:root {
  color-scheme: light;
  --bg: #fcfcfb;
  --surface: #ffffff;
  --surface-2: #f3f2ef;
  --grid: #e4e3df;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --good: #008300;
  --warning: #c98500;
  --critical: #d03b3b;
  --radius: 10px;
  --maxw: 1080px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --grid: #33332f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --good: #2ea043;
    --warning: #d29922;
    --critical: #e66767;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
}
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }

header.site {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--grid);
}
header.site .inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0.7rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
header.site .brand { font-weight: 700; text-decoration: none; color: var(--text-primary); letter-spacing: 0.01em; }
header.site nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
header.site nav a { color: var(--text-secondary); text-decoration: none; font-size: 0.95rem; }
header.site nav a:hover, header.site nav a.active { color: var(--text-primary); }
header.site nav a.active { border-bottom: 2px solid var(--accent); }

main { max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.hero { padding: 2.5rem 0 1.5rem; }
.hero .kicker { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8rem; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3rem); line-height: 1.15; margin: 0.3rem 0 0.8rem; }
.hero p.lede { font-size: 1.15rem; color: var(--text-secondary); max-width: 62ch; }
h2 { margin-top: 2.6rem; font-size: 1.5rem; }
h3 { margin-top: 1.6rem; font-size: 1.15rem; }
p, li { max-width: 75ch; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}
.card h3 { margin-top: 0; }
.card p { margin: 0.4rem 0; color: var(--text-secondary); }
a.card { text-decoration: none; color: inherit; transition: border-color 0.15s; }
a.card:hover { border-color: var(--accent); }

.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 1.2rem 0; }
.stat { background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius); padding: 0.9rem 1rem; }
.stat .label { color: var(--text-muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .value { font-size: 1.7rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--text-secondary); font-size: 0.88rem; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.93rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius); margin: 1rem 0; }
th, td { text-align: left; padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--text-secondary); font-weight: 600; background: var(--surface-2); }
td.num, th.num { text-align: right; }
tr.total td { font-weight: 650; border-top: 2px solid var(--grid); }
tr.section td { background: var(--surface-2); font-weight: 600; color: var(--text-secondary); }

.badge { display: inline-flex; align-items: center; gap: 0.3em; font-size: 0.82rem; font-weight: 600; padding: 0.05rem 0.5rem; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.badge.good { color: var(--good); }
.badge.warn { color: var(--warning); }
.badge.bad { color: var(--critical); }

.callout { border-left: 4px solid var(--accent); background: var(--surface); padding: 0.8rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.2rem 0; }
.callout.warn { border-left-color: var(--warning); }
.callout p { margin: 0.3rem 0; }

figure.chart { margin: 1.4rem 0; background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius); padding: 1rem 1rem 0.6rem; position: relative; }
figure.chart figcaption .title { font-weight: 650; }
figure.chart figcaption .subtitle { color: var(--text-secondary); font-size: 0.9rem; }
figure.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
figure.chart .legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-secondary); margin: 0.4rem 0; }
figure.chart .legend .key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 0.35rem; }
figure.chart .legend .key.sw { height: 10px; width: 10px; border-radius: 2px; }
svg .gridline { stroke: var(--grid); stroke-width: 1; }
svg .axis-text { fill: var(--text-muted); font-size: 11px; }
svg .label-text { fill: var(--text-secondary); font-size: 11px; }
svg .ref-line { stroke: var(--critical); stroke-width: 1.5; }
svg .ref-text { fill: var(--text-secondary); font-size: 11px; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--grid); border-radius: 8px; padding: 0.4rem 0.6rem; font-size: 0.82rem;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.12); white-space: nowrap; display: none; z-index: 5;
}
.tooltip .k { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.35rem; }
details { margin: 0.6rem 0; }
details summary { cursor: pointer; color: var(--text-secondary); font-size: 0.9rem; }

.timeline { list-style: none; padding: 0; margin: 1rem 0; border-left: 2px solid var(--grid); }
.timeline li { position: relative; padding: 0 0 1.1rem 1.4rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 0.45rem; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.timeline .when { font-weight: 650; }
.timeline .what { color: var(--text-secondary); }

.modes { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 1rem 0; }
.mode { background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius); padding: 0.7rem 0.8rem; font-size: 0.9rem; }
.mode b { display: block; }
.mode span { color: var(--text-secondary); }

