/* SortSight dashboard – dark-first, light supported. Tokens first, components below. */
:root {
  color-scheme: dark;
  --bg: #0e0e0e;
  --bg-2: #141414;
  --surface: rgba(239, 238, 232, 0.04);
  --surface-solid: #161616;
  --surface-hi: rgba(239, 238, 232, 0.075);
  --border: rgba(239, 238, 232, 0.10);
  --border-hi: rgba(239, 238, 232, 0.2);
  --grid: rgba(239, 238, 232, 0.07);
  --text: #efeee8;
  --text-2: #b9b8b1;
  --text-3: #85847d;
  --accent: #ff5a36;
  --accent-ink: #0e0e0e;
  --accent-soft: rgba(255, 90, 54, 0.14);
  --warn: #ffb454;
  --eye-on: #efeee8; --eye-off: #1d1d1c;
  --series-1: #efeee8;
  --series-2: #ff5a36;
  --series-3: #9a9992;
  --shadow: none;
  --dot: rgba(239, 238, 232, 0.09);
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pixel: "Pixelify Sans", "Silkscreen", ui-monospace, monospace;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: var(--pixel);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #efeee8; --bg-2: #e6e5de;
    --surface: rgba(255, 255, 255, 0.6); --surface-solid: #ffffff; --surface-hi: #ffffff;
    --border: rgba(14, 14, 14, 0.11); --border-hi: rgba(14, 14, 14, 0.22);
    --grid: rgba(14, 14, 14, 0.09);
    --text: #0e0e0e; --text-2: #4a4a46; --text-3: #7b7a74;
    --accent: #e8431f; --accent-ink: #ffffff; --accent-soft: rgba(232, 67, 31, 0.1);
    --warn: #b5650b; --eye-on: #0e0e0e; --eye-off: #dedcd4;
    --series-1: #0e0e0e; --series-2: #e8431f; --series-3: #85847d;
    --shadow: none;
    --dot: rgba(14, 14, 14, 0.12);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
    --bg: #efeee8; --bg-2: #e6e5de;
    --surface: rgba(255, 255, 255, 0.6); --surface-solid: #ffffff; --surface-hi: #ffffff;
    --border: rgba(14, 14, 14, 0.11); --border-hi: rgba(14, 14, 14, 0.22);
    --grid: rgba(14, 14, 14, 0.09);
    --text: #0e0e0e; --text-2: #4a4a46; --text-3: #7b7a74;
    --accent: #e8431f; --accent-ink: #ffffff; --accent-soft: rgba(232, 67, 31, 0.1);
    --warn: #b5650b; --eye-on: #0e0e0e; --eye-off: #dedcd4;
    --series-1: #0e0e0e; --series-2: #e8431f; --series-3: #85847d;
    --shadow: none;
    --dot: rgba(14, 14, 14, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}
button, select, input { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }

/* ambient background: pixel dot grid */
.dotgrid { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(circle, var(--dot) 1.6px, transparent 1.8px); background-size: 28px 28px; background-position: 10px 10px; }

/* nav */
.nav {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 12px max(20px, calc((100vw - 1240px) / 2 + 24px));
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand .eye { width: 48px; height: auto; flex: none; }
.wordmark { height: 24px; width: auto; display: block; color: var(--text); stroke: currentColor; stroke-width: .42; stroke-linejoin: miter; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); margin-left: 12px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 500; transition: background .2s, color .2s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--text); color: var(--bg); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.live .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--text-3); }
.live.on .dot { background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: ping 2s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; transition: all .2s; }
.icon-btn:hover { color: var(--text); border-color: var(--border-hi); }

