*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3e;
  --accent: #5b8dee;
  --danger: #e05c5c;
  --ok: #4caf7d;
  --text: #d0d4e8;
  --muted: #6b7090;
  --radius: 8px;
}

body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; font-size: 14px; line-height: 1.5; }

/* ── Login / registration / password reset ── */
.auth-page { display: none; align-items: center; justify-content: center; min-height: 100vh; background: url('/static/loginimage.jpg') center/cover no-repeat; }
.auth-page.active { display: flex; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 340px; }
.login-box h1 { font-size: 1.2rem; margin-bottom: 1.5rem; color: var(--accent); }
.login-box input, .login-box select { width: 100%; padding: .6rem .8rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 14px; margin-bottom: .75rem; }
.login-box input:focus, .login-box select:focus { outline: none; border-color: var(--accent); }
.login-box button { width: 100%; padding: .65rem; background: var(--accent); border: none; border-radius: var(--radius); color: #fff; font-size: 14px; cursor: pointer; }
.login-box button:hover { filter: brightness(1.1); }
.login-box small { display: block; color: var(--muted); font-size: 12px; margin: -.4rem 0 .75rem; }
.auth-links { display: flex; justify-content: space-between; gap: .5rem; margin-top: .75rem; }
.auth-links a { color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: none; }
.auth-links a:hover { color: var(--accent); }
.auth-error { color: var(--danger); font-size: 12px; margin-top: .5rem; min-height: 1rem; }
.auth-ok { color: var(--ok); font-size: 12px; margin-top: .5rem; min-height: 1rem; }

/* ── Dashboard ── */
#dashboard { display: none; flex-direction: column; min-height: 100vh; }
header { display: flex; align-items: center; gap: 1rem; padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; }
header .brand { display: flex; align-items: center; gap: .5rem; flex: 0 0 auto; }
header .brand-logo { height: 1.8rem; width: auto; display: block; }
header h1 { font-size: 1rem; color: var(--accent); }
header select { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: .35rem .6rem; font-size: 13px; }
/* Site-wide places read as navigation, not as a row of equal-weight buttons:
   plain text items, with Sign out set apart at the far end. */
.site-nav { display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; }
.site-nav button, .site-nav a {
  background: none; border: none; border-radius: var(--radius); color: var(--muted);
  padding: .4rem .65rem; cursor: pointer; font-size: 14px; text-decoration: none; line-height: normal;
}
.site-nav button:hover, .site-nav a:hover { color: var(--text); background: rgba(255,255,255,.04); }
.account-cluster { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
#who { color: var(--muted); font-size: 13px; }
.signout-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); padding: .35rem .75rem; cursor: pointer; font-size: 13px; }
.signout-btn:hover { color: var(--text); }
header :is(button, a, select):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header controls wrapper — a plain inline flex row on wide viewports, a
   collapsible dropdown sheet on narrow ones (see the mobile block below). */
.header-controls { display: flex; align-items: center; gap: 1rem; flex: 1; min-width: 0; }
.nav-toggle { display: none; }

.content { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1rem; flex: 1; }
@media (max-width: 720px) { .content { grid-template-columns: 1fr; } }

/* A table whose columns don't fit a phone width scrolls sideways inside its
   own box instead of overflowing the panel/modal and getting clipped. */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.panel h2 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: .75rem; }

/* Status */
.status-grid { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; }
.status-grid .label { color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; background: var(--muted); }
.dot.online { background: var(--ok); }
.dot.offline { background: var(--danger); }
.dot.connected { background: var(--ok); }
.dot.connecting { background: var(--accent); }
.dot.error { background: var(--danger); }
.dot.disabled { background: var(--muted); }

/* Audio */
#waveform { width: 100%; height: 80px; background: var(--bg); border-radius: 4px; margin-bottom: .75rem; display: block; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn { padding: .5rem 1rem; border: none; border-radius: var(--radius); font-size: 13px; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #363a52; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* Gain panel */
.gain-row { display: flex; align-items: center; gap: 1rem; }
.gain-row input[type=range] { flex: 1; accent-color: var(--accent); }
.gain-row .gain-label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.gain-row .gain-val { color: var(--text); font-size: 13px; font-weight: 600; min-width: 2rem; text-align: right; }

