/* The design scale (#317). Every colour, font size and corner radius in web/css/ comes from
   these variables: `python tools/check_css.py` (run by `tools/check.py web`) rejects a colour or a font size
   in px outside a :root block. The dark values follow the system setting unless the theme
   picker in the top bar (js/theme.js) sets data-theme="light" or "dark" on <html>. */
:root {
  /* text: xs for small print, sm for hints and tables, md for body text, lg/xl for headings */
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  /* spacing and corners */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --bg: #f6f6f3;
  --panel: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #d9d9d3;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --warn: #9a4b00;
  --error: #b3261e;
  --ok: #2e7d32;
  --hover: rgba(0, 0, 0, .06);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .15);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .15);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .3);
  --backdrop: rgba(0, 0, 0, .35);
  /* the designer's boxes over the tag preview */
  --box: rgba(31, 95, 191, 0.85);
  --box-rect: rgba(204, 102, 0, 0.85);
  --box-sel: #e0218a;
  --on-box: #ffffff;
  /* a tag's screen: white paper and black ink in both themes */
  --paper: #ffffff;
  --paper-edge: #333333;
  --ink: #111111;
  /* the dark toolbar over the selected element in the designer, in both themes */
  --toolbar-bg: #1d1d1b;
  --toolbar-text: #ffffff;
  --toolbar-muted: #aaaaaa;
  --toolbar-hover: #3a3a37;
  --toolbar-on: #3d5f99;
  --toolbar-line: #4a4a46;
  --toolbar-danger: #7a1f1a;
  /* code samples (Layouts card) */
  --code-bg: #1c2330;
  --code-text: #e6edf6;
  /* the chip colour of each AP board in the AP flasher */
  --chip-s3: #7a4fd0;
  --chip-c6: #1d8b5f;
  --chip-c5: #c06a20;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #181817;
    --panel: #222220;
    --text: #ececea;
    --muted: #a3a39d;
    --line: #3a3a37;
    --accent: #6a9be6;
    --accent-text: #0d0d0c;
    --warn: #f0a050;
    --error: #ff7b72;
    --ok: #7bc47f;
    --hover: rgba(255, 255, 255, .08);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, .5);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
    --backdrop: rgba(0, 0, 0, .55);
    --toolbar-bg: #2e2e2b;
    --toolbar-hover: #48483f;
    --code-bg: #12161e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #181817;
  --panel: #222220;
  --text: #ececea;
  --muted: #a3a39d;
  --line: #3a3a37;
  --accent: #6a9be6;
  --accent-text: #0d0d0c;
  --warn: #f0a050;
  --error: #ff7b72;
  --ok: #7bc47f;
  --hover: rgba(255, 255, 255, .08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .5);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
  --backdrop: rgba(0, 0, 0, .55);
  --toolbar-bg: #2e2e2b;
  --toolbar-hover: #48483f;
  --code-bg: #12161e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* The hidden attribute always hides, also on elements whose class sets a display (#301) */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-md)/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