main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 96px; }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: stretch; margin-bottom: 20px; }
.hero-copy { padding: 22px 4px 8px; display: flex; flex-direction: column; justify-content: center; }
.eyebrow { color: var(--accent); font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; margin-bottom: 14px; }
h1 { font-family: var(--pixel); font-weight: 600; font-size: clamp(36px, 5.4vw, 68px); line-height: 1.04; letter-spacing: 0; }
h1 em { font-style: normal; color: var(--accent); }
.hero-sub { color: var(--text-2); font-size: 17px; max-width: 46ch; margin-top: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.chip b { color: var(--text); font-weight: 600; }

/* smart lid */
.lid-card {
  position: relative; border-radius: 12px; padding: 18px 18px 20px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; --c: 255 90 54;
  transition: border-color .6s;
}
.lid-card.live-glow { border-color: color-mix(in srgb, rgb(var(--c)) 55%, var(--border)); }
.lid-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--text-3); letter-spacing: .02em; }
.lid-title { font-family: var(--mono); font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: .2em; font-size: 11px; }
.lid-head .lid-state { font-family: var(--mono); font-size: 11.5px; }
.lid { position: relative; margin: 14px 0 6px; padding: 22px 12px; border-radius: 10px; background: #0e0e0e; border: 1px solid var(--border-hi); display: grid; place-items: center; overflow: hidden; }
.px-row { position: relative; display: grid; grid-template-columns: repeat(13, 1fr); gap: clamp(3px, 1.1%, 6px); width: min(100%, 360px); }
.px-row i { aspect-ratio: 1; border-radius: 22%; background: transparent; }
.px-row i.e { background: #efeee8; }
.px-row i.o { background: #1d1d1c; }
.px-row i.s { background: #ff5a36; transition: background .35s, box-shadow .35s; }
.px-row i.s.on { background: rgb(var(--c)); box-shadow: 0 0 12px 1px rgb(var(--c) / .7); }
.px-row.idle i.s { animation: scan 2.4s steps(1) infinite; }
@keyframes scan { 0%, 70% { opacity: 1; } 80% { opacity: .35; } }
.lid-item { min-height: 92px; padding: 6px 4px 0; }
.lid-name { font-family: var(--pixel); font-size: 24px; font-weight: 500; line-height: 1.15; }
.lid-bin { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--text-2); font-size: 14px; }
.lid-advice { color: var(--text-2); font-size: 13.5px; margin-top: 6px; }
.lid-item.flash { animation: rise .6s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { position: relative; overflow: hidden; border-radius: var(--radius); padding: 16px 16px 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .25s, border-color .25s; }
.tile:hover { border-color: var(--accent); }
.tile .k { color: var(--text-2); font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; }
.tile .v { margin-top: 8px; font-family: var(--pixel); font-size: 40px; font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .v small { font-size: 14px; font-weight: 500; color: var(--text-3); margin-left: 4px; letter-spacing: 0; }
.tile .d { color: var(--text-3); font-size: 12px; margin-top: 2px; min-height: 18px; }
.tile svg.spark { display: block; width: 100%; height: 34px; margin-top: 8px; overflow: visible; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card { min-width: 0; border-radius: var(--radius); padding: 20px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: 1 / -1; }
.card-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); justify-content: flex-end; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -0.5px; }
.btn { border: 1px solid var(--border-hi); background: var(--surface-hi); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; transition: all .2s; }
.btn:hover { border-color: var(--accent); }
.btn.sm { padding: 5px 12px; font-size: 12px; } .btn.ghost { background: transparent; }

/* chart */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hover-col { fill: var(--text); opacity: 0; transition: opacity .15s; }
.chart .hit:hover + .hover-col, .chart g.col:hover .hover-col { opacity: .06; }
.chart .bar { transition: opacity .2s; }
.chart:hover .bar { opacity: .75; } .chart g.col:hover .bar { opacity: 1; }

/* ring */
.ring-wrap { display: grid; place-items: center; margin: 4px 0 16px; }
.ring { position: relative; width: 164px; height: 164px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .trk { stroke: var(--grid); } .ring .val { stroke: var(--accent); transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); filter: drop-shadow(0 0 8px var(--accent-soft)); }
.ring .mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .big { font-family: var(--pixel); font-size: 44px; font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; line-height: 1; }
.ring .big small { font-size: 18px; color: var(--text-3); }
.ring .lbl { color: var(--text-3); font-size: 12px; margin-top: 4px; }

/* bars */
.hbars { display: grid; gap: 11px; }
.hbar { display: grid; grid-template-columns: minmax(0, 11.5em) minmax(40px, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .lab { display: flex; font-size: 12.5px; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.hbar .track { height: 8px; border-radius: 99px; background: var(--grid); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 99px; background: var(--series-1); width: 0; transition: width .9s cubic-bezier(.2,.8,.2,1); }
.hbar .val { color: var(--text-2); font-variant-numeric: tabular-nums; }
.empty { color: var(--text-3); font-size: 13px; }

/* report */
.report h3 { font-family: var(--pixel); font-weight: 500; font-size: 24px; line-height: 1.15; letter-spacing: -0.01em; margin-bottom: 8px; }
.report p { color: var(--text-2); font-size: 14px; }
.report ol { list-style: none; counter-reset: t; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.report li { counter-increment: t; position: relative; padding: 10px 12px 10px 42px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); }
.report li::before { content: counter(t); position: absolute; left: 12px; top: 10px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 11.5px; }
.goal { display: inline-flex; padding: 8px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; }

/* people */
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.person { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--accent-ink); background: var(--accent); }
.avatar.na { background: var(--grid); color: var(--text-2); }
.person .n { font-weight: 600; font-size: 14px; } .person .m { color: var(--text-3); font-size: 12px; }
.person .bar { height: 6px; border-radius: 99px; background: var(--grid); margin-top: 6px; overflow: hidden; }
.person .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.person .score { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; }
.row-i { display: grid; grid-template-columns: 112px minmax(0, 1.6fr) minmax(0, 1.2fr) 70px 82px 84px; gap: 12px; align-items: center; padding: 11px 6px; border-top: 1px solid var(--border); font-size: 13.5px; transition: background .2s; }
.row-i:first-child { border-top: 0; } .row-i:hover { background: var(--surface); border-radius: 12px; }
.row-i .t { color: var(--text-3); font-size: 12.5px; white-space: nowrap; } .row-i .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-i .nm small { color: var(--text-3); margin-left: 6px; }
.row-i .num { text-align: right; font-variant-numeric: tabular-nums; } .row-i .how { color: var(--text-3); font-size: 12.5px; text-align: right; }
.bin-chip { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 8px; border-radius: 8px; background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); font-size: 12.5px; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-i.new { animation: rise .6s cubic-bezier(.2,.8,.2,1); }

.foot { color: var(--text-3); font-size: 12px; margin-top: 28px; max-width: 80ch; }
.tip { position: fixed; pointer-events: none; z-index: 50; background: var(--text); color: var(--bg); padding: 8px 11px; border-radius: 10px; font-size: 12px; line-height: 1.45; max-width: 250px; box-shadow: 0 10px 30px -8px rgba(0,0,0,.5); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* entrance */
@media (prefers-reduced-motion: no-preference) {
  .hero > *, .tile, .card { animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
  .tile:nth-child(2) { animation-delay: .05s; } .tile:nth-child(3) { animation-delay: .1s; } .tile:nth-child(4) { animation-delay: .15s; } .tile:nth-child(5) { animation-delay: .2s; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 1060px) {
  .hero { grid-template-columns: 1fr; }
  
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .nav { padding: 10px 14px; gap: 8px; flex-wrap: wrap; } .nav .seg { margin-left: 0; order: 3; width: 100%; } .nav .seg button { flex: 1; }
  main { padding: 16px 14px 60px; } .tiles { grid-template-columns: 1fr; }
  .card { padding: 16px; } .lid { height: 120px; } .px-row { gap: 8px; padding: 12px; } .px-row i { width: 18px; height: 18px; }
  .row-i { grid-template-columns: 1fr auto; gap: 4px 10px; } .row-i .t, .row-i .how, .row-i .co2 { display: none; }
  .row-i .bn { grid-column: 1; } .row-i .gr { grid-row: 1; grid-column: 2; }
}

/* ---- simplified main screen ---- */
.tile { padding: 22px 22px 20px; }
.tile .k { font-size: 14px; }
.tile .v { font-size: clamp(40px, 5vw, 56px); margin-top: 10px; }
.tile .v small { font-size: 17px; }
.tile .d { font-size: 13px; margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 12px; }
.chart .val-lbl { fill: var(--text-2); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .val-lbl.now { fill: var(--text); font-size: 13px; }
.chart text { font-size: 12px; }
.chart.small text { font-size: 10.5px; }
.report h3 { font-size: 30px; }
.report li { font-size: 14.5px; }

/* ---- settings sheet ---- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity .22s; backdrop-filter: blur(2px); }
.scrim.open { opacity: 1; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(520px, 100vw); display: flex; flex-direction: column;
  background: var(--surface-solid); border-left: 1px solid var(--border-hi); box-shadow: -30px 0 80px -30px rgba(0,0,0,.6);
  transform: translateX(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1); }
.sheet.open { transform: none; }
.sheet[hidden], .scrim[hidden] { display: none; }
.sheet-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 8px; }
.sheet-h h2 { font-size: 20px; }
.tabs { margin: 8px 22px 0; display: flex; } .tabs button { flex: 1; padding: 7px 6px; }
.sheet-body { overflow: auto; padding: 8px 22px 40px; flex: 1; }
.sheet-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3); font-weight: 600; margin: 26px 0 12px; }
.sheet-body h3:first-child { margin-top: 14px; }
.note { color: var(--text-2); font-size: 14px; margin: 14px 0; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.facts div { display: flex; flex-direction: column; gap: 2px; padding: 11px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.facts span { color: var(--text-3); font-size: 12px; } .facts b { font-size: 15px; font-variant-numeric: tabular-nums; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.json { margin: 0; max-height: 46vh; overflow: auto; padding: 14px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--border);
  font: 12px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--text-2); white-space: pre; }
.sheet label { display: block; font-size: 12px; color: var(--text-3); margin: 16px 0 6px; font-weight: 500; }
.sheet select, .sheet input { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border-hi); background: var(--bg-2); min-width: 0; }
.sheet .row { display: grid; grid-template-columns: 90px auto 1fr; gap: 8px; align-items: center; margin-top: 8px; color: var(--text-3); }
.sheet .row input { width: 90px; }
.sheet .legend { justify-content: flex-start; margin-top: 8px; }
.sheet .row-i { grid-template-columns: minmax(0, 1fr) auto auto; padding: 9px 4px; }
.sheet .row-i .t, .sheet .row-i .how, .sheet .row-i .co2 { display: none; }
.sheet .hbar { grid-template-columns: minmax(0, 10em) minmax(30px, 1fr) auto; }
.sheet .people { gap: 12px; }
.seg[role="radiogroup"] { display: inline-flex; margin-left: 0; }
@media (max-width: 1060px) { .grid2 { grid-template-columns: 1fr; } }

/* ---- connecting a bin ---- */
button.pill { font: inherit; color: var(--text-2); cursor: pointer; transition: border-color .2s, color .2s; }
button.pill:hover { border-color: var(--border-hi); color: var(--text); }
.live.on .dot { background: var(--accent); }
.live.warn .dot { background: var(--warn); animation: none; box-shadow: none; }
.live.none .dot { background: var(--text-3); animation: none; box-shadow: none; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
  padding: 14px 18px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-hi); border-left: 4px solid var(--accent); }
.banner[hidden] { display: none; }
.banner div { display: flex; flex-direction: column; gap: 2px; }
.banner span { color: var(--text-2); font-size: 13.5px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); border-color: transparent; }
.btn:disabled { opacity: .6; cursor: progress; }

.conn-status { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border-radius: 16px; margin-top: 14px; border: 1px solid var(--border); background: var(--surface); }
.conn-status span { color: var(--text-2); font-size: 13.5px; }
.conn-status.ok { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.conn-status.ok b { color: var(--accent); }
.conn-status.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.conn-status.warn b { color: var(--warn); }
.warn { margin-top: 12px; padding: 12px 14px; border-radius: 14px; font-size: 13px; color: var(--text-2);
  background: color-mix(in srgb, var(--warn) 10%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.warn[hidden] { display: none; }

.devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.device { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.device .n { font-weight: 600; font-size: 14.5px; } .device .m { color: var(--text-3); font-size: 12.5px; }
.dev-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); }
.dev-dot.on { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.hint { color: var(--text-3); font-size: 12.5px; margin: 8px 0 0; }
.err { color: #ff7b72; font-size: 13px; margin: 10px 0 0; } .err[hidden] { display: none; }
#add-bin { margin-top: 14px; }
.steps { margin: 6px 0 14px; padding-left: 20px; display: grid; gap: 16px; font-size: 14px; color: var(--text-2); }
.steps li::marker { color: var(--accent); font-weight: 700; } .steps b { color: var(--text); }
code { font: 12.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace; padding: 1px 6px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--border); color: var(--text); }
pre.cmd { margin: 8px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border-hi); font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--text); white-space: pre-wrap; word-break: break-all; user-select: all; }
.waiting { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px dashed var(--border-hi); font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.waiting.done { border-style: solid; border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); color: var(--text); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-hi); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.tick { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; flex: none; }
details.help { margin-top: 22px; font-size: 13.5px; color: var(--text-2); }
details.help summary { cursor: pointer; font-weight: 600; color: var(--text); }
details.help ol { padding-left: 20px; display: grid; gap: 8px; margin: 10px 0 0; }
.tabs { overflow-x: auto; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; white-space: nowrap; padding: 7px 12px; }

/* =====================  MENU BAR  ===================== */
.nav { gap: 14px; }
.nav .seg { margin-left: auto; }
.nav-right { margin-left: 0; }
.menu { position: relative; display: flex; gap: 2px; padding: 4px; margin-left: 8px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); }
.menu button, .menu a { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px;
  border: 0; background: transparent; color: var(--text-2); border-radius: 7px; cursor: pointer;
  font-size: 13.5px; font-weight: 560; white-space: nowrap; transition: color .25s; text-decoration: none; }
.menu button:hover, .menu a:hover { color: var(--text); }
.menu a svg { color: var(--accent); }
.menu button.on { color: var(--bg); }
.menu-ind { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 7px; background: var(--text);
  transition: transform .38s cubic-bezier(.2,.8,.2,1), width .38s cubic-bezier(.2,.8,.2,1), opacity .2s;
}
.menu .ai svg { color: var(--accent); transition: color .25s; }
.menu .ai:not(.on) span { color: var(--accent); }
.menu .ai.on svg { color: var(--bg); }
.menu kbd { font: 600 10.5px var(--mono); padding: 1px 6px; border-radius: 6px;
  border: 1px solid var(--border-hi); color: var(--text-3); transition: all .25s; }
.menu .on kbd { border-color: color-mix(in srgb, var(--bg) 35%, transparent); color: color-mix(in srgb, var(--bg) 65%, transparent); }
.menu-dot { width: 7px; height: 7px; border-radius: 2px; background: var(--text-3); }
.menu-dot.on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.menu-dot.warn { background: var(--warn); }
.icon-btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.menu button:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* =====================  ASK AI PANEL  ===================== */
.ai-orb { width: 36px; height: 36px; border-radius: 8px; flex: none; position: relative; background: #0e0e0e; border: 1px solid var(--border-hi); overflow: hidden; }
.ai-orb::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; background: var(--accent); animation: pulse-scan 2.4s ease-in-out infinite; }
.ai-orb::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 2px; background: #efeee8; }
.ai-orb.sm { width: 26px; height: 26px; margin-top: 2px; }
.ai-orb.sm::after { width: 6px; height: 6px; margin: -3px 0 0 -3px; }
@keyframes pulse-scan { 50% { opacity: .45; } }
.sheet-body:has(.pane-ask:not([hidden])) { overflow: hidden; display: flex; flex-direction: column; padding-bottom: 14px; }
.pane-ask { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.pane-ask[hidden] { display: none; }
.ai-intro { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; }
.ai-intro > div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ai-badge { font-size: 12px; color: var(--text-3); } .ai-badge.off { color: var(--warn); }
.chat { display: flex; flex-direction: column; gap: 14px; padding: 12px 2px; flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.msg { display: flex; gap: 10px; align-items: flex-start; animation: rise .35s cubic-bezier(.2,.8,.2,1) both; }
.msg.user { justify-content: flex-end; }
.bub { max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.user .bub { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg.assistant .bub { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 6px; color: var(--text); }
.msg.err .bub { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.bub p { margin: 0 0 6px; } .bub p:last-child { margin: 0; }
.bub ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.typing { display: inline-flex; gap: 4px; padding: 5px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: bounce 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.ask-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; } .ask-chips[hidden] { display: none; }
.chip-btn { border: 1px solid var(--border-hi); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 7px 13px;
  font-size: 13px; cursor: pointer; transition: all .2s; }
.chip-btn:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 7px 7px 7px 16px; border-radius: 26px; background: var(--bg-2);
  border: 1px solid var(--border-hi); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.composer textarea { flex: 1; border: 0; outline: 0; background: transparent; resize: none; font: inherit; font-size: 14.5px; line-height: 1.45;
  color: var(--text); max-height: 120px; padding: 7px 0; min-width: 0; }
.composer textarea::placeholder { color: var(--text-3); }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; flex: none; display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); transition: transform .15s, opacity .2s; }
.send:disabled { opacity: .3; cursor: default; } .send:not(:disabled):hover { transform: scale(1.07); }
.ask-note { font-size: 11.5px; color: var(--text-3); margin: 8px 4px 0; text-align: center; }
.sheet-h h2 { transition: opacity .2s; }

/* =====================  RESPONSIVE MENU  ===================== */
@media (max-width: 1020px) {
  .menu button:not(.on) span, .menu a span { display: none; }
  .menu button, .menu a { padding: 8px 12px; } .menu kbd { display: none; }
}
@media (max-width: 760px) {
  /* phone: the menu becomes a floating bottom bar */
  .menu { position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 30; margin: 0; padding: 6px;
    background: color-mix(in srgb, var(--surface-solid) 84%, transparent); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-color: var(--border-hi); box-shadow: 0 18px 40px -12px rgba(0,0,0,.6); }
  .menu button, .menu a, .menu button:not(.on) span, .menu a span { display: flex; }
  .menu button, .menu a { flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 4px; font-size: 11px; }
  .menu-ind { top: 6px; bottom: 6px; }
  .menu-dot { position: absolute; top: 7px; right: calc(50% - 20px); }
  main { padding-bottom: 110px; }
  .sheet { padding-bottom: env(safe-area-inset-bottom); }
}

/* ---- the menu stays usable while a panel is open ---- */
.nav { z-index: 45; }
.scrim { top: var(--nav-h, 61px); }
.sheet { top: var(--nav-h, 61px); }
@media (max-width: 760px) {
  /* phone: panel covers the top, the bottom menu bar stays on top of it */
  .nav { z-index: 20; }
  .scrim, .sheet { top: 0; }
  .menu { z-index: 45; }
  .sheet { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
}

/* an element with the hidden attribute must always be hidden, whatever display rule it has */
[hidden] { display: none !important; }

@media (max-width: 760px) {
  /* a blurred (backdrop-filter) header would become the anchor for the fixed bottom menu, so no blur here */
  .nav { backdrop-filter: none; -webkit-backdrop-filter: none; background: color-mix(in srgb, var(--bg) 96%, transparent); }
}

@media (max-width: 760px) {
  /* the menu lives inside the header, so the header (and with it the bottom bar) must sit above the panel */
  .nav { z-index: 45; }
  .scrim, .sheet { top: var(--nav-h, 104px); }
  .menu { z-index: auto; }
}

/* Night 2 brand layer */
h2 { font-family: var(--mono); font-size: 12.5px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; }
.sheet-h h2 { font-size: 15px; }
::selection { background: var(--accent); color: #0e0e0e; }
.px-stub { fill: var(--grid); }
.signoff { margin: 36px 0 0; font-family: var(--mono); font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--text-3); }
.foot { margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .px-row.idle i.s, .ai-orb::before { animation: none; } }

.pill.live { white-space: nowrap; }