/* Files */
.files-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin-bottom: .75rem; }
.files-filters label { display: flex; flex-direction: column; gap: .2rem; color: var(--muted); font-size: 12px; }
.files-filters input[type=datetime-local] {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 13px; padding: .3rem .5rem;
}
.files-filters input[type=datetime-local]:focus { outline: none; border-color: var(--accent); }
.files-filters .max-wrap { display: flex; flex-direction: column; gap: .2rem; }
.files-filters .max-wrap span { color: var(--muted); font-size: 12px; }
.files-filters .max-wrap .max-row { display: flex; align-items: center; gap: .5rem; }
.files-filters .max-wrap input[type=range] { width: 100px; accent-color: var(--accent); }
.files-filters .max-wrap .max-val { color: var(--text); font-size: 13px; min-width: 2ch; }
.files-filters button.btn-secondary { align-self: flex-end; }
#files-count { color: var(--muted); font-size: 12px; align-self: flex-end; }

#files-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#files-table th { text-align: left; color: var(--muted); padding: .25rem .5rem; border-bottom: 1px solid var(--border); }
#files-table td { padding: .35rem .5rem; border-bottom: 1px solid var(--border); }
#files-table tr:last-child td { border-bottom: none; }
.tbl-actions { display: flex; gap: .4rem; }
.tbl-actions button { border: none; border-radius: 4px; padding: .2rem .5rem; cursor: pointer; font-size: 12px; }
.btn-play   { background: var(--ok); color: #fff; }
.btn-dl     { background: var(--accent); color: #fff; }
.btn-del    { background: var(--danger); color: #fff; }
.btn-report { background: var(--border); color: var(--text); }
#no-files   { color: var(--muted); font-size: 13px; padding: .5rem 0; }

.pagination { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; }
.pagination button { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); padding: .25rem .6rem; cursor: pointer; font-size: 12px; }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination span { color: var(--muted); font-size: 12px; }

#player-panel { margin-top: .75rem; padding: .6rem .75rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
#player-panel .player-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
#player-panel .player-name { flex: 1; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#player-panel #player-close { border: 1px solid var(--border); border-radius: var(--radius); background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: .15rem .5rem; }
#player-panel audio { width: 100%; display: block; }

/* Actions */
.action-group { margin-bottom: .75rem; }
.action-group label { display: block; color: var(--muted); font-size: 12px; margin-bottom: .3rem; }
.action-group input[type=text], .action-group input[type=password],
.action-group input[type=email], .action-group select {
  width: 100%; padding: .45rem .7rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 13px; margin-bottom: .35rem;
}
.action-group textarea {
  width: 100%; padding: .45rem .7rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 13px; margin-bottom: .35rem;
  font-family: inherit; resize: vertical; box-sizing: border-box;
}
.action-group input:focus, .action-group select:focus, .action-group textarea:focus { outline: none; border-color: var(--accent); }
.action-group .row { display: flex; align-items: center; gap: .5rem; }
/* Sized generously enough by default (rows= on the element) that dragging to
   resize shouldn't be necessary — see support-corrections. */
.action-group textarea.no-resize { resize: none; }

/* Add/remove attachment picker (support.js / console.js) — a hidden native
   <input type=file> plus a JS-held list, since the bare control can neither
   accumulate a selection across more than one open nor drop a single file
   added by mistake. */
.file-picker-list { display: flex; flex-direction: column; gap: .3rem; margin-top: .4rem; }
.file-picker-item {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .3rem .3rem .3rem .6rem; font-size: 12px;
}
.file-picker-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-picker-remove {
  flex-shrink: 0; background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 16px; line-height: 1; padding: .1rem .4rem; border-radius: 4px;
}
.file-picker-remove:hover { color: var(--danger); background: rgba(224,92,92,.12); }
.file-picker-empty { color: var(--muted); font-size: 12px; margin-top: .4rem; }
.checkbox-label { display: flex; align-items: center; gap: .4rem; font-size: 13px; color: var(--muted); }

/* OTA progress */
#ota-progress { display: none; margin-top: .5rem; }
progress { width: 100%; height: 6px; accent-color: var(--accent); }

/* Toast */
#toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--surface); border: 1px solid var(--border);
         border-radius: var(--radius); padding: .6rem 1rem; font-size: 13px; opacity: 0; transition: opacity .3s;
         max-width: 280px; z-index: 99; }
#toast.show { opacity: 1; }

/* ── Sound Detection Modal ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: center; justify-content: center; }
.detection-modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: min(520px, 95vw); max-height: 90vh; overflow-y: auto; }
.detection-modal-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.detection-modal-header h2 { font-size: 15px; font-weight: 600; color: var(--text); margin: 0; }
.detection-modal-header button { background: none; border: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; line-height: 1; padding: 0 .25rem; }
.detection-modal-header button:hover { color: var(--text); }
.detection-modal-body { padding: 1rem; }
.detection-enable-row { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; font-size: .95rem; color: var(--text); }
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 24px; cursor: pointer; transition: background .2s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-switch input:focus-visible + .toggle-slider { outline: 2px solid var(--accent); outline-offset: 2px; }
#detection-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#detection-table th { text-align: center; color: var(--muted); padding: .25rem .5rem; border-bottom: 1px solid var(--border); font-weight: normal; font-size: 12px; }
#detection-table th:first-child { text-align: left; min-width: 160px; }
#detection-table td { padding: .5rem .5rem; border-bottom: 1px solid var(--border); text-align: center; }
#detection-table td:first-child { text-align: left; }
#detection-table tr:last-child td { border-bottom: none; }
#detection-table tr:nth-child(even) { background: rgba(255,255,255,.025); }
#detection-table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
#detection-table input.threshold-input {
  width: 68px; padding: .3rem .4rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 12px; text-align: center;
}
#detection-table input.threshold-input:focus { outline: none; border-color: var(--accent); }
.detection-threshold-hint { display: block; color: var(--muted); font-size: 12px; margin-top: .5rem; }
.btn-link { background: none; border: none; padding: 0; color: var(--accent); font-size: inherit; cursor: pointer; text-decoration: underline; }
.detection-keeponly-row { display: flex; align-items: flex-start; gap: .75rem; margin-top: 1rem; font-size: .95rem; color: var(--text); cursor: pointer; }
.detection-keeponly-row input[type=checkbox] { width: 16px; height: 16px; margin-top: .2rem; accent-color: var(--accent); cursor: pointer; flex: none; }
.detection-keeponly-row small { display: block; color: var(--muted); font-size: 12px; margin-top: .2rem; }

/* ── Multi-site: device manager, site admin, audit ── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; color: var(--muted); font-weight: normal; padding: .3rem .5rem; border-bottom: 1px solid var(--border); }
.admin-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .tbl-actions button { border: none; border-radius: 4px; padding: .2rem .5rem; cursor: pointer; font-size: 12px; }
.admin-table select.assign-site { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; color: var(--text); padding: .2rem .4rem; font-size: 12px; max-width: 14rem; margin-right: .3rem; }
.admin-scroll { max-height: 320px; overflow-y: auto; overflow-x: auto; }
/* Fixed layout + an explicit colgroup (see support-corrections) gives this
   table deliberate column widths instead of table-layout:auto's tendency to
   dump all the panel's spare width into one arbitrary gap. */
.support-table { table-layout: fixed; }
.support-table td, .support-table th { padding: .55rem .75rem; }
.support-table td { overflow-wrap: break-word; }
.pill { font-size: 11px; padding: .1rem .45rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.pill.on { color: var(--ok); border-color: var(--ok); }
.pill.off { color: var(--muted); }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }
.inline-form input { padding: .4rem .6rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 13px; }
.inline-form input:focus { outline: none; border-color: var(--accent); }
.wide-modal { width: min(760px, 95vw); }

/* Admin console tab bar (srv-0.23.2) — splits the super-user view into
   Overview and Support Tickets so support isn't just the last panel in one
   long scrolling list. .admin-tab-content stays a grid-item passthrough
   (display: contents) when active so its child .panels still lay out
   against #superuser-view's own two-column grid, same as if the wrapper
   weren't there at all. */
.admin-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.admin-tab {
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted);
  padding: .55rem .9rem; font-size: 13px; cursor: pointer; margin-bottom: -1px;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.admin-tab-content { display: contents; }
.admin-tab-content.hidden { display: none; }

/* ── Utility classes (srv-0.16.0) ──
   Small, generic, reused across many components — kept separate from the
   semantic component classes below them so the two don't get tangled. A class
   here is never removed for being "only used once somewhere" — the point is
   that no element's look lives in an inline style attribute any more. */
.hidden { display: none; }
.block { display: block; }
.mt-05 { margin-top: .5rem; }
.mt-075 { margin-top: .75rem; }
.mt-1 { margin-top: 1rem; }
.mb-05 { margin-bottom: .5rem; }
.mb-075 { margin-bottom: .75rem; }
.mb-1 { margin-bottom: 1rem; }
.mr-025 { margin-right: .25rem; }
.full-width { grid-column: 1 / -1; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.checkbox-md { width: 16px; height: 16px; accent-color: var(--accent); }
.section-divider { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ── Semantic component classes (srv-0.16.0) ──
   Replace what used to be one-off style="…" attributes in index.html. Named
   for what the element is, not what it looks like — a future style change
   edits the rule here, not every call site. */
.help-text { color: var(--muted); font-size: 12px; display: block; margin-bottom: .35rem; }
.help-text-loose { color: var(--muted); font-size: 12px; margin-bottom: .75rem; }
.modal-note { margin-bottom: .75rem; color: var(--muted); font-size: 13px; }
.note-13 { color: var(--muted); font-size: 13px; }
.ok-note { color: var(--ok); font-size: 13px; }
.ok-note-loose { color: var(--ok); margin-bottom: .75rem; font-size: 13px; }
.danger-note { color: var(--danger); font-size: 13px; margin-bottom: .75rem; }
.modal-sm { max-width: 420px; }
.modal-xs { max-width: 400px; }
.btn-group-gap { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.toggle-row { display: flex; align-items: center; gap: .4rem; font-size: 13px; color: var(--text); font-weight: normal; }
.toggle-row.mb-05 { margin-bottom: .5rem; }
.toggle-row.my-075 { margin: .75rem 0 .5rem; }
.mqtt-status-row { display: flex; align-items: center; gap: .4rem; font-size: 12px; color: var(--muted); margin-bottom: .25rem; }
.credit-bar-fill { height: 100%; background: var(--accent); width: 0%; }
.checkbox-inline-label { font-weight: normal; margin-top: .35rem; display: flex; align-items: center; gap: .4rem; }
.recordings-note { color: var(--muted); font-size: 12px; margin: -.3rem 0 .6rem; }
.refresh-files-btn { font-size: 12px; padding: .2rem .6rem; margin-left: .5rem; }
.small-btn { font-size: 12px; padding: .3rem .6rem; }
.cal-countdown-num { font-size: 3rem; font-weight: 700; color: var(--accent); }
.cal-countdown-unit { font-size: 1.2rem; color: var(--muted); }
.credits-balance-num { font-size: 2rem; font-weight: 700; }
.credits-balance-wrap { text-align: center; padding: .5rem 0 1rem; }
.cal-countdown-wrap { text-align: center; padding: 1rem 0; }
.cal-measuring-note { text-align: center; color: var(--muted); font-size: 12px; }
.credits-bar-track { background: var(--border); border-radius: 6px; height: 8px; overflow: hidden; margin-bottom: .25rem; }
.account-help { color: var(--muted); font-size: 12px; display: block; margin-bottom: .35rem; }

/* Selected-site banner (srv-0.22.0) — always in normal flow (never inside
   .header-controls), so it stays visible whether or not the mobile hamburger
   menu is open. Deliberately styled apart from #dashboard-credits-banner:
   that one is a danger-colored alert, this is routine navigational context
   and must not read as a warning. Uses :not(.hidden) rather than a `display`
   property on the bare id, matching srv-0.21.1's fix — an id-level `display`
   would out-specificity the shared `.hidden{display:none}` and the toggle
   would silently stop working regardless of source order. */
#site-banner { align-items: center; gap: .6rem; padding: .5rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 13px; }
#site-banner:not(.hidden) { display: flex; }
#site-banner .site-banner-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
#site-banner .site-banner-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
#site-banner.has-site { background: linear-gradient(90deg, rgba(91, 141, 238, .16), rgba(91, 141, 238, .03)); }
#site-banner.has-site .site-banner-dot { background: var(--accent); }
#site-banner.has-site .site-banner-text { color: var(--text); }
#site-banner.has-site #site-banner-name { color: var(--accent); font-weight: 600; }
#site-banner-change { flex: 0 0 auto; }

/* Selected Site panel (srv-0.22.0, admin_ui/console.html) — the per-site
   Detection Feedback history/status a super-user previously had to find by
   scrolling the all-sites Detection Feedback Summary table for the right
   row, now surfaced the moment a site is picked. */
.selected-site-stats { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-bottom: .85rem; }
.selected-site-stat .label { display: block; color: var(--muted); font-size: 12px; margin-bottom: .15rem; }
.selected-site-feedback { padding-top: .75rem; border-top: 1px solid var(--border); }
.selected-site-feedback-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.selected-site-feedback-head .label { color: var(--muted); font-size: 12px; }
#ss-feedback-stats { color: var(--muted); font-size: 12px; }
.feedback-site-chip { cursor: pointer; }
.feedback-site-chip::after { content: ' \2715'; }

/* One-off ids: each names an element unique enough on the page that a shared
   class would only add indirection. */
#dashboard-credits-banner { background: var(--danger); color: #fff; padding: .5rem 1rem; font-size: 13px; cursor: pointer; }
#credits-exhausted-banner { background: var(--danger); color: #fff; border-radius: 6px; padding: .6rem .8rem; font-size: 13px; }
#credits-metered-note { background: var(--border); border-radius: 6px; padding: .6rem .8rem; font-size: 13px; }
/* Firmware update banner. The accent edge says "working", green "done", red "failed";
   the words say the same, so colour is never the only signal. :not(.hidden) rather than
   a bare `display`, for the reason given on #site-banner above. */
#ota-banner { flex-direction: column; gap: .4rem; padding: .75rem 2.25rem .75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); font-size: 13px;
  /* A floating card, not a strip in the page flow: the update button is far down the
     page and a banner at the top was out of sight. Above the modals (50), below the toast (99). */
  position: fixed; top: .75rem; left: 50%; transform: translateX(-50%); width: min(38rem, calc(100% - 1.5rem)); z-index: 70; box-shadow: 0 8px 28px rgba(0,0,0,.45); }
#ota-banner:not(.hidden) { display: flex; }
#ota-banner[data-phase="done"] { border-left-color: var(--ok); }
#ota-banner[data-phase="failed"] { border-left-color: var(--danger); }
#ota-banner .ota-banner-body { display: flex; flex-wrap: wrap; gap: .25rem .75rem; }
#ota-banner progress { width: 100%; }
#ota-banner progress.hidden { display: none; }
#ota-banner-dismiss { position: absolute; top: .4rem; right: .6rem; background: none; border: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
#ota-banner-dismiss:hover, #ota-banner-dismiss:focus-visible { color: var(--text); }
#ota-banner-dismiss.hidden { display: none; }
#label-input { text-transform: uppercase; }
#ota-file { color: var(--text); font-size: 13px; margin-bottom: .35rem; }
#delete-include-preserved { width: auto; }

/* ── Device page (srv-0.26.0) ──
   One device at a time: the device bar says which one and whether it is reachable,
   and four tabs split what used to be one long scroll. Tabs follow NN/g's "Tabs,
   Used Right" (one row, above the panel, two selection cues, sentence case) and the
   WAI-ARIA APG keyboard model (js/tabs.js). */
.device-view { display: flex; flex-direction: column; gap: 1rem; width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.25rem 2rem; flex: 1; }
.device-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.device-ident { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.device-dot { width: 10px; height: 10px; margin: 0; flex: none; }
.device-ident-text { min-width: 0; }
.device-title { font-size: 1.4rem; font-weight: 650; line-height: 1.2; color: var(--text); letter-spacing: .01em; overflow-wrap: anywhere; }
.device-sub { display: block; color: var(--muted); font-size: 13px; }
.device-bar-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.device-bar-actions select { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: .45rem .6rem; font-size: 13px; max-width: 22rem; }
.device-bar-actions select.hidden { display: none; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-top: -.25rem; }
.tab {
  background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -1px;
  color: var(--muted); padding: .65rem 1rem; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px 4px 0 0; }
.tab-panel { display: flex; flex-direction: column; gap: 1rem; }
.tab-panel[hidden] { display: none; }
.tab-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; min-width: 0; }
.card-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: .6rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .6rem; }
.card-head .card-title { margin-bottom: 0; }
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.card-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
/* A checkbox row inside a form group: the generic `.action-group label` rule
   (block, muted, 12px) used to win over .toggle-row and push the box off its text. */
.action-group label.toggle-row { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: 13px; }

.disclosure { margin-top: .85rem; padding-top: .65rem; border-top: 1px solid var(--border); }
.disclosure > summary { cursor: pointer; color: var(--muted); font-size: 13px; width: max-content; }
.disclosure > summary:hover { color: var(--text); }
.disclosure > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.disclosure[open] > summary { margin-bottom: .6rem; }
.status-link { margin-left: .5rem; font-size: 12px; }

.site-wide-note { color: var(--muted); font-size: 13px; padding-top: .25rem; }

/* A setting with its explanation on the left and its one action on the right. */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.setting-text { min-width: 0; }
.setting-text .help-text { margin: .15rem 0 0; }
.setting-row > .btn { flex: none; }

/* Destructive device actions, fenced off from routine ones so neither is hit by
   mistake for the other. The red edge is backed by the heading's words. */
.danger-zone { border: 1px solid rgba(224, 92, 92, .45); border-radius: var(--radius); padding: .25rem 1.1rem; }
.danger-zone-title { font-size: 15px; font-weight: 600; color: var(--danger); padding: .75rem 0 .25rem; }
.danger-zone .setting-row { padding: .8rem 0; }
.danger-zone .setting-row + .setting-row { border-top: 1px solid var(--border); }

/* The Account modal's on/off switch. Scoped under .action-group so these beat the
   generic `.action-group label` block-label rule. */
.action-group .switch-row { display: flex; align-items: center; gap: .75rem; margin: .2rem 0 .45rem; }
.action-group .switch-row .toggle-switch { display: inline-block; margin: 0; }
.action-group .switch-row .switch-label { display: inline; margin: 0; color: var(--text); font-size: 13px; cursor: pointer; }

@media (max-width: 860px) { .overview-grid, .card-pair { grid-template-columns: 1fr; } }

/* ── Mobile (phone) layout ──
   Narrower than the .content breakpoint above: the header's controls no
   longer fit in one line, and centered modals sized off vh/vw crop their
   content on a short viewport. Below this width the header collapses behind
   a hamburger and every modal becomes a full-screen sheet instead.
   Placed last on purpose: several rules here override earlier same-specificity
   selectors (.overlay, .detection-modal, .wide-modal, .actions-grid), and CSS
   cascade order — not the media condition — decides ties between those, so
   this block must come after every rule it means to override. */
@media (max-width: 640px) {
  header { padding: .6rem .9rem; flex-wrap: nowrap; }
  header h1 { font-size: .95rem; }
  .nav-toggle {
    margin-left: auto;
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem; background: none; border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 1.1rem; cursor: pointer;
  }
  .header-controls {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: .5rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: .75rem .9rem 1rem; z-index: 60;
    box-shadow: 0 8px 16px rgba(0,0,0,.3);
  }
  .header-controls.open { display: flex; }
  .header-controls select, .header-controls button, .header-controls a {
    width: 100%; padding: .65rem .9rem; font-size: 14px; text-align: left;
  }
  .site-nav { flex-direction: column; align-items: stretch; gap: .1rem; }
  /* Signed-in-as at the top of the sheet, Sign out at the bottom. */
  .account-cluster { display: contents; }
  #who { order: -1; color: var(--muted); font-size: 12px; padding: 0 .1rem .35rem; border-bottom: 1px solid var(--border); }
  .signout-btn { order: 99; margin-top: .25rem; }

  .device-view { padding: .9rem .9rem 1.5rem; }
  .device-title { font-size: 1.2rem; }
  .device-bar-actions { width: 100%; }
  .device-bar-actions select { flex: 1 1 100%; max-width: none; }
  /* Four short labels fit a phone; if a larger text size makes them overflow, the
     row scrolls sideways rather than wrapping into two rows. */
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tab { flex: 1 0 auto; padding: .65rem .55rem; }
  .card-pair { grid-template-columns: 1fr; }
  .setting-row { flex-wrap: wrap; }

  /* Recordings as one compact card per file: five columns do not fit a phone, and
     sideways scrolling hid the Play/Download buttons. Name on top, length and
     flags under it, actions last. */
  #files-table thead { display: none; }
  #files-table, #files-table tbody { display: block; }
  #files-table tr {
    display: grid; grid-template-columns: auto auto 1fr; gap: .2rem .9rem; align-items: center;
    grid-template-areas: "name name name" "dur det pres" "act act act";
    padding: .65rem 0; border-bottom: 1px solid var(--border);
  }
  #files-table tr:last-child { border-bottom: none; }
  #files-table td { padding: 0; border: none; }
  #files-table .rec-name { grid-area: name; font-weight: 600; overflow-wrap: anywhere; }
  #files-table .rec-dur { grid-area: dur; color: var(--muted); }
  #files-table .rec-det { grid-area: det; }
  #files-table .rec-pres { grid-area: pres; text-align: left; }
  #files-table .rec-actions { grid-area: act; padding-top: .35rem; }
  #files-table .tbl-actions { flex-wrap: wrap; }
  #files-table .tbl-actions button { padding: .4rem .7rem; font-size: 13px; }
  /* "Nothing detected" / "not preserved" placeholders only make sense under a
     column heading, and the card has none. */
  #files-table .rec-det > .text-muted, #files-table .rec-pres > .text-muted { display: none; }

  /* Same banner, tighter side padding to match the narrower header above —
     it stays outside .header-controls so the hamburger state above it has
     no bearing on whether it's visible. */
  #site-banner { padding: .5rem .9rem; }
  #site-banner-change { font-size: 12px; padding: .3rem .5rem; }

  .login-box { width: 92vw; max-width: 340px; }

  .actions-grid { grid-template-columns: 1fr; }

  /* Every dialog becomes a full-screen sheet: fixed-width modals sized in vw
     and a scroll region that only covers vertical overflow are exactly what
     was clipping options off the right edge on a phone. */
  .overlay { padding: 0; align-items: stretch; justify-content: stretch; }
  .detection-modal, .wide-modal {
    width: 100%; max-width: 100%; height: 100%; max-height: 100%;
    border-radius: 0; display: flex; flex-direction: column;
  }
  .detection-modal-header { flex: 0 0 auto; }
  .detection-modal-body { flex: 1 1 auto; overflow-y: auto; }

  /* .admin-table's Name/MAC/timestamp columns push every Actions column (Remove
     device, Delete site, Disable feedback…) well past 100vw. .table-scroll and
     .admin-scroll make that reachable by a horizontal swipe, but nothing on a
     phone hints one is needed, so the only control in the row reads as missing
     rather than off-screen. Pin it to the visible edge instead of relying on
     the swipe being discovered. */
  .admin-table td { white-space: nowrap; }
  .admin-table .tbl-actions {
    position: sticky; right: 0; background: var(--surface);
  }
}

/* ── Report a missed sound (srv-0.25.0) ──
   Big tap targets: the whole flow is two taps, often on a phone, often just
   after the sound. */
.report-question { font-size: 15px; font-weight: 600; margin-bottom: .6rem; }
.report-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.report-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
  min-height: 72px; padding: .6rem .5rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px; cursor: pointer;
  transition: border-color .12s, background .12s; }
