:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d1d1b; --muted: #6b6a64; --line: #e2e0d8;
  --accent: #c2410c; --accent-ink: #fff; --think: #f1efe8; --ok: #15803d; --bad: #b91c1c;
  --cold: #e8e4d8; --hot: #c2410c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121211; --panel: #1b1b19; --ink: #ecebe6; --muted: #9a988f; --line: #2c2b28;
    --accent: #f97316; --accent-ink: #111; --think: #22211e; --cold: #2c2b28; --hot: #f97316; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
.top { padding: 18px 20px 8px; max-width: 1200px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }
.lede { color: var(--muted); margin: 4px 0 0; }
.notice { margin: 8px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--think); border: 1px solid var(--line); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; max-width: 1200px; margin: 0 auto; padding: 8px 20px 24px; }
.chat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 72vh; }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; max-height: 70vh; }
.msg { max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 12px 12px 2px 12px; }
.msg.assistant { align-self: flex-start; }
.msg.doc { align-self: flex-end; font-size: 13px; color: var(--muted); }
details.thinking { background: var(--think); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
details.thinking summary { cursor: pointer; }
details.thinking .t { white-space: pre-wrap; max-height: 240px; overflow-y: auto; }
.meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.ask { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.ask textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: inherit; background: var(--bg); color: var(--ink); max-height: 200px; }
.ask button { border: 0; border-radius: 8px; padding: 9px 16px; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.ask button:disabled { opacity: .5; cursor: default; }
.upload { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 20px; color: var(--muted); }
.upload input { display: none; }
.docs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.docs .k { width: 100%; }
.chip { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--muted); background: none; font-family: inherit; }
button.chip { cursor: pointer; text-align: left; }
button.chip:disabled { opacity: .55; cursor: default; }
.chip.on { border-color: var(--accent); color: var(--ink); }
.msg.pinned { align-self: center; font-size: 13px; color: var(--muted); }
.status { min-height: 20px; padding: 0 12px 6px; font-size: 13px; color: var(--muted); }
.status.err { color: var(--bad); }
.link { align-self: flex-start; margin: 0 12px 10px; background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; }
.live { display: flex; flex-direction: column; gap: 14px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.tile.wide { grid-column: span 2; }
.k { font-size: 12px; color: var(--muted); }
.v { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.note { font-size: 11px; color: var(--muted); }
.map { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.map svg { width: 100%; height: auto; display: block; }
.map line { stroke: var(--line); stroke-width: 1.2; }
.map circle { stroke: var(--panel); stroke-width: 1.5; transition: fill .6s; }
.map circle.lent, .map circle.silent { fill: var(--panel); stroke: var(--muted); }
.map circle.silent { stroke-dasharray: 2 2; }
.map figcaption { font-size: 12px; color: var(--muted); text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; padding: 8px 16px 20px; }
  .top { padding: 14px 16px 4px; }
  .live { order: -1; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tile.wide { grid-column: span 4; }
  .v { font-size: 18px; }
  .map { display: none; }
  .chat { min-height: 60vh; }
}
