:root {
  --bg: #f7f4ef;
  --paper: #fffefb;
  --surface: #f1ede6;
  --ink: #1b1e24;
  --muted: #585f6a;
  --line: #e4ded3;
  --line-strong: #c9c0b1;
  --accent: #3247c9;
  --accent-ink: #ffffff;
  --accent-soft: #e9ecfb;
  --ok: #1d7a4a;
  --warn: #8a5300;
  --fail: #b42318;
  --focus: #b25e00;
  --wave-bg: #15171c;
  --wave-grid: #272b33;
  --wave-dim: #5d6573;
  --wave-sel: #a8b8ff;
  --wave-text: #a3abb8;
  --wave-head: #ffffff;
  --clip: #ff6b5e;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(27, 30, 36, 0.06), 0 8px 24px rgba(27, 30, 36, 0.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --paper: #191c21; --surface: #20242a; --ink: #eceef2; --muted: #a5acb7; --line: #2b3038; --line-strong: #464d58;
    --accent: #93a6ff; --accent-ink: #0e1530; --accent-soft: #222a45; --ok: #6fd39a; --warn: #f2c35c; --fail: #ff8a80; --focus: #f0a640;
    --wave-bg: #0b0c0f; --wave-grid: #22262d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Hiragino Sans", "Yu Gothic UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK KR", "Noto Sans CJK JP", "Noto Sans CJK SC", sans-serif;
  font-feature-settings: "tnum" 1;
}
:lang(ja) body, body:lang(ja) { font-family: system-ui, "Hiragino Sans", "Yu Gothic UI", "Noto Sans CJK JP", sans-serif; }
:lang(zh-Hans) body, body:lang(zh-Hans) { font-family: system-ui, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.6rem); font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }
h1:focus { outline: none; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); color: var(--ink); padding: 10px 14px; border-radius: 8px; z-index: 30; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.lead { font-size: 1.125rem; color: var(--muted); max-width: 40em; }
.fine { color: var(--muted); font-size: 0.9rem; }
.mini-title { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; padding: 0; }
.panel-title { font-size: 1.05rem; font-weight: 700; padding: 0; margin: 0 0 12px; }
.error-text { color: var(--fail); font-weight: 600; margin: 6px 0 0; }
.error-text:empty { display: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; word-break: break-all; }

/* ---------- header / footer ---------- */
.topbar { display: flex; align-items: center; gap: 8px 20px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--paper); flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; color: var(--ink); text-decoration: none; min-height: 44px; margin-right: auto; }
.brand-mark { width: 30px; height: 22px; flex: none; border-radius: 6px; background:
  linear-gradient(var(--accent), var(--accent)) 5px 50% / 3px 40% no-repeat,
  linear-gradient(var(--accent), var(--accent)) 10px 50% / 3px 80% no-repeat,
  linear-gradient(var(--accent), var(--accent)) 15px 50% / 3px 55% no-repeat,
  linear-gradient(var(--accent), var(--accent)) 20px 50% / 3px 95% no-repeat,
  var(--accent-soft); }