code, pre, textarea { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: var(--fs-sm); }
h1 { font-size: var(--fs-xl); margin: 0; }
h2 { font-size: var(--fs-lg); margin: 0 0 var(--space-2); }
button, .button, select, input:not([type]), input[type="number"], input[type="text"], input[type="password"] {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
}
button, .button { cursor: pointer; }
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
label { display: inline-flex; gap: 6px; align-items: center; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

.top {
  display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.tabs { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.tabs a { padding: 6px 12px; border-radius: var(--radius-sm); color: inherit; text-decoration: none; }
.tabs a:hover, .tabs button:hover:not([aria-selected="true"]) { background: var(--hover); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.tabs button { border: none; border-radius: var(--radius-sm); background: none; padding: 6px 12px; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.repo { margin-left: auto; color: var(--text); font-weight: 500; text-underline-offset: 3px; }
.repo:hover { color: var(--accent); }
/* the light/dark/auto button (js/theme.js) */
.theme-btn { margin-left: auto; display: inline-flex; gap: var(--space-1); align-items: center; border-color: transparent; background: none; color: var(--text); padding: var(--space-1) var(--space-2); }
.repo + .theme-btn { margin-left: 0; }
.theme-btn:hover:not(:disabled) { background: var(--hover); border-color: transparent; }
.theme-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
@media (max-width: 600px) {
  .theme-btn { padding: 0 var(--space-1); }
  .theme-btn span { display: none; }
}
.top :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tab { padding: var(--space-4); max-width: 1400px; margin: 0 auto; }
.sep { flex: 1; }


.stage canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.overlay { position: absolute; inset: 0; }
.overlay.hide-boxes .box:not(.sel) { border-color: transparent; }
.overlay.hide-boxes .box:not(.sel) .tag { display: none; }
.box {
  position: absolute; border: 1px dashed var(--box); cursor: move;
}
.box.rect { border-color: var(--box-rect); }
.box.sel { border: 2px solid var(--box-sel); z-index: 2; }
.box .tag {
  position: absolute; left: -1px; top: -18px; font-size: var(--fs-xs); line-height: 16px; padding: 0 var(--space-1);
  background: var(--box); color: var(--on-box); border-radius: 3px 3px 0 0; white-space: nowrap; pointer-events: none;
}
.box.rect .tag { background: var(--box-rect); }
.box.sel .tag { background: var(--box-sel); }
.box .grip {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  background: var(--paper); border: 2px solid var(--box-sel); border-radius: 2px; display: none;
}
.box .grip.nw { left: 0; top: 0; cursor: nwse-resize; }
.box .grip.n { left: 50%; top: 0; cursor: ns-resize; }
.box .grip.ne { left: 100%; top: 0; cursor: nesw-resize; }
.box .grip.e { left: 100%; top: 50%; cursor: ew-resize; }
.box .grip.se { left: 100%; top: 100%; cursor: nwse-resize; }
.box .grip.s { left: 50%; top: 100%; cursor: ns-resize; }
.box .grip.sw { left: 0; top: 100%; cursor: nesw-resize; }
.box .grip.w { left: 0; top: 50%; cursor: ew-resize; }
.box:hover:not(.sel) { border-style: solid; }
.box.sel .grip { display: block; }

.box.barcode { border-color: var(--muted); }
.box.barcode .tag { background: var(--muted); }
.guide { position: absolute; pointer-events: none; z-index: 3; }
.guide.x { top: 0; bottom: 0; width: 0; border-left: 1px solid var(--box-sel); }
.guide.y { left: 0; right: 0; height: 0; border-top: 1px solid var(--box-sel); }
.buttons.tight { margin: 0; gap: 6px; }
.wifi-msg.error { color: var(--error); }
.wifi-msg.ok { color: var(--ok); }
.wifi-form { max-width: 480px; }
.wifi-form[hidden] { display: none; }
kbd { font: var(--fs-xs) ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--radius-sm); padding: 0 var(--space-1); background: var(--panel); color: var(--text); }
.box.hover { border-style: solid; border-width: 2px; }
.hint, .muted { color: var(--muted); font-size: var(--fs-sm); }
.steps { margin: 0 0 var(--space-1); padding-left: 20px; }
.steps li { margin-bottom: var(--space-1); }
.warn { color: var(--warn); }

.form { display: grid; gap: var(--space-2); }
.form[hidden] { display: none; }
.form label { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--space-2); }
.form label > input, .form label > select { width: 100%; min-width: 0; }
.form .pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.form .pair label { grid-template-columns: 14px minmax(0, 1fr); }
.form.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.form.row label { display: inline-flex; }
.form .count { font-size: var(--fs-xs); color: var(--muted); text-align: right; }
.form .count.error { color: var(--error); }
textarea { width: 100%; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-2); }
.cmd { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: var(--space-2); border-radius: var(--radius-sm); margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); margin-bottom: var(--space-4); max-width: 860px; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: var(--space-3) 0; }
progress { width: 100%; height: 14px; }
.log { background: var(--bg); border-radius: var(--radius-sm); padding: var(--space-2); min-height: 120px; max-height: 360px; overflow: auto; white-space: pre-wrap; margin: var(--space-2) 0 0; }
.log .err { color: var(--error); }
.log .good { color: var(--ok); }
.backups { width: 100%; border-collapse: collapse; }
.backups td, .backups th { text-align: left; padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--line); }

