/* Hybrid ANC design system - shared by the lab console (src/anc/server/static) and the phone demo (web/, copied there by
   scripts/build_web.py). Dark-first: charcoal background, lighter rounded surfaces, one restrained mint accent. Colour beyond
   the accent only carries meaning: amber = the noisy input / "A", mint = the enhanced output / "B", green / red = pass / fail. */

:root {
  --bg: #15161c;
  --sidebar: #1a1b22;
  --surface: #1f2029;
  --elevated: #272833;
  --hover: #2f303c;
  --border: rgba(255, 255, 255, .065);
  --border-strong: rgba(255, 255, 255, .12);

  --text: #eef0f3;
  --muted: #9a9dab;
  --faint: #6c6f7d;

  --accent: #9fe3d6;
  --accent-strong: #7fd8c7;
  --accent-ink: #0c2a25;
  --accent-soft: rgba(159, 227, 214, .12);
  --input: #f2b04c;                  /* the noisy signal, "A" */
  --input-soft: rgba(242, 176, 76, .13);
  --ok: #5ad48a;
  --ok-soft: rgba(90, 212, 138, .14);
  --bad: #f06c68;
  --bad-soft: rgba(240, 108, 104, .14);
  --info: #7cb4f5;

  --r-card: 16px;
  --r-ctl: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 0, 0, .18);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ icons */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round;
     stroke-linejoin: round; vertical-align: middle; }
.i.sm { width: 15px; height: 15px; }
.i.lg { width: 22px; height: 22px; }
.i.fill { fill: currentColor; stroke: none; }

/* ------------------------------------------------------------------ app shell: sidebar + main */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sidebar); border-right: 1px solid var(--border);
           display: flex; flex-direction: column; padding: 20px 14px; gap: 22px; z-index: 30; }
.logo { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.logo-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft);
             color: var(--accent); flex: none; }
.logo b { display: block; font-size: 15px; font-weight: 650; letter-spacing: .01em; }
.logo small { display: block; color: var(--faint); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
             padding: 0 12px; margin: 4px 0 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-ctl); color: var(--muted);
         font-weight: 500; transition: background .15s var(--ease), color .15s var(--ease); text-decoration: none; }
