@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #f4f5f7; --panel: #ffffff; --panel-2: #f0f2f5; --line: #dfe3e8;
  --fg: #12161c; --muted: #5d6673; --faint: #8a93a0;
  --accent: #7c8cff; --ok: #1f9d55; --warn: #c98a00; --bad: #d64545;
  --c1: #3f7be0; --c2: #e0773f; --c3: #2e9e6a; --c4: #a056d6; --c5: #c9a400; --c6: #d64575;
  --grid: rgba(18, 22, 28, 0.08);
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --sans: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0d1014; --panel: #151a20; --panel-2: #1b2129; --line: #262e38;
    --fg: #e8ecf1; --muted: #9aa4b1; --faint: #6b7583;
    --ok: #3ccf7f; --warn: #f0b429; --bad: #ff6464;
    --c1: #6ea2ff; --c2: #ff9a5c; --c3: #4fd18f; --c4: #c08bff; --c5: #ffd23f; --c6: #ff6fa3;
    --grid: rgba(232, 236, 241, 0.07);
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0d1014; --panel: #151a20; --panel-2: #1b2129; --line: #262e38;
  --fg: #e8ecf1; --muted: #9aa4b1; --faint: #6b7583;
  --ok: #3ccf7f; --warn: #f0b429; --bad: #ff6464;
  --c1: #6ea2ff; --c2: #ff9a5c; --c3: #4fd18f; --c4: #c08bff; --c5: #ffd23f; --c6: #ff6fa3;
  --grid: rgba(232, 236, 241, 0.07);
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 .8em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* network bar */
.netbar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.netbar .in { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 4px; height: 48px; overflow-x: auto; scrollbar-width: none; }
.netbar .in::-webkit-scrollbar { display: none; }
.netbar .brand { font-weight: 700; font-size: 13px; text-decoration: none; margin-right: 10px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.netbar .brand i { width: 10px; height: 10px; border-radius: 3px; background: linear-gradient(135deg, #ff6b4a, #f5b301, #19c2b0, #4cc764, #3fa2ff); }
.netbar a.node { font-size: 13px; text-decoration: none; padding: 6px 10px; border-radius: 7px; color: var(--muted); white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.netbar a.node:hover { background: var(--panel-2); color: var(--fg); }
.netbar a.node.on { color: var(--fg); background: var(--panel-2); }
.netbar a.node b { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.netbar .stage { font-family: var(--mono); font-size: 10.5px; color: var(--faint); text-transform: uppercase; }

/* layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.hero { padding: 40px 0 24px; }
.hero .kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.hero .kicker::before { content: ''; width: 18px; height: 2px; background: var(--accent); }
.hero p.lead { font-size: 17px; color: var(--muted); max-width: 760px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.side { grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
@media (max-width: 960px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .side { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.panel .head h2, .panel .head h3 { margin: 0; }
section { margin: 0 0 16px; }

/* stat tiles */
.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font: 600 26px/1.15 var(--mono); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* controls */
label.f { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
label.f span.val { float: right; color: var(--fg); font-family: var(--mono); }
input[type='range'] { width: 100%; accent-color: var(--accent); }
input[type='text'], input[type='number'], select, textarea {
  width: 100%; font: inherit; color: var(--fg); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; }
.btn { font: 500 14px var(--sans); border: 1px solid var(--line); background: var(--panel-2); color: var(--fg);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; text-decoration: none; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: 500 13px var(--sans); border: 0; background: transparent; color: var(--muted); padding: 6px 12px; cursor: pointer; }
.seg button.on { background: var(--panel-2); color: var(--fg); }

/* tags */
.tag { display: inline-flex; align-items: center; gap: 6px; font: 500 12px var(--mono); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.tag.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tbl td.n, .tbl th.n { text-align: right; font-family: var(--mono); }
.scroll { overflow: auto; max-height: 420px; }

/* charts */
.chart { position: relative; width: 100%; height: 260px; }
.chart.tall { height: 340px; }
.chart.short { height: 180px; }
.chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart .tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); white-space: nowrap; display: none; z-index: 5; }
.chart .tip b { font-family: var(--mono); font-weight: 500; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* research notes */
.notes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .notes { grid-template-columns: 1fr; } }
.notes h3 { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.notes p, .notes li { color: var(--muted); font-size: 14px; }
.notes ul { padding-left: 18px; margin: 0; }

footer.foot { border-top: 1px solid var(--line); margin-top: 32px; padding: 20px 0 40px; font-size: 13px; color: var(--faint); }
footer.foot .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.sim-badge { font: 500 11px var(--mono); color: var(--warn); border: 1px dashed color-mix(in srgb, var(--warn) 50%, transparent); padding: 2px 8px; border-radius: 6px; }
.hidden { display: none !important; }