@media (max-width: 700px) {
  /* The main menu is one row that scrolls sideways, under the name, instead of two rows */
  .top { gap: 4px 10px; padding: 8px 0 0; }
  .top h1 { padding-left: 16px; }
  .repo { padding-right: 16px; }
  .tabs { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; padding: 0 12px 8px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button, .tabs a { flex: none; white-space: nowrap; }
}
@media (max-width: 600px) {
  .top { gap: 10px; }
  .tab { padding: var(--space-3) var(--space-4); }
  .form label { grid-template-columns: 80px minmax(0, 1fr); }
}

/* ---------- overview ---------- */
.hero { max-width: 860px; margin: 8px 0 20px; }
.hero h2 { font-size: var(--fs-xl); margin-bottom: var(--space-2); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.cards .card { margin: 0; max-width: none; }
.card.link { display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.card.link:hover { border-color: var(--accent); }
.card.link p { flex: 1; }
.card .go { color: var(--accent); font-weight: 600; }
.card.wide { max-width: none; }
h3 { font-size: var(--fs-md); margin: 0 0 var(--space-2); }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 6px; }

/* ---------- tag model picker ---------- */
h3.sub { margin-top: var(--space-4); }
.models { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-2); }
.model {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1);
  padding: 10px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--panel);
  text-align: left; min-width: 0;
}
.model img {
  display: block; height: 140px; width: auto; max-width: 100%; object-fit: contain;
  border: 1px solid var(--line); border-radius: 3px;
}
.model .name { font-weight: 600; }
.model[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.model[aria-checked="true"] .name::after { content: " ✓ selected"; color: var(--accent); font-weight: 600; }
.models.locked .model { opacity: 0.6; cursor: not-allowed; }

/* ---------- backups ---------- */
.table-wrap { overflow-x: auto; }
.backups input { width: 100%; min-width: 120px; }
.backups input.bad { border-color: var(--error); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: var(--fs-sm); }

/* API tab: api.html (Scalar, from docs/openapi.yaml) in a frame */
.tab-api { padding-bottom: 0; }
.api-intro { max-width: 960px; margin: 0 auto var(--space-3); line-height: 1.5; }
.api-intro code { background: var(--panel); border-radius: var(--radius-sm); padding: 1px 4px; overflow-wrap: anywhere; }
.api-frame { display: block; width: 100%; height: calc(100vh - 140px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }

/* ---------- dashboard ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 16px; margin: 0 0 var(--space-2); }
.facts div { min-width: 0; }
.facts dt { color: var(--muted); font-size: var(--fs-sm); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.dash-tags { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
.dash-tags th, .dash-tags td { text-align: left; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dash-tags th { color: var(--muted); font-weight: 600; font-size: var(--fs-sm); }
.dash-tags td.state { white-space: normal; }
.state-bad { color: var(--error); }
.state-busy { color: var(--warn); }
.state-ok { color: var(--ok); }
#dash-health.bad { color: var(--error); }
#dash-health.ok { color: var(--ok); }
.dash-alert { margin: 0 0 var(--space-3); padding: 10px 12px; border: 1px solid var(--error); border-left-width: 4px; border-radius: var(--radius); color: var(--error); font-weight: 600; }
#dash-msg.error, #fw-msg.error, #dash-poll-msg.error { color: var(--error); }
#dash-body.stale #dash-tiles, #dash-body.stale #dash-ap, #dash-body.stale #dash-wifi, #dash-body.stale #dash-tags, #dash-body.stale #dash-tagfw { opacity: 0.45; }
#fw-msg.ok, #dash-poll-msg.ok { color: var(--ok); }
/* the dashboard's two views, and its Settings page: a menu of groups, one group at a time */
.views { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: var(--space-4); background: var(--panel); }
.views button { border: 0; border-radius: 0; padding: 6px 16px; }
.views button + button { border-left: 1px solid var(--line); }
.views button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
#dash-overview[hidden], .set-page[hidden], .set-page [hidden] { display: none !important; }
.set-page { display: grid; grid-template-columns: 200px minmax(0, 1fr); padding: 0; min-height: 380px; }
.set-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-right: 1px solid var(--line); }
.set-nav button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: var(--radius-sm); font-weight: 600; }
.set-nav button small { display: block; font-weight: 400; font-size: var(--fs-xs); color: var(--muted); }
.set-nav button[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.set-pane { padding: 18px 22px; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.set-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); max-width: 520px; min-width: 0; flex: 1; align-content: start; }
.set-fields h3 { margin: 0; }
.set-fields h3 + p { margin-top: -10px !important; }
.set-fields p { margin: 0; }
.set-page .field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
.set-page .field > span:first-child { font-weight: 600; }
.set-page .field small, .field-note { color: var(--muted); font-size: var(--fs-xs); }
.field-note { margin: -10px 0 0 !important; }
.set-page .field input:not([type="checkbox"]), .set-page .field select { width: 100%; min-width: 0; }
.set-page .row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; min-width: 0; }
.set-page .row > input:not([type]) { flex: 1; width: auto; }
.set-page .row > select { width: auto; flex: 0 1 auto; min-width: 0; max-width: 100%; }
.set-page #set-poll-s { width: 100px; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-size: var(--fs-xs); text-decoration: underline; }
.savebar { max-width: 520px; display: flex; gap: var(--space-2); align-items: center; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: var(--space-3); min-height: 46px; }
.savebar .hint { margin-right: auto; }
.savebar:has(.set-save[hidden]):has(.hint:empty) { visibility: hidden; }
.set-page .hint.error { color: var(--error); }
.set-page .hint.ok { color: var(--ok); }
.bk-ask { display: grid; gap: 10px; background: var(--bg); border-radius: var(--radius-sm); padding: var(--space-3); }
#bk-log { margin: 6px 0 0; padding-left: 18px; }
#bk-log .bad { color: var(--error); }
#dash-body.stale .set-page .set-pane { opacity: 0.45; }
@media (max-width: 720px) {
  .set-page { grid-template-columns: minmax(0, 1fr); }
  .set-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .set-nav button { flex: 0 0 auto; }
  .set-nav button small { display: none; }
  .set-pane { padding: var(--space-4); }
}
#fw-progress { width: 100%; }
.form.row label[hidden] { display: none; }
.form label.check { display: inline-flex; gap: 6px; align-items: center; }
.form label.check > input { width: auto; }