.nav a:hover { background: var(--elevated); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.active .i { stroke-width: 2; }
.side-foot { margin-top: auto; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 18px 28px;
          background: rgba(21, 22, 28, .86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.page-title { min-width: 0; flex: 1; }
.page-title h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.page-title p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.content { padding: 24px 28px 40px; width: 100%; max-width: 1480px; }
.btn.menu-btn { display: none; }

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 20px;
        box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-head .grow { flex: 1; min-width: 0; }
.step { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: 13px;
        font-weight: 700; background: var(--elevated); color: var(--accent); border: 1px solid var(--border-strong); }
.card-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
             background: var(--elevated); color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }

/* ------------------------------------------------------------------ type helpers */
.label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; margin: 14px 0 7px; }
.label:first-child { margin-top: 0; }
.note { font-size: 12.5px; color: var(--muted); margin-top: 12px; line-height: 1.55; }
.note.err { color: #ffb9b6; }
.hint { color: var(--faint); font-size: 12px; font-weight: 400; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }
kbd { font: 600 11px var(--mono); color: var(--muted); background: var(--bg); border: 1px solid var(--border-strong);
      border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: var(--r-ctl);
       border: 1px solid var(--border-strong); background: var(--elevated); color: var(--text); font-weight: 550; cursor: pointer;
       white-space: nowrap; transition: background .15s var(--ease), border-color .15s var(--ease), transform .08s, box-shadow .15s; }
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn.off { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); box-shadow: 0 0 0 4px var(--accent-soft); }
.btn.stop { background: var(--bad-soft); border-color: rgba(240, 108, 104, .45); color: #ffc9c6; font-weight: 650; }
.btn.stop:hover { background: rgba(240, 108, 104, .24); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--elevated); color: var(--text); }
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.lg { padding: 13px 22px; font-size: 15px; border-radius: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* segmented control */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
.seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 10px;
              border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 500;
              transition: background .15s var(--ease), color .15s var(--ease); }
.seg button:hover:not(.on) { color: var(--text); background: var(--elevated); }
.seg button.on { background: var(--elevated); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.seg button.on .i { color: var(--accent); }

/* inputs */
select, input[type=text] { width: 100%; background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--r-ctl);
         padding: 9px 12px; color: var(--text); outline: none; transition: border-color .15s; }
select:hover { border-color: rgba(255, 255, 255, .2); }
select:focus { border-color: var(--accent); }
select:disabled { opacity: .55; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.range { margin: 14px 0 0; }
.range-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.range-top output, .range-top b { font: 600 12.5px var(--mono); color: var(--text); }

/* switch (styled checkbox) */
.switch { position: relative; width: 38px; height: 22px; flex: none; appearance: none; -webkit-appearance: none; margin: 0;
          background: var(--hover); border-radius: 999px; cursor: pointer; transition: background .15s var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
                 background: #c9ccd6; transition: transform .18s var(--ease), background .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); background: var(--accent-ink); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-top: 1px solid var(--border); }
.toggle:first-child { border-top: 0; padding-top: 0; }
.toggle b { display: block; font-weight: 550; font-size: 13.5px; }
.toggle span { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ pills, badges, dots */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface);
        border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.live .dot, .dot.live { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(90, 212, 138, 0); } }
.badge { display: inline-flex; align-items: center; gap: 5px; font: 650 10.5px var(--font); letter-spacing: .04em; padding: 3px 8px;
         border-radius: 999px; white-space: nowrap; }
.badge.pass { background: var(--ok-soft); color: var(--ok); }
.badge.fail { background: var(--input-soft); color: var(--input); }
.badge.na { background: var(--elevated); color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13px;
          background: rgba(124, 180, 245, .08); border: 1px solid rgba(124, 180, 245, .22); color: #cfe2fb; }
.banner .i { color: var(--info); margin-top: 1px; }
.banner.warn { background: var(--input-soft); border-color: rgba(242, 176, 76, .3); color: #fbdcaa; }
.banner.warn .i { color: var(--input); }

/* ------------------------------------------------------------------ stat tiles */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 18px; box-shadow: var(--shadow); }
.stat .k { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .sub { color: var(--muted); font-size: 12px; }
.up { color: var(--ok); }

/* ------------------------------------------------------------------ key/value lists */
.kvlist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.kvlist div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border);
              font-size: 13px; color: var(--muted); }
.kvlist b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ------------------------------------------------------------------ tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--faint); font-weight: 600; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
            padding: 0 12px 10px 0; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; }
.table-wrap { overflow-x: auto; }

/* ------------------------------------------------------------------ bars (results charts) */
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row .bar-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.bar-row .bar-label b { color: var(--text); font-weight: 600; }
.bar { height: 8px; border-radius: 999px; background: var(--elevated); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transform-origin: left;
         animation: grow .6s var(--ease) both; }
.bar i.in { background: var(--input); }
.bar i.ghost { background: #4a4c5a; }
@keyframes grow { from { transform: scaleX(0); } }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ------------------------------------------------------------------ toast + skeleton */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 12px); background: var(--elevated); color: var(--text);
         border: 1px solid var(--border-strong); padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); opacity: 0;
         pointer-events: none; transition: opacity .18s var(--ease), transform .18s var(--ease); z-index: 60; max-width: 90vw; font-size: 13px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--elevated) 25%, var(--hover) 50%, var(--elevated) 75%);
            background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.fade-in { animation: fadein .22s var(--ease) both; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }

/* ------------------------------------------------------------------ responsive shell */
@media (max-width: 1200px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 20px 12px; align-items: center; }
  .logo { padding: 0; } .logo > div, .nav a span, .nav-label, .side-foot { display: none; }
  .nav a { justify-content: center; padding: 11px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; align-items: stretch; transform: translateX(-100%);
             transition: transform .22s var(--ease); box-shadow: var(--shadow); }
  .logo > div, .nav a span, .nav-label, .side-foot { display: block; }
  .nav a { justify-content: flex-start; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 25; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .page-title h1 { font-size: 18px; } .page-title p { display: none; }
  .content { padding: 16px 16px 32px; }
  .grid-2, .grid-3, .grid-4, .kvlist { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