footer.site { border-top: 1px solid var(--grid); color: var(--text-muted); font-size: 0.85rem; }
footer.site .inner { max-width: var(--maxw); margin: 0 auto; padding: 1.2rem 1.25rem 2rem; }

/* ---------------------------------------------------------------- mockup */
.mockup-wrap { position: relative; background: radial-gradient(ellipse at 50% 35%, var(--surface-2), var(--surface) 70%); border: 1px solid var(--grid); border-radius: var(--radius); overflow: hidden; }
#mockup { width: 100%; height: min(72vh, 640px); cursor: grab; }
#mockup canvas { display: block; width: 100%; height: 100%; }
#mockup-labels { position: absolute; inset: 0; pointer-events: none; }
.mockup-label { position: absolute; left: 0; top: 0; font-size: 0.75rem; color: var(--text-primary); background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--grid); border-radius: 6px; padding: 0.1rem 0.4rem; white-space: nowrap; }
#mockup-tip { position: absolute; display: none; max-width: 290px; pointer-events: none; background: var(--surface); border: 1px solid var(--grid); border-radius: 8px; padding: 0.5rem 0.65rem; font-size: 0.82rem; box-shadow: 0 6px 18px rgb(0 0 0 / 0.18); z-index: 3; }
.mockup-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.7rem; border-top: 1px solid var(--grid); background: var(--surface); }
.mockup-bar button, .chat button { font: inherit; font-size: 0.85rem; padding: 0.35rem 0.75rem; border-radius: 999px; border: 1px solid var(--grid); background: var(--surface-2); color: var(--text-primary); cursor: pointer; }
.mockup-bar button:hover, .chat button:hover { border-color: var(--accent); }
.mockup-bar button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.mockup-bar .sep { flex: 1; }
.key-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.4rem 1.2rem; padding: 0; list-style: none; }
.key-list li { display: flex; gap: 0.5rem; align-items: baseline; color: var(--text-secondary); font-size: 0.92rem; }
.key-list .sw { flex: none; width: 12px; height: 12px; border-radius: 3px; transform: translateY(2px); }

/* ---------------------------------------------------------------- chat */
.chat-fab { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 40; font: inherit; font-weight: 600; padding: 0.7rem 1.1rem; border-radius: 999px; border: none; background: var(--accent); color: #fff; box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); cursor: pointer; }
.chat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--grid); border-radius: 14px; }
.chat-floating { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 41; width: min(420px, calc(100vw - 2rem)); height: min(620px, calc(100vh - 6rem)); box-shadow: 0 12px 40px rgb(0 0 0 / 0.3); display: none; }
.chat-floating.open { display: flex; }
.chat-inline { height: min(75vh, 760px); }
.chat-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--grid); }
.chat-head span { color: var(--text-muted); font-size: 0.8rem; flex: 1; }
.chat-head .chat-close { border: none; background: none; font-size: 1.4rem; line-height: 1; padding: 0 0.3rem; }
.chat-log { flex: 1; overflow-y: auto; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.7rem; }
.msg { max-width: 92%; padding: 0.55rem 0.8rem; border-radius: 12px; font-size: 0.93rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg p { margin: 0.3rem 0; } .msg ul, .msg ol { margin: 0.3rem 0; padding-left: 1.2rem; } .msg h4 { margin: 0.5rem 0 0.2rem; }
.msg pre { overflow-x: auto; background: var(--surface-2); padding: 0.5rem; border-radius: 6px; }
.msg .table-wrap { margin: 0.4rem 0; font-size: 0.85rem; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); }
.msg.error { border: 1px solid var(--critical); }
.msg-sources { margin-top: 0.4rem; font-size: 0.8rem; color: var(--text-secondary); }
.msg-sources ul { padding-left: 1.1rem; margin: 0.3rem 0 0; }
.chat-suggest { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }
.chat-suggest button { text-align: left; border-radius: 10px; }
.chat-form { display: flex; gap: 0.5rem; padding: 0.7rem; border-top: 1px solid var(--grid); }
.chat-form textarea { flex: 1; resize: none; font: inherit; font-size: 0.93rem; padding: 0.5rem 0.6rem; border-radius: 10px; border: 1px solid var(--grid); background: var(--bg); color: var(--text-primary); }
.chat-form button[type="submit"] { background: var(--accent); color: #fff; border-color: var(--accent); border-radius: 10px; }
.chat-foot { font-size: 0.72rem; color: var(--text-muted); padding: 0 0.9rem 0.6rem; }
.dots i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--text-muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; } .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