button.small { padding: 2px 8px; font-size: var(--fs-sm); }
.fw-prog { white-space: nowrap; }
.fw-prog progress { width: 80px; height: 10px; vertical-align: middle; margin: 0 6px 0 2px; }
button.fw-up { padding: 0 6px; font-weight: 700; line-height: 1.4; margin-left: var(--space-1); }
.mac-ask[hidden] { display: none; }
#tag-mac { width: 18em; max-width: 100%; }

/* Dashboard: send info to tags */
.send-text { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.st-preview[hidden] { display: none; }
.tag-table td.screen canvas { display: block; width: 148px; height: auto; border: 1px solid var(--line); image-rendering: pixelated; background: var(--paper); }
.tag-table td.screen canvas.waiting { opacity: 0.45; }
.st-preview canvas { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); image-rendering: pixelated; background: var(--paper); }
@media (max-width: 720px) { .send-text { grid-template-columns: minmax(0, 1fr); } }
.st-bar { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--line); display: grid; gap: 10px; }
.st-bar [hidden], #st-own[hidden], #st-show[hidden] { display: none; }
.dash-tags th.sel, .dash-tags td.sel { width: 1%; padding-right: 6px; }
.st-ph { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.st-ph button { font-family: ui-monospace, Consolas, monospace; }
.st-list td { font-size: var(--fs-xs); vertical-align: top; white-space: normal; }
.st-list td.mono { white-space: nowrap; }
/* The picture dialog of the Send form: its own rules, since the Dashboard on a C6 has no designer.css */
.pic-dlg { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; width: min(680px, calc(100vw - 32px)); background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg); }
.pic-dlg::backdrop { background: var(--backdrop); }
.pic-dlg h3 { font-size: var(--fs-lg); margin: 0 0 var(--space-3); }
.pic-dlg .dlg-x { position: absolute; right: 12px; top: 10px; }
.pic-dlg .dlg-x button { border: 0; background: none; color: var(--muted); }
.pic-dlg .dlg-buttons { display: flex; gap: var(--space-2); align-items: center; margin-top: var(--space-4); }
.pic-dlg .dlg-buttons .sep { flex: 1; }
.st-pic { display: grid; gap: 10px; margin-bottom: 10px; }
.st-pics[hidden] { display: none; }
.st-drop { display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px 12px; text-align: center; cursor: pointer; color: var(--muted); }
.st-drop:hover, .st-drop.over, .st-drop:focus-within { border-color: var(--accent); color: var(--text); }
.st-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.st-pic input[type="range"] { width: 120px; }
.st-pics { display: grid; gap: 10px; }
.st-pics figure { margin: 0; }
.st-pics canvas { width: 100%; cursor: grab; touch-action: none; }
.st-pics canvas.drag { cursor: grabbing; }
.st-pics figcaption { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

/* Dashboard layout: the connection as one line, figures, the tag table first, the rest folded */
#dash-body h2 { font-size: var(--fs-lg); margin: 0; }
#dash-body h3 { font-size: var(--fs-md); margin: 0; }
.dash #dash-conn > h2 { font-size: var(--fs-lg); }
.dash #dash-conn > p { max-width: 62ch; }
#dash-conn.connected { padding: 10px 16px; }
#dash-conn.connected > h2, #dash-conn.connected > p:not(#dash-msg),
#dash-conn.connected #dash-src, #dash-conn.connected label:has(#dash-src),
#dash-conn.connected #dash-url-label, #dash-conn.connected #dash-token-label { display: none; }
#dash-conn.connected #dash-msg:empty { display: none; }
.dash-live { margin: 0 auto 0 0; display: inline-flex; flex-wrap: wrap; gap: 0 6px; align-items: center; font-size: var(--fs-sm); }
.dash-live[hidden] { display: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.bad { background: var(--error); }
.dot.wait { background: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.tile { display: grid; gap: 2px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font: inherit; color: var(--text); }
button.tile { cursor: pointer; }
button.tile:hover { border-color: var(--accent); }
.tile.on { outline: 2px solid var(--accent); outline-offset: -2px; }
.tile .n { font-size: var(--fs-2xl); font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .l { font-size: var(--fs-sm); color: var(--muted); }
.tile.bad { border-color: var(--error); }
.tile.bad .n { color: var(--error); }
.tile.good .n { color: var(--ok); }
.tile.busy .n { color: var(--warn); }

.dash-head { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); align-items: baseline; margin-bottom: 10px; }
.dash-head p { margin: 0; }
.dash-tools { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; margin-bottom: var(--space-2); }
.dash-tools input { width: 14em; max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 999px; padding: var(--space-1) var(--space-3); font-size: var(--fs-sm); min-height: 28px; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip.on .n { color: inherit; }

.tag-table th.num, .tag-table td.num { text-align: right; padding-right: var(--space-4); font-variant-numeric: tabular-nums; }
.tag-table td.signal { white-space: nowrap; }
.tag-table td.signal svg { vertical-align: -4px; margin-right: var(--space-1); }
.tag-table td.signal .bar { fill: currentColor; opacity: .6; }
.tag-table td.signal .lost { fill: var(--error); }
.tag-table td.signal .retry { fill: var(--warn); }
.tag-table .sig-btn { all: unset; cursor: pointer; border-radius: var(--radius-sm); white-space: nowrap; }
.tag-table .sig-btn:hover { text-decoration: underline; }
.tag-table .sig-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tag-table td.sig-detail { background: color-mix(in srgb, var(--muted) 6%, transparent); padding: var(--space-3) var(--space-4); white-space: normal; }
.tag-table td.sig-detail p { margin: 6px 0; font-size: var(--fs-sm); }
.sig-chart { display: block; max-width: 100%; height: auto; }
.sig-chart .grid { stroke: var(--line); }
.sig-chart .weak { stroke: var(--warn); stroke-dasharray: 4 3; }
.sig-chart .axis { fill: var(--muted); font-size: var(--fs-xs); }
.sig-chart .bar { fill: var(--accent); opacity: .75; }
.sig-chart .lost, .sig-legend .key.lost { fill: var(--error); background: var(--error); }
.sig-chart .retry, .sig-legend .key.retry { fill: var(--warn); background: var(--warn); }
.sig-legend .key { display: inline-block; width: 12px; height: 6px; margin: 0 4px 1px 10px; vertical-align: middle; }
.sig-legend .key:first-child { margin-left: 0; }
.sig-legend .key.weak { height: 0; border-top: 2px dashed var(--warn); }
.tag-table td { padding-top: 7px; padding-bottom: 7px; }
.tag-table input[type="checkbox"], #st-all { width: 24px; height: 24px; margin: 0; vertical-align: middle; }
.dash label.check > input { width: 18px; height: 18px; }
.dash-tools input { min-height: 34px; }
.tag-table .mac { font-size: var(--fs-sm); }
.tag-table .mac .pre { color: var(--muted); }
.tag-table .mac b { font-weight: 600; }
.tag-table .st { display: inline-flex; gap: 6px; align-items: center; }
.tag-table .st::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tag-table tr.lvl-bad td { background: color-mix(in srgb, var(--error) 7%, transparent); }
.tag-table td.meta { display: none; }
.tag-table td.empty button { margin-left: 6px; }
/* the header stays in view in a long table (the wrapper may not scroll on its own then) */
@media (min-width: 721px) {
  .dash-wrap { overflow: visible; }
  .tag-table thead th { position: sticky; top: 0; z-index: 1; background: var(--panel); }
}
@media (max-width: 720px) {
  .tag-table, .tag-table tbody { display: block; }
  .tag-table thead tr, .tag-table tbody tr { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-2); border-bottom: 1px solid var(--line); padding: 6px 0; }
  .tag-table th, .tag-table td { border: 0; padding: 0; }
  .tag-table .opt, .tag-table thead th:nth-child(3) { display: none; }
  .tag-table td.meta { display: block; grid-column: 2 / 4; font-size: var(--fs-sm); color: var(--muted); white-space: normal; }
  .tag-table .mac .pre { display: none; }
  .tag-table td.empty, .tag-table td.sig-detail { grid-column: 1 / -1; white-space: normal; }
  .tag-table td.sig-detail { padding: var(--space-2); }
  .tag-table tr.lvl-bad { background: color-mix(in srgb, var(--error) 7%, transparent); }
  .tag-table tr.lvl-bad td { background: none; }
}

/* The ticked tags: a count and what to do with them, at the right end of the tools above the table */
.selbar { margin-left: auto; display: inline-flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: var(--fs-sm); background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: var(--radius); padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3); }
.selbar[hidden] { display: none; }
.selbar #st-sel-count { font-weight: 600; }
.selbar .hidden-n { color: var(--muted); font-weight: 400; }
.selbar button.small { min-height: 28px; }
#st-hint { margin: 10px 0 0; }
#st-form[hidden] { display: none; }

details.fold > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "\25B8"; content: "\25B8" / ""; color: var(--muted); width: 1em; }
details.fold[open] > summary::before { content: "\25BE"; content: "\25BE" / ""; }
details.fold[open] > summary { margin-bottom: var(--space-3); }
details.help { margin: 0 0 var(--space-3); }
details.help > summary { cursor: pointer; color: var(--accent); font-size: var(--fs-sm); }
details.help > p { max-width: 62ch; }
.dash :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }


/* The AP's own dashboard: a layout file from the designer (js/apreceive.js) */
.recv { display: flex; gap: 18px; align-items: flex-start; border: 2px solid var(--accent); }
.recv h2 { margin-top: 0; }
.recv-img { width: min(296px, 40%); image-rendering: pixelated; border: 1px solid var(--text); background: var(--paper); }
.recv-body { flex: 1; min-width: 0; }
.recv-body p { margin: 6px 0; }
.recv-body label { display: block; margin: var(--space-2) 0; }
.recv [hidden] { display: none; }
.lname { display: inline-block; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 var(--space-2); margin: 2px 4px 2px 0; font-size: var(--fs-sm); }
.lname.new { border-color: var(--ok); color: var(--ok); }
.lname.gone { border-color: var(--warn); color: var(--warn); text-decoration: line-through; }
@media (max-width: 640px) { .recv { flex-direction: column; } .recv-img { width: 100%; } }

/* The Layouts card of the dashboard (js/aplayouts.js) */
.lay-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.lay-space { margin-left: auto; display: inline-flex; align-items: center; gap: var(--space-2); }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: var(--radius-sm); padding: 4px 10px; font-size: var(--fs-sm); min-height: 0; }
.seg button.on { background: var(--panel); box-shadow: var(--shadow-sm); font-weight: 600; }
.seg.small button { font-size: var(--fs-xs); padding: 3px 8px; }
.meter { display: inline-block; width: 120px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.lay-warn p { margin: var(--space-2) 0; padding: var(--space-2) var(--space-3); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); border-radius: var(--radius); }
.lay-body { display: flex; gap: var(--space-4); align-items: flex-start; }
.lay-main { flex: 1; min-width: 0; }
.lay-h { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 8px; }
.lay-font-list { list-style: none; padding: 0; margin: 0 0 var(--space-2); }
.lay-font-list li { padding: var(--space-1) 0; overflow-wrap: anywhere; }
.lay-fm { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-top: 10px; background: var(--panel); }
.lay-fm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-2) var(--space-3); }
.lay-fm-grid label { display: grid; gap: 3px; font-size: var(--fs-sm); color: var(--muted); }
.lay-fm-grid input, .lay-fm-grid select { width: 100%; box-sizing: border-box; }
.lay-fm .hint.error { color: var(--error); }
.lay-fm-grid [hidden] { display: none; }
.lay-fm-wide { grid-column: 1 / -1; }
.lay-fm-prev { margin-top: 10px; overflow-x: auto; background: var(--paper); border: 1px solid var(--paper-edge); border-radius: 2px; padding: 6px; }
.lay-fm-prev canvas { display: block; image-rendering: pixelated; }
.lay-h .small { text-transform: none; letter-spacing: 0; }
.lay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.lay-card { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-2); cursor: pointer; display: grid; gap: var(--space-1); align-content: start; background: var(--panel); }
.lay-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.lay-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
/* The frame has the 2.9" shape for every model so the cards line up; the picture is fitted
   inside it (a 1.54" square one with white on each side), never cut off (#303) */
