:root { --hdr:57px;   /* header height, kept current by worker.js; everything sticky below the header offsets by it */
  --bg:#111214; --panel:#1a1b1f; --line:#2a2c33; --fg:#e6e6e6; --muted:#8b8f9a; --accent:#7c9cff; --err:#ff6b6b; --ok:#5fd18a; }
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font:14px/1.45 -apple-system, system-ui, sans-serif; }
html, body { max-width:100%; overflow-x:clip; }   /* nothing may widen the page: on a phone that breaks scrolling and pinch zoom on every screen */
header { display:flex; align-items:center; gap:18px; padding:10px 20px; border-bottom:1px solid var(--line); min-height:56px; flex-wrap:wrap; row-gap:6px; position:sticky; top:0; z-index:30; background:var(--bg); }   /* pinned on desktop */
header nav { display:flex; align-items:center; min-width:0; }
.pill { display:inline-flex; align-items:center; gap:8px; height:30px; padding:0 10px 0 12px; border:1px solid var(--line); border-radius:15px; font-size:12px; color:var(--muted); white-space:nowrap; }
.pill .dot { width:8px; height:8px; border-radius:50%; background:var(--muted); }
.pill.ok .dot { background:var(--ok); } .pill.warn .dot { background:#ffd166; } .pill.err .dot { background:var(--err); }
.pill b { color:var(--fg); font-weight:500; }
.pill .dot.ok { background:var(--ok); } .pill .dot.warn { background:#ffd166; } .pill .dot.err { background:var(--err); }
#menuBtn, #navBackdrop, .pill.leds, .mobile-only, #toolsBtn { display:none; }
.tools { display:contents; }
#banner.info { background:#1f2a3a; color:#cfe0ff; border-color:#2c3f5c; }
header h1 { font-size:15px; margin:0; font-weight:600; }
header nav a { color:var(--muted); text-decoration:none; margin-right:14px; white-space:nowrap; }
header nav a.active, header nav a:hover { color:var(--fg); }
header .spacer { flex:1; }
#banner { display:none; background:#3a1f22; color:#ffd2d2; padding:10px 20px; border-bottom:1px solid #5a2a2f; }
#banner button { margin-left:12px; }
main { padding:20px; max-width:1500px; margin:0 auto; min-width:0; }
main > *, .panel, .panel > * { min-width:0; }   /* grid/flex children never grow past their track because of long unbroken text */
img, video, canvas { max-width:100%; }
.panel { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:16px; }
label { display:block; color:var(--muted); font-size:12px; margin:12px 0 4px; }
label span.v { float:right; color:var(--fg); font-variant-numeric:tabular-nums; }
textarea, input[type=number], input[type=text], input[type=password], select { width:100%; background:#0e0f11; color:var(--fg); border:1px solid var(--line); border-radius:6px; padding:8px; font:inherit; }
textarea { min-height:90px; resize:vertical; }
input[type=range] { width:100%; accent-color:var(--accent); }
details summary { cursor:pointer; color:var(--muted); font-size:12px; margin-top:12px; }
.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.row label { margin:0; }
button { background:#26272d; color:var(--fg); border:1px solid var(--line); border-radius:6px; padding:0 12px; height:34px; line-height:32px; font:inherit; font-size:13px; cursor:pointer; white-space:nowrap; display:inline-flex; align-items:center; gap:6px; }
button:hover:not(:disabled) { border-color:var(--accent); }
button:disabled { opacity:.45; cursor:default; }
button.primary { background:var(--accent); color:#0b0d14; border-color:transparent; font-weight:600; width:100%; margin-top:16px; height:42px; justify-content:center; font-size:14px; }
button.danger { border-color:var(--err); color:var(--err); }
button.small { height:28px; line-height:26px; padding:0 10px; font-size:12px; }
.hint { color:var(--muted); font-size:12px; margin-top:6px; min-height:16px; }
.tag { display:inline-block; font-size:11px; padding:1px 6px; border-radius:4px; background:#26272d; color:var(--muted); margin-left:6px; }
.err { color:var(--err); }

/* tile selection (select.js): round checkbox top-right, visible on hover and while a selection exists */
.ph .ck { position:absolute; top:6px; right:6px; width:18px; height:18px; border-radius:50%; border:2px solid rgba(255,255,255,.9); background:rgba(0,0,0,.35); box-shadow:0 0 3px rgba(0,0,0,.7); cursor:pointer; display:none; z-index:2; }
.ph:hover .ck, body.selecting .ph .ck { display:block; }
.ph.sel { border-color:var(--accent); }
.ph.sel .ck { background:var(--accent); border-color:var(--accent); }
.ph.sel .ck::after { content:"✓"; color:#fff; font-size:12px; line-height:14px; display:block; text-align:center; }
.bulk { display:none; gap:8px; align-items:center; } body.selecting .bulk { display:flex; }

/* ---- small screens. The nav becomes its own row under the brand and scrolls sideways within itself (the page never does);
   controls grow to finger size; wide tables scroll inside their box; form fields are 16px so iOS does not zoom into them. */
@media (max-width: 760px) {
  header { padding:8px 12px; gap:10px; position:static; }   /* phones: the header scrolls away, the screen is small */
  :root { --hdr:0px; }
  header h1, header .hint, header .pill:not(.leds), #workerCtl, #workerState { display:none !important; }   /* brand name, counters and text pills go; the LED pill stays */
  #menuBtn { display:inline-flex; width:36px; justify-content:center; padding:0; font-size:18px; position:relative; z-index:41; }
  header nav { position:fixed; top:0; left:0; bottom:0; width:min(78vw, 300px); background:var(--panel); border-right:1px solid var(--line); flex-direction:column; align-items:stretch; gap:2px; padding:60px 12px 12px; margin:0; overflow:auto; transform:translateX(-100%); transition:transform .2s ease; z-index:40; }
  body.nav-open header nav { transform:none; box-shadow:0 0 40px rgba(0,0,0,.5); }
  header nav a { margin:0; padding:12px 14px; font-size:16px; border-radius:8px; }
  header nav a.active { background:#26272d; color:var(--fg); }
  #navBackdrop { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:39; } body.nav-open #navBackdrop { display:block; }
  body.nav-open { overflow:hidden; }
  .pill.leds { display:inline-flex; gap:7px; padding:0 11px; height:28px; } .pill.leds .dot { width:9px; height:9px; }
  .mobile-only { display:revert; }
  /* toolbars: the primary control and a Filters toggle; everything else is folded away until asked for */
  #toolsBtn { display:inline-flex; flex:none; } #toolsBtn::after { content:"▾"; font-size:10px; margin-left:4px; opacity:.7; } .toolbar.tools-open #toolsBtn::after { content:"▴"; }
  .tools { display:none; flex:1 1 100%; flex-wrap:wrap; gap:8px; align-items:center; padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:var(--panel); }
  .toolbar.tools-open .tools { display:flex; }
  main { padding:12px; }
  table { display:block; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  input[type=text], input[type=password], input[type=number], select, textarea { font-size:16px; }
  select { max-width:100%; }
  dialog { max-width:calc(100vw - 24px); }
}
@media (pointer: coarse) {
  button { min-height:40px; }
  button.small { min-height:36px; height:36px; line-height:34px; }
  header nav a { min-height:40px; display:inline-flex; align-items:center; }
  .ph .ck { display:block; width:22px; height:22px; }   /* no hover on a touchscreen: the selection circle is always there */
  .ph .ck::after { font-size:14px; line-height:18px; }
}