.mainnav, .langnav { display: flex; flex-wrap: wrap; gap: 2px; }
.mainnav a, .langnav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.mainnav a:hover, .langnav a:hover { color: var(--ink); background: var(--surface); }
.mainnav a[aria-current="page"] { color: var(--ink); font-weight: 650; }
.langnav { border-left: 1px solid var(--line); padding-left: 10px; }
.langnav a[aria-current="true"] { color: var(--accent); font-weight: 700; }
.foot { max-width: 1200px; margin: 0 auto; padding: 24px; color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.foot a { color: inherit; display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
.foot .credit a { display: inline; min-height: 0; padding: 0; text-decoration: underline; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  font: inherit; font-weight: 600; font-size: 0.95rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); cursor: pointer; text-decoration: none; text-align: center; line-height: 1.2;
}
.btn:hover { background: var(--surface); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-accent { border-color: var(--accent); color: var(--accent); }
.btn-outline { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-big { min-height: 52px; padding: 0 22px; font-size: 1.02rem; border-radius: 12px; }
.btn-block { width: 100%; }
.nudge { min-width: 44px; padding: 0 8px; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
select, input { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 8px 12px; min-height: 44px; }
input[aria-invalid="true"] { border-color: var(--fail); box-shadow: 0 0 0 1px var(--fail); }
input[type="range"] { accent-color: var(--accent); padding: 0; border: 0; background: transparent; }
input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; min-height: 0; margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { display: grid; gap: 4px; margin: 12px 0 0; font-weight: 600; font-size: 0.95rem; }
.field > span, .field > label { font-weight: 600; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); font-size: 0.8rem; font-weight: 650; }
.pill:empty { display: none; }
.badge { display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); font-size: 0.85rem; font-weight: 600; }
.badge[hidden] { display: none; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }

/* ---------- screens ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 24px 24px 48px; outline: none; }
.screen[hidden] { display: none !important; }

/* start / home */
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 40px; align-items: center; padding: 24px 0 16px; }
.hero-text { display: grid; gap: 18px; }
.drop { padding: 20px; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--paper); display: grid; gap: 10px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.drop-hint { color: var(--muted); font-size: 0.9rem; }
.support { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink); font-size: 0.95rem; }
.support li { display: flex; align-items: center; gap: 8px; }
.support li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.hero-figure { margin: 0; display: grid; gap: 8px; }
.hero-figure figcaption { color: var(--muted); font-size: 0.88rem; text-align: center; }
.example { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.example-badge { position: absolute; top: 14px; right: 14px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 1px 10px; }
.example-name { font-weight: 650; padding-right: 72px; }
.example-wave { background: var(--wave-bg); border-radius: 10px; padding: 10px; }
.example-wave svg { display: block; width: 100%; height: auto; }
.example-wave rect { fill: var(--wave-dim); }
.example-wave rect.in { fill: var(--wave-sel); }
.example-wave rect.sel { fill: var(--wave-sel); opacity: 0.12; }
.example-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.95rem; }
.example-rows li { display: flex; gap: 8px; align-items: baseline; }
.example-rows li::before { content: "•"; color: var(--muted); }
.example-rows li.ok::before { content: "✓"; color: var(--ok); font-weight: 700; }
.scope { margin-top: 8px; }
body.started .landing, body.started .hero-figure, body.started .scope { display: none; }
body.started .hero { grid-template-columns: minmax(0, 1fr); }