.lay-thumb { background: var(--paper); border: 1px solid var(--paper-edge); border-radius: 2px; aspect-ratio: 296 / 128; position: relative; overflow: hidden; }
.lay-thumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.lay-n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lay-card .lay-name { font-size: var(--fs-xs); color: var(--muted); background: none; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lay-u { font-size: var(--fs-xs); color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.lay-b { display: flex; gap: 6px; margin-top: 2px; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: var(--fs-xs); font-weight: 500; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.off { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.lay-panel { flex: 0 0 380px; max-width: 380px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; position: sticky; top: 8px; }
.lay-p-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.lay-p-head h3 { margin: 0; font-size: var(--fs-lg); }
.lay-p-head .lay-x { border: 0; background: none; color: var(--muted); padding: 2px 6px; font-size: var(--fs-md); min-height: 0; }
.lay-p-head .lay-x:hover { color: var(--text); }
.lay-panel > p { margin: 6px 0; }
.lay-panel code { background: var(--bg); padding: 1px 5px; border-radius: var(--radius-sm); }
.lay .hint.error, .lay-panel .hint.error { color: var(--error); }
.lay .hint.ok, .lay-panel .hint.ok { color: var(--ok); }
.lay-inputs { display: grid; gap: 6px; }
.lay-inputs label { display: grid; grid-template-columns: minmax(0, 120px) minmax(0, 1fr); gap: var(--space-2); align-items: center; font-size: var(--fs-sm); }
.lay-f { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lay-inputs input { width: 100%; box-sizing: border-box; }
.lay-send-row { display: flex; gap: var(--space-2); margin-top: 10px; }
.lay-send-row select { flex: 1; min-width: 0; }
.lay-send-row select[hidden] { display: none; }
.lay-send .hint { margin: 6px 0 0; }
.lay-p-tabs { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); margin-top: 10px; }
.lay-code { background: var(--code-bg); color: var(--code-text); border-radius: var(--radius); padding: 10px 12px; font-size: var(--fs-xs); margin: 6px 0 0; white-space: pre; overflow-x: auto; }
@media (max-width: 900px) {
  .lay-body { flex-direction: column; }
  .lay-panel { position: static; flex: none; max-width: none; width: 100%; box-sizing: border-box; }
  .lay-space { margin-left: 0; }
  .lay-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-2); }
}

/* The weather dialog of the Dashboard's Send form (apsources.js): its own rules, since the
   Dashboard on a C6 has no designer.css */
.wx-dlg { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; width: min(520px, calc(100vw - 32px)); background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg); }
.wx-dlg::backdrop { background: var(--backdrop); }
.wx-dlg h3 { font-size: var(--fs-lg); margin: 0 0 var(--space-3); }
.wx-dlg .dlg-x { position: absolute; right: 12px; top: 10px; }
.wx-dlg .dlg-x button { border: 0; background: none; color: var(--muted); }
.wx-dlg .form { margin: 10px 0; }
.wx-dlg .dlg-buttons { display: flex; gap: var(--space-2); align-items: center; margin-top: var(--space-4); }
.wx-dlg .dlg-buttons .sep { flex: 1; }
.wx-places { display: grid; gap: 6px; }
.wx-places label { display: flex; gap: var(--space-2); align-items: center; }
.wx-find { position: relative; min-width: 0; }
.wx-find input { width: 100%; }
.wx-hits { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 5; margin: 0; padding: var(--space-1) 0; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); max-height: 280px; overflow-y: auto; }
.wx-hits[hidden] { display: none; }
.wx-hits li { display: flex; flex-direction: column; padding: 5px 10px; cursor: pointer; }
.wx-hits li span { font-size: var(--fs-xs); color: var(--muted); }
.wx-hits li:hover, .wx-hits li[aria-selected="true"] { background: var(--line); }