.report-tile:hover { border-color: var(--accent); }
.report-tile:focus-visible, .report-chosen:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.report-tile:active { background: var(--border); }
.report-tile .report-emoji { font-size: 28px; line-height: 1; }
.report-tiles-time .report-tile { min-height: 52px; }
.report-tile[disabled] { opacity: .5; cursor: progress; }
.report-chosen { display: inline-flex; align-items: center; gap: .4rem; margin-bottom: .75rem; padding: .3rem .7rem;
  background: var(--border); border: none; border-radius: 999px; color: var(--text); font-size: 13px; cursor: pointer; }
.report-chosen::after { content: "Change"; color: var(--accent); font-size: 12px; margin-left: .3rem; }
.report-pick { display: flex; gap: .5rem; margin-top: .6rem; }
.report-pick.hidden { display: none; }
.report-pick input { flex: 1; min-width: 0; padding: .5rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px; color-scheme: dark; }
.report-keep { margin-top: .9rem; color: var(--muted); font-size: 12px; align-items: flex-start; }
.report-keep input { margin-top: .2rem; }
.report-done { font-size: 15px; margin-bottom: .9rem; }
.report-done::before { content: "✓"; color: var(--ok); font-weight: 700; margin-right: .4rem; }
.report-recent { margin-top: 1.1rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.report-recent-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .4rem; }
.report-recent ul { list-style: none; display: flex; flex-direction: column; gap: .3rem; font-size: 13px; }
.report-recent li { display: flex; justify-content: space-between; gap: .5rem; }
.report-status { color: var(--muted); font-size: 12px; white-space: nowrap; }
.report-status.ok { color: var(--ok); }
.report-status.warn { color: #d9a441; }
@media (min-width: 560px) { .report-tiles:not(.report-tiles-time) { grid-template-columns: repeat(4, 1fr); } }
@media (prefers-reduced-motion: reduce) { .report-tile { transition: none; } }