.landing { display: grid; gap: 8px; margin-top: 24px; }
.band { padding: 36px 0; border-top: 1px solid var(--line); display: grid; gap: 16px; }
.band.two { grid-template-columns: 1fr 1fr; gap: 40px; }
.band.two > section { display: grid; gap: 12px; align-content: start; }
.how { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.how li { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 8px; align-content: start; }
.step-no { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 750; }
.how p { color: var(--muted); }
.uses { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.faq { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 32px; }
.qa dt { font-weight: 650; }
.qa dd { margin: 4px 0 0; color: var(--muted); }
.link-arrow { display: inline-flex; align-items: center; min-height: 44px; font-weight: 650; }
.link-arrow::after { content: " →"; }

/* loading / error */
.loading-box, .error-box { max-width: 560px; margin: 48px auto; display: grid; gap: 16px; justify-items: start; }
.loading-box { justify-items: center; text-align: center; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-big { font-size: 1.15rem; font-weight: 600; }

/* steps */
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 0.9rem; color: var(--muted); counter-reset: st; }
.steps li { display: flex; align-items: center; gap: 8px; counter-increment: st; }
.steps li::before { content: counter(st); width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; border: 1px solid var(--line-strong); font-size: 0.8rem; font-weight: 700; }
.steps li.done::before { content: "✓"; background: var(--surface); }
.steps li[aria-current="step"] { color: var(--ink); font-weight: 650; }
.steps li[aria-current="step"]::before { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- work ---------- */
.filebar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.file-id { min-width: 0; }
#work-title { font-size: 1.4rem; word-break: break-word; }
.file-info { color: var(--muted); margin-top: 2px; }
.work-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.work-main { display: grid; gap: 20px; min-width: 0; }
.bench { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.wave-panel { background: var(--wave-bg); border-radius: 12px; padding: 8px 10px 10px; }
.wave-wrap { position: relative; height: 220px; touch-action: none; user-select: none; cursor: crosshair; }
#wave { display: block; width: 100%; height: 100%; }
.sel-shade { position: absolute; top: 20px; bottom: 0; background: rgba(168, 184, 255, 0.10); border-left: 1px solid var(--wave-sel); border-right: 1px solid var(--wave-sel); pointer-events: none; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--wave-head); pointer-events: none; }
.handle { position: absolute; top: 20px; bottom: 0; width: 28px; margin-left: -14px; cursor: ew-resize; touch-action: none; }
.handle::before { content: ""; position: absolute; left: 12px; top: 0; bottom: 0; width: 4px; border-radius: 2px; background: var(--wave-sel); }
.handle::after { content: ""; position: absolute; left: 5px; top: 50%; width: 18px; height: 34px; margin-top: -17px; border-radius: 6px; background: var(--wave-sel); box-shadow: 0 0 0 2px var(--wave-bg); }
.handle:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-radius: 6px; }

.sel-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px 16px; align-items: end; }
.sel-row > legend { grid-column: 1 / -1; float: left; width: 100%; }
.sel-row > p { grid-column: 1 / -1; }
.time-field { display: grid; gap: 4px; min-width: 0; }
.time-field label { font-weight: 600; font-size: 0.95rem; }
.time-ctl { display: flex; gap: 4px; align-items: stretch; }
.time-ctl input { flex: 1 1 5em; min-width: 4.5em; width: 100%; text-align: center; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.sel-length { display: grid; justify-items: center; padding: 0 8px 4px; text-align: center; }
.sel-length span { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.sel-length strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sel-summary { margin: 0; }

.listen { display: grid; gap: 8px; }
.listen-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.more { border-top: 1px solid var(--line); padding-top: 8px; }
.more summary, .cond summary, .result-details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: 8px; list-style-position: inside; }
.more-body { display: grid; gap: 12px; padding: 8px 0 4px; }
.tap-mode { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.tap-mode legend { float: left; margin-right: 8px; font-weight: 600; font-size: 0.95rem; }
.tap-mode label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px; }

/* volume */
.gain .gain-row { display: flex; align-items: center; gap: 8px; }
.gain-row input[type="range"] { flex: 1; min-width: 160px; min-height: 44px; }
#gain-value { min-width: 5.5em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter { margin: 12px 0 8px; display: grid; gap: 4px; }
.meter-label { font-size: 0.85rem; color: var(--muted); }
.meter-track { position: relative; height: 10px; border-radius: 6px; background: var(--surface); overflow: visible; border: 1px solid var(--line); }
.meter-fill { height: 100%; width: 0; border-radius: 6px; background: var(--ok); }
.meter-fill[data-level="warn"] { background: var(--warn); }
.meter-fill[data-level="block"] { background: var(--fail); }
.meter-limit { position: absolute; right: 0; top: 12px; font-size: 0.75rem; color: var(--muted); }
.status { margin: 14px 0 12px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--surface); }
.status:empty { display: none; }
.status[data-level="warn"] { background: color-mix(in srgb, var(--warn) 14%, var(--paper)); border-left: 4px solid var(--warn); }
.status[data-level="block"] { background: color-mix(in srgb, var(--fail) 12%, var(--paper)); border-left: 4px solid var(--fail); }

/* save panel */
.work-side { position: sticky; top: 16px; }
.save { display: grid; gap: 10px; }
.save > legend { float: left; width: 100%; }
.format-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); cursor: pointer; min-height: 44px; }
.choice input { margin-top: 3px; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice-text { display: grid; gap: 2px; }
.choice-text small { color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.field[hidden], #kbps-field[hidden] { display: none; }
.notice { padding: 8px 12px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--warn) 14%, var(--paper)); border-left: 4px solid var(--warn); color: var(--ink); font-size: 0.9rem; }
.notice[hidden] { display: none; }
.cond { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0 12px 12px; }
.cond[open] { background: var(--bg); }
.size-row { display: flex; gap: 8px; }
.size-row input { flex: 1; min-width: 0; }
.size-row select { flex: 0 0 auto; }
.estimate-box { background: var(--surface); border-radius: var(--radius-s); padding: 12px; display: grid; gap: 6px; }
.estimate-box:has(#estimate:empty) { display: none; }
.estimate { font-weight: 600; }
.gauges { display: grid; gap: 8px; }
.gauges:empty { display: none; }
.gauge { display: grid; gap: 3px; font-size: 0.88rem; }
.gauge-track { height: 8px; border-radius: 6px; background: var(--paper); border: 1px solid var(--line); overflow: hidden; }
.gauge-fill { height: 100%; background: var(--ok); }
.gauge-fill[data-level="fail"] { background: var(--fail); }
.blockers { display: grid; gap: 6px; margin: 0; padding: 0; outline-offset: 2px; }
.blockers:empty { display: none; }
.blocker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--fail) 10%, var(--paper)); border-left: 4px solid var(--fail); font-size: 0.92rem; }
.blocker > span { flex: 1 1 12em; }
.blocker .btn { min-height: 36px; padding: 0 10px; font-size: 0.85rem; }
.blocker.info { background: var(--surface); border-left-color: var(--line-strong); }
.progress { display: grid; gap: 8px; }
.progress[hidden] { display: none; }
.progress progress { width: 100%; height: 10px; accent-color: var(--accent); }
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.92rem; color: var(--muted); }
.stages li { display: flex; align-items: center; gap: 8px; }
.stages li::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; }
.stages li[data-state="active"] { color: var(--ink); font-weight: 650; }
.stages li[data-state="active"]::before { border-color: var(--accent); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.stages li[data-state="done"]::before { content: "✓"; border: 0; color: var(--ok); font-weight: 800; width: 14px; text-align: center; line-height: 14px; }

/* narrow-screen action bar */
.action-bar { display: none; }

/* ---------- result ---------- */
#result-title { margin-bottom: 6px; }
.verdict { font-size: 1.05rem; margin-bottom: 18px; padding: 10px 14px; border-radius: var(--radius-s); border-left: 4px solid var(--line-strong); background: var(--surface); }
.verdict[data-level="ok"] { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--paper)); }
.verdict[data-level="warn"] { border-left-color: var(--fail); background: color-mix(in srgb, var(--fail) 9%, var(--paper)); }
.result-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 20px; align-items: start; }
.final-card { display: grid; gap: 12px; }
.final-name { font-size: 1.15rem; font-weight: 700; word-break: break-word; }
.final-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.final-facts > div { background: var(--surface); border-radius: var(--radius-s); padding: 10px 12px; min-width: 0; }
.final-facts dt { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.final-facts dd { margin: 2px 0 0; font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; word-break: break-word; }
.final-facts dd small { display: block; font-size: 0.8rem; font-weight: 500; color: var(--muted); }
#result-audio { width: 100%; }
.status-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.9rem; }
.status-list li { display: flex; gap: 8px; align-items: baseline; }
.status-list li::before { content: "✓"; color: var(--ok); font-weight: 800; }
.status-list li[data-state="todo"]::before { content: "○"; color: var(--muted); }
.result-side { display: grid; gap: 16px; align-content: start; }
.cond-card { display: grid; gap: 8px; }
.result-actions { display: grid; gap: 8px; }
.result-actions .btn { justify-content: flex-start; }
.result-details { margin-top: 20px; }
.result-details[open] { display: grid; gap: 12px; }
.disclaimer { margin-top: 16px; }
.facts-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.facts-table caption { text-align: left; font-weight: 650; padding: 8px 0; }
.facts-table th, .facts-table td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.facts-table th { font-weight: 600; color: var(--muted); width: 38%; }
.facts-table td[data-level="fail"] { color: var(--fail); font-weight: 650; }
.facts-table td[data-level="pass"] { color: var(--ok); font-weight: 650; }

