/* BACnet Hub — operations console for chilled-water metering.
   Supply (cold) is teal and return (warm) is amber everywhere they appear. */

@font-face { font-family: 'Plex Sans'; font-weight: 400; font-display: swap; src: url(/fonts/sans/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Plex Sans'; font-weight: 500; font-display: swap; src: url(/fonts/sans/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Plex Sans'; font-weight: 600; font-display: swap; src: url(/fonts/sans/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Plex Cond'; font-weight: 500; font-display: swap; src: url(/fonts/cond/ibm-plex-sans-condensed-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Plex Cond'; font-weight: 600; font-display: swap; src: url(/fonts/cond/ibm-plex-sans-condensed-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Plex Cond'; font-weight: 700; font-display: swap; src: url(/fonts/cond/ibm-plex-sans-condensed-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Plex Mono'; font-weight: 400; font-display: swap; src: url(/fonts/mono/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Plex Mono'; font-weight: 500; font-display: swap; src: url(/fonts/mono/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); }

:root {
  --paper: #EEF2F3;
  --panel: #FFFFFF;
  --panel-2: #F6F8F9;
  --ink: #14212B;
  --ink-2: #4A5A66;
  --ink-3: #7A8994;
  --rule: #D8DFE3;
  --rule-strong: #B9C4CA;
  --chill: #1C7C8C;
  --chill-soft: #DCEFF2;
  --warm: #C8742F;
  --warm-soft: #F7E8DA;
  --ok: #2F7D4F;
  --ok-soft: #DDEFE3;
  --fault: #B4232C;
  --fault-soft: #F8E0E1;
  --idle: #A9B5BC;
  --nav: #14212B;
  --nav-ink: #C9D4DA;
  --nav-active: #3FB3C4;
  --focus: #3FB3C4;
  --shadow: 0 1px 2px rgba(20, 33, 43, .06), 0 2px 8px rgba(20, 33, 43, .05);

  --f-cond: 'Plex Cond', 'Arial Narrow', sans-serif;
  --f-sans: 'Plex Sans', system-ui, sans-serif;
  --f-mono: 'Plex Mono', ui-monospace, Consolas, monospace;
  --r: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F181F; --panel: #16222B; --panel-2: #1B2933; --ink: #E3EAEE; --ink-2: #A9B7C0;
    --ink-3: #7D8D97; --rule: #263642; --rule-strong: #34495A; --chill: #4FB8C9; --chill-soft: #17343B;
    --warm: #E39456; --warm-soft: #3A2A1D; --ok: #5CB880; --ok-soft: #173326; --fault: #EF6B72;
    --fault-soft: #3D1D20; --idle: #4B5C68; --nav: #0A1116; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --paper: #0F181F; --panel: #16222B; --panel-2: #1B2933; --ink: #E3EAEE; --ink-2: #A9B7C0;
  --ink-3: #7D8D97; --rule: #263642; --rule-strong: #34495A; --chill: #4FB8C9; --chill-soft: #17343B;
  --warm: #E39456; --warm-soft: #3A2A1D; --ok: #5CB880; --ok-soft: #173326; --fault: #EF6B72;
  --fault-soft: #3D1D20; --idle: #4B5C68; --nav: #0A1116; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
body { background: var(--paper); color: var(--ink); font: 400 14px/1.5 var(--f-sans); -webkit-font-smoothing: antialiased; }
a { color: var(--chill); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mono, .num { font-family: var(--f-mono); font-feature-settings: 'zero'; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* --- shell ------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.nav { background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; padding: 18px 0; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 22px; color: #fff; font: 700 17px/1 var(--f-cond); letter-spacing: .02em; }
.brand svg { flex: none; }
.brand small { display: block; font: 500 11px/1.4 var(--f-cond); color: var(--nav-ink); letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--nav-ink); text-decoration: none; padding: 8px 20px; font: 500 14px/1.3 var(--f-cond); letter-spacing: .03em; border-left: 3px solid transparent; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.nav a.active { color: #fff; border-left-color: var(--nav-active); background: rgba(63, 179, 196, .08); }
.nav .group { margin: 16px 20px 6px; font: 600 10.5px/1 var(--f-cond); letter-spacing: .12em; text-transform: uppercase; color: #6E808C; }
.nav .spacer { flex: 1; }
.nav .me { padding: 12px 20px 0; border-top: 1px solid rgba(255, 255, 255, .08); margin-top: 12px; font-size: 12.5px; }
.nav .me b { color: #fff; font-weight: 500; }
.nav .me .role { font: 600 10.5px var(--f-cond); letter-spacing: .1em; text-transform: uppercase; color: var(--nav-active); }
.nav .me button { background: none; border: 0; color: var(--nav-ink); padding: 0; cursor: pointer; text-decoration: underline; font-size: 12px; margin-right: 12px; }
.btn.menu-btn { display: none; }

main { padding: 26px 32px 60px; min-width: 0; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
h1 { font: 700 26px/1.1 var(--f-cond); letter-spacing: .01em; margin: 0; }
h2 { font: 600 13px/1.2 var(--f-cond); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 10px; }
.crumb { font: 500 12px var(--f-cond); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.crumb a { color: inherit; text-decoration: none; }
.crumb a:hover { color: var(--chill); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- panels & grids ---------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow); }
.panel > .ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.panel > .ph h2 { margin: 0; }
.panel > .pb { padding: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.stack > * + * { margin-top: 16px; }

/* --- devices: tile list + detail pane ------------------------------------ */
.dev-split { display: grid; grid-template-columns: minmax(210px, 20%) minmax(0, 1fr); gap: 16px; align-items: start; }
.dev-list { position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dl-head { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--rule); }
.dl-head input { flex: 1; width: 100%; }
.dl-cards { display: flex; flex-direction: column; gap: 6px; padding: 8px; overflow: auto; }
.dev-card { display: block; padding: 9px 10px; border: 1px solid var(--rule); border-left: 3px solid var(--rule); border-radius: var(--r); background: var(--panel); color: var(--ink); text-decoration: none; }
.dev-card:hover { background: var(--panel-2); border-color: var(--rule-strong); }
.dev-card.on { background: var(--chill-soft); border-color: var(--chill); }
.dev-card.off .dc-name b { color: var(--ink-3); }
.dc-name { display: flex; align-items: center; gap: 7px; }
.dc-name .dot { flex: none; }
.dc-name b { font-weight: 500; font-size: 13.5px; line-height: 1.3; overflow-wrap: anywhere; }
.dc-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.dc-meta.mono { color: var(--ink-3); }
.dev-detail { min-width: 0; }
.dev-head h1 { font-size: 22px; }

/* --- tags: tree | folder | point browser -------------------------------- */
.tag-split { display: grid; grid-template-columns: minmax(220px, 22%) minmax(0, 1fr) minmax(260px, 24%); gap: 16px; align-items: start; }
.tag-split.ro { grid-template-columns: minmax(220px, 24%) minmax(0, 1fr); }
.tag-pane { position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 32px); min-width: 0; }
.tp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.tp-head h2 { margin: 0; }
.tp-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.tp-tools input[type=search], .tp-tools select { flex: 1 1 140px; width: 100%; }
.tp-body { overflow: auto; padding: 6px; flex: 1; min-height: 120px; }
.tp-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--rule); }
.ki { display: inline-flex; color: var(--ink-3); vertical-align: -2px; flex: none; }
.ki.k-site, .ki.k-building { color: var(--chill); }
.ki.k-equipment { color: var(--warm); }
.tn { display: flex; align-items: center; gap: 5px; padding: 4px 8px 4px calc(4px + var(--d, 0) * 16px); border-radius: 4px; cursor: pointer; border: 1px solid transparent; user-select: none; }
.tn:hover { background: var(--panel-2); }
.tn.on { background: var(--chill-soft); border-color: var(--chill); }
.tn .tw { width: 16px; height: 18px; border: 0; background: none; padding: 0; color: var(--ink-3); cursor: pointer; font-size: 11px; flex: none; }
.tn .tw:disabled { cursor: default; }
.tn .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.ct { font: 500 11px var(--f-mono); color: var(--ink-3); }
.drop { outline: 2px dashed var(--chill) !important; outline-offset: -2px; background: var(--chill-soft) !important; }
.dragging .tag-drop { outline: 2px dashed var(--rule-strong); outline-offset: -2px; }
.tag-h1 { display: flex; align-items: center; gap: 8px; }
.tag-h1 .ki svg { width: 20px; height: 20px; }
.tag-path { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin: -6px 0 12px; }
.tag-path .mono { background: var(--panel-2); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 6px; user-select: all; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--rule); border-radius: 999px; background: var(--panel); color: var(--ink); text-decoration: none; font-size: 13px; }
.chip:hover { border-color: var(--chill); }
.tag-name { font-weight: 500; }
.pt { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 4px; border: 1px solid transparent; cursor: grab; }
.pt:hover { background: var(--panel-2); }
.pt.sel { background: var(--chill-soft); border-color: var(--chill); }
.pt.mapped { cursor: default; opacity: .7; }
.pt input { margin-top: 3px; }
.pt-main { display: flex; flex-direction: column; min-width: 0; }
.pt-main b { font-weight: 500; font-size: 13px; overflow-wrap: anywhere; }
.pt-path { color: var(--chill); overflow-wrap: anywhere; }

/* --- signature: the slot tape ------------------------------------------- */
.tape { padding: 16px 18px 14px; }
.tape-top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.tape-top .next { font: 500 12px var(--f-cond); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.tape-top .count { font: 500 30px/1 var(--f-mono); letter-spacing: -.01em; color: var(--ink); margin-left: 8px; }
.tape-top .count.live { color: var(--chill); }
.tape-strip { display: flex; gap: 3px; align-items: flex-end; height: 54px; overflow: hidden; }
.tape-strip .cell { flex: 1 1 0; min-width: 6px; max-width: 22px; border-radius: 2px 2px 0 0; background: var(--ok); position: relative; cursor: default; }
.tape-strip .cell.partial { background: var(--warm); }
.tape-strip .cell.fail { background: var(--fault); }
.tape-strip .cell.next { background: repeating-linear-gradient(135deg, var(--rule-strong) 0 3px, transparent 3px 6px); border: 1px dashed var(--rule-strong); }
.tape-strip .cell:hover { filter: brightness(1.15); }
.tape-axis { display: flex; justify-content: space-between; margin-top: 6px; font: 400 11px var(--f-mono); color: var(--ink-3); border-top: 1px solid var(--rule); padding-top: 5px; }
.tape-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.tape-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* --- figures ------------------------------------------------------------ */
.figs { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rule); }
.fig { padding: 12px 18px; border-right: 1px solid var(--rule); }
.fig:last-child { border-right: 0; }
.fig .k { font: 600 11px var(--f-cond); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.fig .v { font: 500 20px/1.3 var(--f-mono); }
.fig .v small { font-size: 12px; color: var(--ink-3); margin-left: 3px; }
.fig .v .sub { display: block; margin-left: 0; font-size: 11.5px; line-height: 1.4; }

/* --- pipeline (the real order jobs run in after each poll) ---------------- */
.pipe { display: flex; align-items: stretch; gap: 0; overflow-x: auto; }
.stage { flex: 1 1 0; min-width: 150px; padding: 12px 14px; border-right: 1px solid var(--rule); position: relative; }
.stage:last-child { border-right: 0; }
.stage::after { content: ''; position: absolute; right: -6px; top: 50%; width: 10px; height: 10px; background: var(--panel); border-top: 1px solid var(--rule); border-right: 1px solid var(--rule); transform: translateY(-50%) rotate(45deg); z-index: 1; }
.stage:last-child::after { display: none; }
.stage .t { font: 600 13px var(--f-cond); letter-spacing: .03em; display: flex; align-items: center; gap: 6px; }
.stage .s { font-size: 12px; color: var(--ink-2); margin-top: 4px; min-height: 36px; overflow-wrap: anywhere; }
.stage .w { font: 400 11px var(--f-mono); color: var(--ink-3); margin-top: 6px; }
.stage.off { opacity: .55; }
.stage button { margin-top: 8px; }

/* --- status dots & pills ------------------------------------------------- */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--idle); flex: none; }
.dot.ok { background: var(--ok); }
.dot.fail { background: var(--fault); }
.dot.warn { background: var(--warm); }
.dot.run { background: var(--chill); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.pill { display: inline-block; font: 600 10.5px/1 var(--f-cond); letter-spacing: .08em; text-transform: uppercase; padding: 4px 7px; border-radius: 3px; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--rule); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.fail { background: var(--fault-soft); color: var(--fault); border-color: transparent; }
.pill.warn { background: var(--warm-soft); color: var(--warm); border-color: transparent; }
.pill.chill { background: var(--chill-soft); color: var(--chill); border-color: transparent; }

/* --- tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font: 600 11px var(--f-cond); letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--rule-strong); background: var(--panel); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel-2); }
tr.off td { color: var(--ink-3); }
td.wrap { overflow-wrap: anywhere; }
th.num { text-align: right; }
.scroll { max-height: 64vh; overflow: auto; }
.supply { color: var(--chill); }
.return { color: var(--warm); }
.err-text { color: var(--fault); }

/* --- forms & buttons ------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 5px; border: 1px solid var(--rule-strong); background: var(--panel); color: var(--ink); cursor: pointer; font: 500 13px/1.2 var(--f-sans); text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--fault); border-color: var(--fault); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.link { border: 0; background: none; padding: 0; color: var(--chill); }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=datetime-local], input[type=time], select, textarea {
  border: 1px solid var(--rule-strong); border-radius: 5px; padding: 7px 10px; background: var(--panel); min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--chill); outline: none; box-shadow: 0 0 0 3px var(--chill-soft); }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font: 600 11px var(--f-cond); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 5px; }
label.f input, label.f select { width: 100%; }
label.f .hint, label.f > span.hint { display: block; font: 400 12px/1.4 var(--f-sans); letter-spacing: 0; text-transform: none; color: var(--ink-3); margin: 4px 0 0; }
.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.toolbar input[type=search] { flex: 1 1 220px; }
.form-err { color: var(--fault); font-size: 13px; min-height: 1em; }

/* --- login ------------------------------------------------------------------ */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background:
  linear-gradient(90deg, var(--chill) 0 50%, var(--warm) 50% 100%) top / 100% 4px no-repeat, var(--paper); }
.login .card { width: 100%; max-width: 360px; padding: 28px; }
.login .brand { color: var(--ink); padding: 0 0 22px; }
.login .brand small { color: var(--ink-3); }
.login h1 { font-size: 22px; margin-bottom: 4px; }
.login p { color: var(--ink-2); margin: 0 0 20px; }

/* --- dialog ------------------------------------------------------------------ */
dialog { border: 1px solid var(--rule); border-radius: 8px; padding: 0; background: var(--panel); color: var(--ink); width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(15, 24, 31, .45); }
dialog .dh { padding: 16px 20px; border-bottom: 1px solid var(--rule); font: 700 18px var(--f-cond); }
dialog .db { padding: 18px 20px 6px; }
dialog .df { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* --- toasts ------------------------------------------------------------------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 6px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 420px; border-left: 4px solid var(--ok); }
.toast.err { border-left-color: var(--fault); }

/* --- logs ---------------------------------------------------------------------- */
.logs { font: 12px/1.55 var(--f-mono); background: #0E161C; color: #C5D1D8; padding: 12px 14px; border-radius: var(--r); max-height: 70vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.logs .warn { color: #E9B26F; }
.logs .error { color: #F2868C; }
.logs .debug { color: #6F8590; }

.chart-box { position: relative; height: 340px; }
.empty { padding: 34px 16px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-family: var(--f-mono); overflow-wrap: anywhere; }
.progress { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--chill); transition: width .3s; }
.banner { padding: 10px 14px; border-radius: var(--r); background: var(--warm-soft); color: var(--ink); border: 1px solid var(--warm); margin-bottom: 16px; font-size: 13px; }
.banner.fault-banner { background: var(--fault-soft); border-color: var(--fault); }
.banner.live-banner { background: var(--chill-soft); border-color: var(--chill); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* --- settings forms ------------------------------------------------------------- */
.set-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.set-preview { background: var(--panel-2); border: 1px solid var(--rule); border-radius: var(--r); padding: 9px 12px; font-size: 13px; margin: 2px 0 6px; }
.set-h { font: 600 13px var(--f-cond); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); margin: 18px 0 10px; }
.set-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); }
.set-foot .form-err { flex: 1; }
.panel > .ph .actions { gap: 6px; }

/* --- help ----------------------------------------------------------------------- */
.btn.help-btn { color: var(--ink-2); }
.help { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.help-toc { position: sticky; top: 16px; padding: 8px 0; max-height: calc(100vh - 32px); overflow: auto; }
.help-toc a { display: block; padding: 6px 14px; color: var(--ink-2); text-decoration: none; font-size: 13px; border-left: 3px solid transparent; }
.help-toc a:hover { color: var(--ink); background: var(--panel-2); }
.help-toc a.on { color: var(--ink); border-left-color: var(--chill); }
.help-toc a.dim { opacity: .4; }
.help-toc small { font: 600 10px var(--f-cond); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.help-body { min-width: 0; max-width: 860px; }
.help-body > * + * { margin-top: 16px; }
.help-sec { scroll-margin-top: 16px; }
.help-sec.flash { border-color: var(--chill); }
.help-sec .pb { line-height: 1.6; }
.help-sec .pb > :first-child { margin-top: 0; }
.help-sec .pb > :last-child { margin-bottom: 0; }
.help-sec h3 { font: 600 15px/1.3 var(--f-cond); letter-spacing: .02em; margin: 18px 0 6px; }
.help-sec ul, .help-sec ol { padding-left: 20px; }
.help-sec li + li { margin-top: 4px; }
.help-table { margin: 8px 0 12px; font-size: 13px; }
.help-table th { position: static; }
.help-table td { vertical-align: top; }
.help-table td:first-child { white-space: nowrap; }
.help-table td.mono { white-space: normal; overflow-wrap: anywhere; font-size: 12px; }
.help-kv { margin: 8px 0 12px; }
.help-kv dd { font-family: var(--f-sans); }
.help-note { background: var(--warm-soft); border-left: 3px solid var(--warm); padding: 9px 12px; border-radius: 0 var(--r) var(--r) 0; margin: 12px 0; font-size: 13px; }
.help-pre { font: 12px/1.55 var(--f-mono); background: #0E161C; color: #C5D1D8; padding: 12px 14px; border-radius: var(--r); overflow-x: auto; white-space: pre; margin: 8px 0 12px; }

@media (max-width: 1100px) { .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 1200px) {
  .tag-split { grid-template-columns: minmax(220px, 32%) minmax(0, 1fr); }
  .tag-src { grid-column: 1 / -1; position: static; max-height: 60vh; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .nav.open { transform: none; }
  .btn.menu-btn { display: inline-flex; position: fixed; top: 12px; left: 12px; z-index: 40; }
  main { padding: 60px 16px 40px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .figs { grid-template-columns: 1fr 1fr; }
  .fig:nth-child(2) { border-right: 0; }
  .fig:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
  .pipe { flex-direction: column; }
  .stage { border-right: 0; border-bottom: 1px solid var(--rule); }
  .stage:last-child { border-bottom: 0; }
  .stage::after { display: none; }
  .stage .s { min-height: 0; }
  .help { grid-template-columns: 1fr; }
  .set-grid { grid-template-columns: 1fr; }
  .help-toc { position: static; max-height: none; }
  .help-sec { scroll-margin-top: 60px; }
  .help-table td:first-child { white-space: normal; }
  .dev-split { grid-template-columns: 1fr; }
  .dev-list { position: static; max-height: none; }
  .dl-cards { flex-direction: row; overflow-x: auto; }
  .dev-card { flex: 0 0 200px; }
  .tag-split, .tag-split.ro { grid-template-columns: 1fr; }
  .tag-pane { position: static; max-height: 50vh; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
