:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e2e2dd;
  --text: #1b1b1a;
  --muted: #6b6b66;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --bad: #c53030;
  --meter-lo: #2fa36b;
  --meter-hi: #e0a526;
  --meter-clip: #e04848;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111213;
    --surface: #1a1b1d;
    --border: #2a2c2f;
    --text: #ececea;
    --muted: #9a9a95;
    --accent: #5b8ef0;
    --accent-text: #0d0e10;
    --ok: #4cc283;
    --warn: #e0b04a;
    --bad: #f07171;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111213;
  --surface: #1a1b1d;
  --border: #2a2c2f;
  --text: #ececea;
  --muted: #9a9a95;
  --accent: #5b8ef0;
  --accent-text: #0d0e10;
  --ok: #4cc283;
  --warn: #e0b04a;
  --bad: #f07171;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: grid;
  gap: 16px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.brand { font-weight: 700; letter-spacing: 0.02em; }
.room { color: var(--muted); font-size: 13px; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--text); }

.hero { text-align: center; padding: 16px 0 4px; }

#start {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 44px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
#start[data-active="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
#start:disabled { opacity: 0.5; cursor: not-allowed; }

.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.error { color: var(--bad); margin: 12px 0 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.status {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 0;
}
.status dt { color: var(--muted); }
.status dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.status [data-tone="ok"] { color: var(--ok); }
.status [data-tone="warn"] { color: var(--warn); }
.status [data-tone="bad"] { color: var(--bad); }

.bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 6px; overflow: hidden; }
#buffer-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.meters { display: grid; gap: 6px; }
.meter { display: grid; grid-template-columns: 16px 1fr; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--meter-lo) 0%, var(--meter-lo) 80%, var(--meter-hi) 92%, var(--meter-clip) 100%);
  background-size: 100vw 100%;
  transition: width 0.08s linear;
}

.controls { display: grid; gap: 16px; }
.controls label { display: grid; gap: 6px; }
.controls label > span { color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; }
select, input[type="range"] { width: 100%; font: inherit; }
select {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

@media (max-width: 420px) {
  .status { grid-template-columns: 1fr; gap: 2px; }
  .status dd { margin-bottom: 8px; }
}
