:root {
  --bg: #101317; --panel: #191d23; --line: #2a3039; --text: #e9edf2; --muted: #8a94a3;
  --accent: #3fb36b; --stop: #e0473c; --warn: #e3a23b;
  --wave-bg: #0b0d10; --wave: #5c6878; --beep: #e3a23b; --shot: #3fb36b; --manual: #4aa3ff;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f7; --panel: #ffffff; --line: #d9dde3; --text: #15181d; --muted: #616b78;
    --wave-bg: #eef0f3; --wave: #8d97a5; color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  touch-action: manipulation; }
button:active { filter: brightness(1.3); }
.tabs { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg); border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-radius: 0; background: none; padding: 12px 4px; color: var(--muted); font-size: 15px; }
.tabs button.active { color: var(--text); box-shadow: inset 0 -3px 0 var(--accent); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 40px; }
.tab { display: none; } .tab.active { display: block; }
.display { text-align: center; padding: 8px 0 12px; }
.state { color: var(--muted); font-size: 18px; min-height: 26px; }
.state.go { color: var(--accent); font-weight: 600; }
.big { font-size: 88px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -2px; }
.biglabel { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.sub { margin-top: 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sub span { color: var(--text); }
.start { display: block; width: 100%; height: 120px; font-size: 34px; font-weight: 700; border: 0;
  background: var(--accent); color: #fff; border-radius: 16px; }
.start.stop { background: var(--stop); }
.start.wait { background: var(--warn); }
.meter { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums; }
.meter .bar { position: relative; flex: 1; height: 10px; background: var(--panel); border-radius: 5px; overflow: hidden; }
#meter-bar { height: 100%; width: 0; background: var(--accent); }
#meter-thr { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--warn); }
h2 { font-size: 18px; margin: 20px 0 8px; } h2 small { color: var(--muted); font-weight: 400; font-size: 13px; }
canvas#wave { width: 100%; height: 160px; display: block; border-radius: 8px; touch-action: manipulation; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.row button { flex: 1 1 auto; }
button.toggle.on { background: var(--manual); color: #fff; border-color: transparent; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); border: 1px solid var(--warn);
  padding: 8px 10px; border-radius: 8px; font-size: 14px; margin: 8px 0; }
table.shots { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin-top: 8px; }
.shots th, .shots td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.shots th:first-child, .shots td:first-child { text-align: left; }
.shots th { color: var(--muted); font-weight: 500; font-size: 13px; }
.shots tr.invalid td { color: var(--muted); }
.shots tr.manual td:first-child::after { content: " ✎"; color: var(--manual); }
.shots td.split { font-weight: 600; }
details.det { margin: 12px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
details.det summary { cursor: pointer; }
label { display: block; margin: 10px 0; font-size: 14px; }
input[type=range] { width: 100%; display: block; margin-top: 4px; }
.note textarea { width: 100%; margin-top: 4px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; }
form#settings fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 12px; padding: 4px 12px 8px; }
form#settings legend { color: var(--muted); padding: 0 6px; font-size: 13px; }
form#settings label { display: grid; grid-template-columns: 1fr 96px; align-items: center; gap: 8px; }
form#settings input { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; text-align: right; }
pre#diag { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.filebtn { display: block; width: 100%; text-align: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; margin: 0; }
.filebtn input { display: none; }
ul.hist { list-style: none; padding: 0; margin: 8px 0; }
.hist li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hist .info { flex: 1; min-width: 0; }
.hist .t { font-size: 13px; color: var(--muted); }
.hist .v { font-variant-numeric: tabular-nums; }
.hist .n { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist button { padding: 8px 10px; }
