:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #57606a;
  --line: #d0d7de;
  --accent: #0b5cad;
  --accent-text: #ffffff;
  --accent-soft: #e8f1fb;
  --radius: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --surface: #1e2125;
    --text: #e6e8ea;
    --muted: #a5adb6;
    --line: #3a4048;
    --accent: #6cb0ff;
    --accent-text: #0d1117;
    --accent-soft: #1b2a3c;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 46rem; margin: 0 auto; padding: 0 1rem; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: .5rem; background: var(--surface); padding: .5rem .75rem; z-index: 10; }

.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem 1rem; padding-top: .5rem; padding-bottom: .5rem; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); text-decoration: none; }
.brand svg { width: 24px; height: 24px; }
.site-nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .95rem; }
.site-nav a[aria-current="page"] { color: var(--text); text-decoration: none; font-weight: 600; }

h1 { font-size: 1.5rem; line-height: 1.25; margin: 1rem 0 .35rem; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 2.5rem 0 .6rem; }
h3 { font-size: 1.1rem; line-height: 1.35; margin: 1.6rem 0 .4rem; }
p, ul, ol, table, dl { margin: 0 0 1rem; }
li { margin-bottom: .35rem; }
.lede { color: var(--muted); margin-bottom: 1rem; }

/* The tool */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
/* Row 1: label and level. Row 2: slider and Stop. */
.controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .25rem .75rem; }
.volume { display: contents; }
.volume label { grid-column: 1; grid-row: 1; font-weight: 600; }
.volume output { grid-column: 2 / 4; grid-row: 1; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.volume input { grid-column: 1 / 3; grid-row: 2; width: 100%; min-width: 0; margin: 0; accent-color: var(--accent); height: 2.25rem; }
.controls > .btn-stop { grid-column: 3; grid-row: 2; }
.safety { font-size: .95rem; color: var(--muted); margin: .5rem 0 .5rem; }
.status { font-weight: 600; margin: 0 0 .5rem; min-height: 1.6em; }

button { font: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .45rem 1rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-stop { font-weight: 600; border-color: var(--text); }
.btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--line); margin: 0 0 1rem; }
.tabs [role="tab"] {
  min-height: 44px; padding: .4rem .5rem; font-size: .95rem; border: 1px solid transparent; border-bottom: 0;
  border-radius: 6px 6px 0 0; background: none; color: var(--muted); cursor: pointer; margin-bottom: -1px;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--text); font-weight: 600; background: var(--surface); border-color: var(--line); }

.stage { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; margin: 0 0 .5rem; }
.side { border: 1px solid var(--line); border-radius: 6px; padding: .5rem; text-align: center; line-height: 1.3; }
.side strong { display: block; }
.side span { display: block; font-size: .85rem; color: var(--muted); }
.side.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.side.on span { color: var(--text); font-weight: 600; }

.steps { list-style: none; padding: 0; margin: 0 0 1rem; }
.steps > li { border-top: 1px solid var(--line); padding: .75rem 0 .25rem; margin: 0; }
.steps > li:first-child { border-top: 0; padding-top: .25rem; }
fieldset { border: 0; padding: 0; margin: .6rem 0 0; min-width: 0; }
legend { padding: 0; margin-bottom: .35rem; }
.choices { display: flex; flex-wrap: wrap; gap: .4rem; }
.choices label {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 44px;
  padding: .3rem .8rem; border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.choices input { margin: 0; accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }
.choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
fieldset:disabled { color: var(--muted); }
fieldset:disabled label { cursor: default; opacity: .7; }

.verdict { border-left: 4px solid var(--line); padding: .5rem .9rem; margin: 0 0 1rem; background: var(--bg); }
.verdict.ok { border-left-color: var(--accent); }
.verdict p { margin: 0; }
.verdict .title { font-weight: 700; }
.verdict:empty { display: none; }
.readout { font-size: 1.25rem; font-variant-numeric: tabular-nums; margin: 0 0 .5rem; }
.readout span { display: inline-block; min-width: 6.5rem; font-weight: 700; }
.hint { font-size: .95rem; color: var(--muted); }
.tone-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 0 0 1rem; }
.notice { border: 1px solid var(--line); border-radius: 6px; padding: .6rem .8rem; }

.playing-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--surface); border-top: 2px solid var(--accent);
  padding: .5rem 1rem calc(.5rem + env(safe-area-inset-bottom));
}
.playing-bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0; }
.playing-bar[hidden] { display: none; }
.playing-bar .btn { flex: none; white-space: nowrap; }

/* Content */
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { border-bottom: 1px solid var(--line); padding: .5rem .5rem .5rem 0; text-align: left; vertical-align: top; }
th { font-weight: 600; }
.table-wrap { overflow-x: auto; }
dt { font-weight: 600; margin-top: .75rem; }
dd { margin: 0 0 .5rem; }
.site-footer { border-top: 1px solid var(--line); margin-top: 3rem; padding: 1rem 0 5rem; color: var(--muted); font-size: .95rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-bottom: .5rem; }

@media (min-width: 40rem) {
  h1 { font-size: 2rem; margin-top: 1.25rem; }
  .tool { padding: 1.25rem; }
  .tabs [role="tab"] { padding: .4rem .9rem; }
  .tone-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  .side { transition: background-color .15s, border-color .15s; }
}