/* ---------- guide / privacy / chooser ---------- */
.doc { max-width: 1000px; display: grid; gap: 24px; }
.doc-head { display: grid; gap: 12px; padding: 16px 0 8px; }
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.prose { display: grid; gap: 10px; align-content: start; }
.prose h2 { font-size: 1.1rem; }
.prose p { color: var(--ink); }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.example-rule { display: grid; gap: 8px; align-content: start; }
.example-rule ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.example-rule .howto { list-style: none; padding: 10px 12px; background: var(--accent-soft); border-radius: var(--radius-s); }
.example-rule .howto li::before { content: "→ "; color: var(--accent); font-weight: 700; }
.src { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; word-break: break-all; }
.doc-cta { padding-top: 8px; }
.chooser { max-width: 640px; display: grid; gap: 20px; padding-top: 64px; }
.chooser h1 { display: flex; align-items: center; gap: 12px; font-size: 1.8rem; }
.langlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.langlist li { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.langlist .btn { min-width: 9em; }
.langlist span { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .work-grid, .result-grid { grid-template-columns: minmax(0, 1fr); }
  .work-side { position: static; }
  .band.two, .faq, .qa-grid, .rules-grid { grid-template-columns: minmax(0, 1fr); }
  /* Summary gets a complete row; translated buttons cannot squeeze it into a letter column.
     Reserve four summary lines and two button lines at the current text scale, plus gaps/padding. */
  .screen.work, .screen.result { padding-bottom: calc(9rem + env(safe-area-inset-bottom)); }
  .action-bar:not([hidden]) {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; align-items: stretch; gap: 8px;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.08);
  }
  .action-bar .bar-sel {
    grid-column: 1 / -1; min-width: 0; font-size: 0.875rem; line-height: 1.5;
    font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
  }
  .action-bar .btn { min-width: 0; min-height: 48px; padding: 8px 10px; white-space: normal; overflow-wrap: anywhere; }
  #bar-play { grid-column: 1; }
  #bar-save { grid-column: 2; }
  body.typing .action-bar { display: none !important; }
}
@media (max-width: 767px) {
  main { padding: 16px 16px 40px; }
  .topbar { padding: 6px 12px; gap: 0 8px; }
  .mainnav a, .langnav a { padding: 0 8px; font-size: 0.9rem; }
  .langnav { border-left: 0; padding-left: 0; }
  .how { grid-template-columns: minmax(0, 1fr); }
  .hero { padding-top: 8px; }
  .drop { padding: 14px; }
  .drop-actions .btn { flex: 1 1 100%; }
  .wave-wrap { height: 170px; }
  .sel-row { grid-template-columns: minmax(0, 1fr); }
  .sel-length { justify-items: start; padding: 0; grid-row: 2; display: flex; gap: 10px; align-items: baseline; }
  .format-row { grid-template-columns: minmax(0, 1fr); }
  .final-facts { grid-template-columns: minmax(0, 1fr); }
  .final-facts > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
  .final-facts dd { text-align: right; }
  .band { padding: 28px 0; }
  .panel { padding: 16px; }
  .bench { padding: 12px; }
}
@media (max-width: 380px) {
  .time-ctl .nudge[data-delta="-0.01"], .time-ctl .nudge[data-delta="0.01"] { display: none; }
  .gain-row input[type="range"] { min-width: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner, .stages li[data-state="active"]::before { animation: none; }
}
@media (max-width: 480px) {
  .gain .gain-row { flex-wrap: wrap; }
  .gain-row input[type="range"] { order: -1; flex-basis: 100%; }
  #gain-value { flex: 1; text-align: center; }
}
fieldset.panel > legend { float: left; width: 100%; }
fieldset.panel > legend + * { clear: both; }
@media (min-width: 1024px) and (max-height: 820px) {
  .wave-wrap { height: 180px; }
  .topbar { padding-top: 6px; padding-bottom: 6px; }
  .steps { margin-bottom: 10px; }
  .filebar { margin-bottom: 12px; }
  .bench { gap: 12px; }
}
@media (max-width: 767px) {
  .mainnav a[data-lang-href=""], .mainnav a[data-lang-href="edit/"] { display: none; }
  .brand { margin-right: 0; flex: 1 1 auto; }
  .topbar { row-gap: 0; }
  .langnav { width: 100%; justify-content: flex-start; }
  .langnav a { font-size: 0.85rem; }
}
@media (max-width: 767px) {
  .langnav { width: auto; }
  .mainnav a, .langnav a { padding: 0 6px; font-size: 0.85rem; }
}
/* inputs never force their containers wider than the screen */
.field, .size-row, .cond, .save, .work-side { min-width: 0; }
.field input, .field select { width: 100%; min-width: 0; }
.size-row input { width: 0; flex: 1 1 0; min-width: 0; }
.size-row select { width: auto; }
.wave-panel .tap-mode { color: var(--wave-text); font-size: 0.85rem; padding-top: 4px; }
.wave-panel .tap-mode legend { font-weight: 600; font-size: 0.85rem; color: var(--wave-text); }
.wave-panel .tap-mode label { color: #e6e9ef; }
.from-play .btn { min-height: 40px; font-size: 0.88rem; font-weight: 500; }
#mp3-note[hidden] { display: none; }
@media (pointer: coarse) { .from-play .btn, .blocker .btn { min-height: 44px; } }

/* desktop save panel: quality on one line so the save button stays on a 1280x720 first screen */
@media (min-width: 1024px) {
  #bits-field:not([hidden]), #kbps-field:not([hidden]) { grid-template-columns: 1fr auto; align-items: center; margin-top: 4px; }
  #bits-field select, #kbps-field select { width: auto; min-width: 8em; }
  .save { gap: 8px; }
  .save .panel-title { margin-bottom: 8px; }
  .choice { padding: 8px 10px; }
}
@media (min-width: 1024px) and (max-height: 820px) {
  .panel.save { padding: 16px; }
  .estimate-box { padding: 10px 12px; }
}
/* phones: compact start so title, description, open, sample and limits fit the first screen */
@media (pointer: coarse) { .drop-hint { display: none; } }
@media (max-width: 480px) {
  .topbar { padding: 4px 10px; }
  .brand { min-height: 40px; font-size: 0.95rem; }
  .home h1 { font-size: 1.5rem; }
  .home .lead { font-size: 1rem; line-height: 1.5; }
  .hero { gap: 16px; }
  .hero-text { gap: 12px; }
  .drop { padding: 10px; border-width: 1px; }
  .drop-actions { gap: 8px; }
  .drop-actions .btn-big { min-height: 48px; }
  .support { font-size: 0.9rem; gap: 2px 12px; }
  .fine { font-size: 0.85rem; }
}
/* touch targets (0.5.0 layout rule: 44x44 on touch screens) */
.brand { min-height: 44px !important; }
.foot a, .mainnav a, .langnav a { min-width: 44px; justify-content: center; }
.handle { width: 44px; margin-left: -22px; }
.handle::before { left: 20px; }
.handle::after { left: 13px; }
.from-play .btn { min-height: 44px; }
audio:focus-visible, audio:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.pill { white-space: nowrap; }
@media (max-width: 1023px) { .langnav { border-left: 0; padding-left: 0; } }
@media (max-width: 767px) { .wave-panel .tap-mode legend { width: 100%; } }
@media (max-width: 360px) {
  .home h1 { font-size: 1.4rem; }
  .home .lead { font-size: 0.95rem; }
  .hero-text { gap: 10px; }
  main { padding-top: 12px; }
}

/* ---------- 0.5.1 ---------- */
/* The canvas never sets the size of its box: it is drawn to fill whatever width the workbench gets,
   so an open edit can shrink from desktop to phone width and grow back (no stale pixel width). */
.work-grid > *, .work-main, .bench, .wave-panel, .wave-wrap, .controls, .controls > * { min-width: 0; }
#wave { position: absolute; inset: 0; width: 100%; height: 100%; }
/* listen + volume form one row of the workbench on wide screens */
.controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1180px) { .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; } }
.gain { display: grid; gap: 6px; }
.gain > legend { float: left; width: 100%; }
.gain .meter { margin: 0; }
.gain .status { margin: 2px 0 0; padding: 6px 10px; font-size: 0.9rem; }
.gain-btns .btn { min-height: 40px; font-size: 0.88rem; font-weight: 500; }
@media (pointer: coarse), (max-width: 1023px) { .gain-btns .btn { min-height: 44px; } }
.listen { align-content: start; }
/* Korean keeps words together; headlines wrap evenly */
:lang(ko) h1, :lang(ko) h2, :lang(ko) h3, :lang(ko) .lead, :lang(ko) p, :lang(ko) li, :lang(ko) dd, :lang(ko) dt, :lang(ko) .btn { word-break: keep-all; overflow-wrap: break-word; }
.nudge, #gain-value, .sel-length strong { white-space: nowrap; }
:lang(ja) h1, :lang(zh-Hans) h1 { line-break: strict; }
h1, .doc-head h1 { text-wrap: balance; }
.unit-detail { font-size: 0.85rem; color: var(--muted); }
.unit-detail summary { cursor: pointer; display: inline-flex; align-items: center; min-height: 44px; }
.estimate-more { font-size: 0.85rem; color: var(--muted); }
.estimate-more summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
@media (pointer: coarse), (max-width: 1023px) { .estimate-more summary { min-height: 44px; } }
.diff { font-weight: 700; color: var(--fail); }
/* 0.5.2: the bitrate menu has a set width, so long "not available (would save at … Hz)" option texts
   (shown in the open menu and in "Why are some bitrates off?") never squeeze the label or push Save down */
@media (min-width: 1024px) {
  #bits-field:not([hidden]), #kbps-field:not([hidden]) { grid-template-columns: minmax(0, 1fr) 9.5em; gap: 4px 10px; }
  #bits-field select, #kbps-field select { width: 100%; min-width: 0; }
}
#kbps-why[hidden] { display: none; }
#kbps-why p { margin: 4px 0 2px; overflow-wrap: anywhere; }
@media (min-width: 1024px) and (max-height: 820px) {
  .save { gap: 6px; }
  .save .panel-title { margin-bottom: 4px; }
  .choice { padding: 6px 10px; }
  .estimate-box { gap: 2px; padding: 8px 12px; }
  .estimate-more summary { min-height: 28px; }
  #bits-field:not([hidden]), #kbps-field:not([hidden]) { margin-top: 0; }
}
