:root {
  --bg: #f6f6f4; --surface: #ffffff; --border: #e2e2dd; --text: #191919; --muted: #666666;
  --accent: #257de0; --bar: #257de0; --bar-hover: #1757ac; --add: #008a17; --del: #dc3c3d;
  --user: #eaf2fd; --code: #f1f1ee; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111; --surface: #191919; --border: #2c2c2c; --text: #efefef; --muted: #9c9c9c;
    --accent: #519ced; --bar: #338ced; --bar-hover: #84b9f3; --add: #0aac23; --del: #eb6263;
    --user: #1b2a3d; --code: #222222; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
header { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center;
  padding: calc(.6rem + env(safe-area-inset-top, 0px)) 1rem .6rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; color: var(--text); }
nav { display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
nav a { color: var(--muted); }
nav a.on { color: var(--text); font-weight: 600; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem calc(4rem + env(safe-area-inset-bottom, 0px)); }
#offline { background: #f2a600; color: #191919; padding: .4rem 1rem; font-size: .85rem; text-align: center; }
h1 { font-size: 1.3rem; margin: .2rem 0 1rem; }
h2 { font-size: 1rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.tile .v { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .k { color: var(--muted); font-size: .8rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.grow { flex: 1 1 200px; min-width: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; }
textarea { width: 100%; min-height: 6rem; resize: vertical; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: .55rem 1rem; cursor: pointer; font-weight: 600; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button:disabled { opacity: .5; cursor: default; }
.tbl { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 10rem; max-width: 26rem; }
.add { color: var(--add); } .del { color: var(--del); }
.list > a { display: block; color: inherit; padding: .7rem .2rem; border-bottom: 1px solid var(--border); }
.list > a:hover { background: var(--surface); }
.list .t { font-weight: 600; overflow-wrap: anywhere; }
.chart { overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 520px; height: auto; }
.chart .bar { fill: var(--bar); }
.chart .hit:hover + .bar, .chart .bar.on { fill: var(--bar-hover); }
.chart .axis { stroke: var(--border); }
.chart text { fill: var(--muted); font-size: 11px; }
#tip { position: fixed; z-index: 10; pointer-events: none; background: var(--text); color: var(--bg); padding: .35rem .55rem; border-radius: 6px; font-size: .8rem; }
.msg { margin: .5rem 0; padding: .6rem .8rem; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { background: var(--user); }
.msg.assistant { background: var(--surface); border: 1px solid var(--border); }
.msg .ts { display: block; color: var(--muted); font-size: .72rem; margin-bottom: .2rem; }
details.tool { margin: .25rem 0 .25rem .8rem; font-size: .82rem; }
details.tool summary { cursor: pointer; color: var(--muted); }
details.tool pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--code); padding: .5rem; border-radius: 6px; max-height: 24rem; overflow: auto; margin: .3rem 0; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: .6rem 0 calc(.6rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); }
.pill { display: inline-block; font-size: .72rem; padding: .05rem .45rem; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); }
.day { margin-top: 1.2rem; font-weight: 600; }
.entry { padding: .35rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; white-space: pre-wrap; }
.center { max-width: 26rem; margin: 15vh auto; text-align: center; }
