/* MT+ browser views. Every colour is a token; dark follows Windows unless the view picks one.
   The dark set is the tk window's palette (gui/main_window._STATE_COLORS), so the two views
   read the same; the light set keeps each state's meaning at the same strength. */
:root {
  /* Light is a soft grey, not paper white (Tyler, 2026-11-24: "less eyeball-searing"): no surface
     brighter than #eceef1, the page a step darker than the cards, and every text colour still
     4.5:1 or better on the surface it sits on (WCAG AA); only the "unknown" grey is fainter, as
     it is meant to be. */
  --bg: #dfe2e6; --panel: #eceef1; --panel-2: #e1e4e8; --ink: #1c222b; --muted: #4f5764;
  --line: #c3c8cf; --accent: #1f63d6; --focus: #1f63d6;
  --ok: #2a6f2e; --warn: #8f5100;
  --held: #d46f00; --hint-bg: #eebd86; --hint-fg: #2b1d0e;
  --caution-bg: #f0d9a8; --caution-fg: #4f3100;
  --scan: #d3d9e2;
  --cool-bg: #c8d9ea; --cool-fg: #123a5e;
  --heat-bg: #ebcdc9; --heat-fg: #5e1a14;
  --stop-bg: #d8dbdf; --stop-fg: #4f5662;
  --unk-bg: #e3e5e8; --unk-fg: #7d848e;
  --pass-bg: #c2dfc7; --pass-fg: #14451f;
  --fail-bg: #ebc9c9; --fail-fg: #5e1414;
  --cold: #1559a8; --hot: #b42323; --noflow: #855c00;
  --grid: #cfd3d9; --mark: #7f8897;
  --ffwd: #1c222b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1e1e1e; --panel: #252526; --panel-2: #2a2a2a; --ink: #e8e8e8; --muted: #9a9a9a;
    --line: #3a3a3a; --accent: #58a6ff; --focus: #58a6ff;
    --ok: #5cc66a; --warn: #e0a440;
    --held: #ff9d3c; --hint-bg: #f3c493; --hint-fg: #2b1d0e;
    --caution-bg: #4d3d1c; --caution-fg: #f6dfae;
    --scan: #33373d;
    --cool-bg: #2f4a63; --cool-fg: #dce8f2;
    --heat-bg: #5e3a38; --heat-fg: #f2dede;
    --stop-bg: #2a2a2a; --stop-fg: #9a9a9a;
    --unk-bg: #232323; --unk-fg: #6a6a6a;
    --pass-bg: #2f5e3a; --pass-fg: #dcf2de;
    --fail-bg: #5e3a3a; --fail-fg: #f2dcdc;
    --cold: #61afef; --hot: #e06c75; --noflow: #e5b567;
    --grid: #34383e; --mark: #7d8592; --ffwd: #fff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1e1e1e; --panel: #252526; --panel-2: #2a2a2a; --ink: #e8e8e8; --muted: #9a9a9a;
  --line: #3a3a3a; --accent: #58a6ff; --focus: #58a6ff;
  --ok: #5cc66a; --warn: #e0a440;
  --held: #ff9d3c; --hint-bg: #f3c493; --hint-fg: #2b1d0e;
  --caution-bg: #4d3d1c; --caution-fg: #f6dfae;
  --scan: #33373d;
  --cool-bg: #2f4a63; --cool-fg: #dce8f2;
  --heat-bg: #5e3a38; --heat-fg: #f2dede;
  --stop-bg: #2a2a2a; --stop-fg: #9a9a9a;
  --unk-bg: #232323; --unk-fg: #6a6a6a;
  --pass-bg: #2f5e3a; --pass-fg: #dcf2de;
  --fail-bg: #5e3a3a; --fail-fg: #f2dcdc;
  --cold: #61afef; --hot: #e06c75; --noflow: #e5b567;
  --grid: #34383e; --mark: #7d8592; --ffwd: #fff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.35 "Segoe UI", system-ui, sans-serif;
  display: flex; flex-direction: column;
}
#app { flex: 1; display: flex; flex-direction: column; min-height: 0; }
button, input, select { font: inherit; color: inherit; }
button {
  padding: 5px 12px; border-radius: 4px; cursor: pointer; position: relative; overflow: hidden;
  border: 1px solid var(--line); background: var(--panel-2); white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
button .fill {
  position: absolute; inset: 0 auto 0 0; background: var(--accent); opacity: .28;
  transition: width .2s;
}
button .lbl { position: relative; }

/* ------------------------------------------------------------------ the pinned top */
.top {
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 14px;
  display: flex; flex-direction: column; gap: 8px; flex: none;
}
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row .spacer { flex: 1; }
.caption { color: var(--muted); }
.chip {
  padding: 5px 14px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer;
}
.chip.sel { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip:disabled { cursor: default; }
.readout { display: inline-flex; gap: 4px; margin-left: 6px; }
.readout b { font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.conn { color: var(--warn); font-size: 12px; }
.conn[data-state="live"] { color: var(--ok); }
.iconbtn { padding: 5px 9px; }

/* ------------------------------------------------------------------ the site */
.site { flex: 1; overflow: auto; padding: 12px 14px 24px; position: relative; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px 10px; margin-bottom: 12px; width: max-content; min-width: 100%;
  position: relative;
}
.card > h2 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.outdoor { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.outdoor .card { min-width: 0; margin: 0; }
.points { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-bottom: 6px; font-size: 12px; }
.points .grp { display: flex; gap: 2px 10px; flex-wrap: wrap; }
.points .pt { display: flex; flex-direction: column; padding: 0 3px; border-radius: 3px; }
.points .pt.scan { background: var(--scan); }       /* the points being read: the scan line */
.points .pt b { color: var(--muted); font-weight: 600; }

table.units { border-collapse: separate; border-spacing: 0; }
table.units th {
  color: var(--muted); font-weight: 600; text-align: left; padding: 2px 8px 4px 6px;
  white-space: nowrap; font-size: 13px;
}
table.units td { padding: 1px 8px 1px 6px; white-space: nowrap; height: 38px; }
table.units tbody tr:hover td { background: var(--panel-2); }
table.units tbody tr:hover td.scan { background: var(--scan); }
table.units td.scan { background: var(--scan); }
table.units td.graph, table.units th.graph { padding: 1px 6px; }
table.units td.ac { padding: 1px; }
.st-cold { color: var(--cold); font-weight: 600; }
.st-hot { color: var(--hot); font-weight: 600; }
.st-noflow { color: var(--noflow); }
/* an indoor unit's row, but for its Actual Port boxes: click for its every point. Its Mode goes
   amber with a ⚠ in Prohibit or on an error */
table.units tbody tr[data-row] td:not(.ac) { cursor: pointer; }
table.units td.st-prohibit, table.units td.st-error,
table.units tbody tr:hover td.st-prohibit, table.units tbody tr:hover td.st-error {
  background: var(--caution-bg); color: var(--caution-fg); font-weight: 600;
}
.st-prohibit::after, .st-error::after { content: " \26A0"; }
table.units tr.detail td, table.units tbody tr.detail:hover td {
  height: auto; white-space: normal; padding: 6px 10px 8px; background: var(--panel-2);
  border-left: 3px solid var(--accent); border-radius: 0 0 4px 4px; cursor: pointer;
}
.detail .caution {
  background: var(--caution-bg); color: var(--caution-fg); border-radius: 4px;
  padding: 6px 10px; margin: 0 0 6px; width: fit-content; max-width: 100%;
}
.detail .caution .gap { height: .9em; }
.detail .pts { display: flex; flex-wrap: wrap; gap: 2px 16px; }
.detail .pts b { color: var(--muted); font-weight: 600; margin-right: 5px; }
th .help {
  margin-left: 4px; padding: 0 5px; font-size: 11px; line-height: 16px; border-radius: 8px;
}

.box {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 28px; padding: 0 4px; border-radius: 3px;
  border: 1px solid transparent; background: var(--unk-bg); color: var(--unk-fg);
  user-select: none;
}
.box.click { cursor: pointer; border-color: var(--line); }
.box.click:hover { border-color: var(--accent); }
.box.off { cursor: default; opacity: .6; }
.s-cooling { background: var(--cool-bg); color: var(--cool-fg); }
.s-heating { background: var(--heat-bg); color: var(--heat-fg); }
.s-stopped, .s-recovery { background: var(--stop-bg); color: var(--stop-fg); }
.s-unknown { background: var(--unk-bg); color: var(--unk-fg); }
.s-pass { background: var(--pass-bg); color: var(--pass-fg); font-weight: 600; }
.s-fail { background: var(--fail-bg); color: var(--fail-fg); }
.s-normal { background: transparent; color: var(--ink); }
.box.held { box-shadow: 0 0 0 2px var(--held); }
.box.pair-ringed { box-shadow: none; }

table.ports { border-collapse: separate; border-spacing: 2px 1px; margin-top: 8px; }
table.ports th { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 2px; }
table.ports td.vname {
  font-size: 12px; color: var(--muted); text-align: right; padding: 0 6px 0 2px;
}
table.ports .box.valve { min-width: 52px; height: 22px; font-size: 12px; }
table.ports .box.port { min-width: 62px; height: 30px; font-weight: 600; margin-top: 3px; }
table.ports tr.scan td { background: var(--scan); }

/* The ring round a held port: each cell under it draws its own edges of it (pv.js rings), so it
   sits on the boxes wherever the table moves them. It stands 1px outside its cells, which in the
   ports table meets the next cell's across their 2px spacing. */
td.rg { position: relative; }
td.rg::after {
  content: ""; position: absolute; inset: -1px; pointer-events: none; z-index: 1;
  border: 0 solid var(--held);
}
td.rg-t::after { border-top-width: 2px; }
td.rg-b::after { border-bottom-width: 2px; }
td.rg-l::after { border-left-width: 2px; }
td.rg-r::after { border-right-width: 2px; }
td.rg-t.rg-l::after { border-top-left-radius: 4px; }
td.rg-t.rg-r::after { border-top-right-radius: 4px; }
td.rg-b.rg-l::after { border-bottom-left-radius: 4px; }
td.rg-b.rg-r::after { border-bottom-right-radius: 4px; }

/* the TH2/TH3 graph beside each unit's Actual Port boxes */
svg.spark { display: block; }
svg.spark .frame { fill: none; stroke: var(--grid); }
svg.spark .thresh { stroke: var(--grid); stroke-dasharray: 2 3; }
svg.spark .mark { stroke: var(--mark); stroke-width: 1; }
svg.spark .trace { fill: none; stroke: var(--ink); stroke-width: 1.75; }
svg.spark .trace.cold { stroke: var(--cold); stroke-width: 2.25; }
svg.spark .trace.hot { stroke: var(--hot); stroke-width: 2.25; }
.legend { display: inline-flex; gap: 8px; font-weight: 400; font-size: 12px; }

/* ------------------------------------------------------------------ dialogs and covers */
.scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex;
  align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 20;
}
.scrim.clear { background: transparent; pointer-events: none; }
.scrim.clear .dlg { pointer-events: auto; }
/* a note that opens beside what was clicked (the Mode column's ?), not mid-screen */
.scrim.anchored .dlg { position: fixed; min-width: 0; max-width: min(380px, calc(100vw - 16px)); }
.dlg {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); padding: 16px 18px; min-width: 320px;
  max-width: min(560px, calc(100vw - 32px));
}
.dlg h3 { margin: 0 0 10px; font-size: 15px; }
.dlg p { margin: 0 0 10px; }
.dlg .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dlg .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.dlg .primary .fill { background: #fff; }        /* the accent's own fill would not show on it */
.dlg .line { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.dlg input[type=number] { width: 64px; padding: 3px 4px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 3px; }
.dlg .steps div { padding: 2px 0; }
.dlg .steps .done { color: var(--muted); }
.unitgrid { display: grid; grid-template-columns: repeat(12, auto); gap: 2px; justify-content: start; }
/* the fast-forward (pv.js fade): the walkthrough's ⏩ mark (walk.css .wff), centred */
.ffwd {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 30;
}
.ffwd.on { opacity: .5; pointer-events: auto; }
.ffwd .tri { width: 0; height: 0; border-top: 70px solid transparent; border-bottom: 70px solid transparent;
  border-left: 100px solid var(--ffwd); filter: drop-shadow(0 0 6px rgba(0, 0, 0, .6)); }
.ffwd.on .tri { animation: ffpulse 1.2s ease-in-out infinite; }
.ffwd.on .tri + .tri { animation-delay: .15s; }
@keyframes ffpulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .ffwd.on .tri { animation: none; } }
.empty { color: var(--muted); padding: 24px 16px; }
.note {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px;
  background: var(--hint-bg); color: var(--hint-fg); border-bottom: 1px solid var(--line);
}
.note span { flex: 1; }
.note button { color: var(--ink); }
