/* Sound Sensing page. Colors are roles; the dark values are their own steps, not a flip. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series: #2a78d6;
  --band: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --shadow: 0 6px 20px rgba(11, 11, 11, 0.08);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series: #3987e5;
    --band: rgba(57, 135, 229, 0.14);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series: #3987e5;
  --band: rgba(57, 135, 229, 0.14);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text); }
body { line-height: 1.4; -webkit-text-size-adjust: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 16px 40px; }
[hidden] { display: none !important; }

/* ---- header: title and the live level (not scoped by the filters) ---- */
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 32px; flex-wrap: wrap; }
h1 { font-size: 26px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.sub { margin: 4px 0 0; color: var(--text-2); font-size: 15px; }
.now { text-align: right; }
.now-label { font-size: 13px; color: var(--text-2); }
.now-value { font-size: 56px; font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; }
.now-value .unit { font-size: 20px; font-weight: 500; color: var(--text-2); margin-left: 6px; letter-spacing: 0; }
.now.stale .now-value { color: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); margin-top: 2px; }
.status-icon { width: 10px; height: 10px; flex: none; }
.status[data-state="live"] .status-icon { background: var(--good); border-radius: 50%; animation: pulse 2s ease-in-out infinite; }
.status[data-state="delayed"] .status-icon { background: var(--warning); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.status[data-state="offline"] .status-icon { background: var(--critical); }
.status[data-state="unknown"] .status-icon { border: 2px solid var(--muted); border-radius: 50%; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .status-icon { animation: none !important; } }

/* ---- filter row ---- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 26px 0 22px; }
.presets { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.presets button {
  font: inherit; font-size: 14px; color: var(--text-2); background: transparent;
  border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
.presets button:hover { background: var(--border); color: var(--text); }
.presets button[aria-pressed="true"] { background: var(--text); color: var(--page); font-weight: 600; }
.custom, .device { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.custom label { display: inline-flex; align-items: center; gap: 6px; }
input, select, .custom button {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px;
}
.custom button { padding: 6px 14px; cursor: pointer; }
.custom button:hover { background: var(--border); }
:focus-visible { outline: 2px solid var(--series); outline-offset: 2px; }

/* ---- range summary ---- */
.range-title { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.error { margin: 0 0 12px; font-size: 14px; color: var(--text); }
.error::before { content: "▲"; color: var(--critical); margin-right: 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 12px; }
.tile-label { font-size: 13px; color: var(--text-2); }
.tile-value { font-size: 28px; font-weight: 600; margin-top: 2px; letter-spacing: -0.01em; }
.tile-value .unit { font-size: 14px; font-weight: 500; color: var(--text-2); margin-left: 4px; letter-spacing: 0; }
.tile-note { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- chart ---- */
.card { position: relative; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 16px 10px; }
figcaption h3 { font-size: 15px; font-weight: 600; margin: 0; }
figcaption p { font-size: 13px; color: var(--text-2); margin: 2px 0 10px; }
.chart { position: relative; min-height: 260px; border-radius: 6px; transition: opacity 0.15s; }
.card.loading .chart { opacity: 0.55; }
.empty { position: absolute; left: 0; right: 0; top: 150px; margin: 0; text-align: center; color: var(--muted); font-size: 14px; pointer-events: none; }

.u-select { background: var(--band); }
.u-cursor-x { border-right: 1px solid var(--muted) !important; }
.u-over { cursor: crosshair; }
.marker { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--series);
          box-shadow: 0 0 0 2px var(--surface); transform: translate(-50%, -50%); pointer-events: none; }

.tip { position: absolute; z-index: 5; pointer-events: none; min-width: 132px; background: var(--surface);
       border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 13px; }
.tip-value { font-size: 17px; font-weight: 650; }
.tip-value .unit { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.tip-key { display: inline-block; width: 14px; height: 2px; background: var(--series); vertical-align: middle; margin-right: 6px; border-radius: 1px; }
.tip-range { color: var(--text-2); margin-top: 2px; }
.tip-time { color: var(--muted); font-size: 12px; margin-top: 2px; }

.table-view { margin-top: 6px; border-top: 1px solid var(--grid); padding-top: 8px; }
.table-view summary { cursor: pointer; font-size: 13px; color: var(--text-2); padding: 2px 0; }
.table-wrap { max-height: 360px; overflow: auto; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 4px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); color: var(--text-2); font-weight: 600; }
th:first-child, td:first-child { text-align: left; }

/* ---- footer ---- */
.foot { margin-top: 22px; font-size: 12px; color: var(--muted); }
.foot p { margin: 4px 0; max-width: 760px; }

@media (max-width: 640px) {
  .wrap { padding-top: 20px; }
  .now { text-align: left; }
  .now-value { font-size: 48px; }
  .filters { gap: 10px; }
  .presets { width: 100%; justify-content: space-between; }
  .presets button { padding: 6px 8px; }
}
