:root {
  color-scheme: dark;
  --bg: #0d1611;
  --surface: #17241c;
  --surface-raised: var(--surface-soft);
  --surface-soft: #203126;
  --border: #3c5645;
  --text: #f3f7f2;
  --muted: #bacdc0;
  --green: #a8efbc;
  --green-strong: #b9f5ca;
  --purple: #b9b5ff;
  --danger: #ffb6b0;
  --ring: #d1ffc8;
  --border-strong: #63806b;
  --purple-surface: #353452;
  --purple-border: #7973bd;
  --alert-surface: #4a322b;
  --alert-edge: #a87966;
  --recording: #b53837;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 280px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}
button, input, audio { font: inherit; }
button, a, input[type="file"] { touch-action: manipulation; }
a { color: inherit; }
button, .btn, .side-link { cursor: pointer; }
button:disabled, .btn.disabled { cursor: not-allowed; }
:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.skip-link {
  position: absolute;
  top: -80px;
  left: 12px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--green);
  color: var(--bg);
  font-weight: 700;
}
.skip-link:focus { top: 12px; }
.site-shell {
  width: min(100% - 32px, 1140px);
  margin-inline: auto;
}
.site-header { border-bottom: 1px solid var(--surface-soft); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 18px;
  font-weight: 650;
  white-space: nowrap;
}
.brand strong { color: var(--green); }
.brand-mark { width: 38px; height: 38px; color: var(--green); }
.header-note { color: var(--muted); font-size: 13px; }

.hero {
  display: grid;
  align-items: center;
  gap: 28px;
  padding-block: 48px 42px;
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 15px;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .14em;
}
.eyebrow-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 14%, transparent);
}
h1, h2, p { overflow-wrap: anywhere; }
h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2.45rem, 8vw, 4.6rem);
  font-weight: 760;
  line-height: 1.08;
  letter-spacing: -.052em;
  text-wrap: balance;
}
h1 em { color: var(--green); font-style: normal; }
.hero-lead {
  max-width: 590px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.17rem);
  line-height: 1.6;
}
.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 25px;
}
.hero-facts span {
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface);
  font-size: 13px;
  font-weight: 550;
}
.hero-art { display: none; }
.hero-art svg { display: block; width: 100%; height: auto; }
.art-caption {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .24em;
  text-align: center;
}

.tool-layout { display: grid; gap: 20px; align-items: start; }
.tool-main { min-width: 0; }
.step, .side-card {
  min-width: 0;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 16px 38px rgb(0 0 0 / 8%);
}
.step { padding: 21px; }
.step-head {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 20px;
}
.step-number, .track-index {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--green);
  font-weight: 750;
}
.step-number { width: 36px; height: 36px; font-size: 12px; letter-spacing: .06em; }
.step h2, .side-card h2 {
  margin: 0;
  font-size: clamp(1.16rem, 3vw, 1.38rem);
  line-height: 1.3;
  letter-spacing: -.02em;
}
.step-head p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.source-controls { display: grid; gap: 16px; align-items: center; }
.upload-control {
  min-width: 0;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
}
.upload-control label { display: block; margin-bottom: 10px; font-weight: 680; }
.upload-control input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  max-width: 100%;
  color: var(--text);
  font-size: 14px;
}
input[type="file"]::file-selector-button {
  min-height: 44px;
  margin-right: 12px;
  padding: 9px 14px;
  border: 0;
  border-radius: 9px;
  background: var(--green);
  color: var(--bg);
  font: inherit;
  font-weight: 720;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--green-strong); }
.upload-control p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.or-label { color: var(--muted); font-size: 13px; text-align: center; }
button, .btn, .side-link {
  min-height: 48px;
  border-radius: 10px;
  font-weight: 720;
  text-decoration: none;
}
button {
  border: 1px solid transparent;
  padding: 11px 18px;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.record-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: var(--green);
  color: var(--bg);
}
.record-button:hover:not(:disabled) { background: var(--green-strong); }
.record-button:disabled { opacity: .55; }
.record-symbol {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--recording);
}
.record-button.is-recording { background: var(--danger); }
.record-button.is-recording .record-symbol { border-radius: 2px; }
.secondary-button {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
}
.secondary-button:hover:not(:disabled) { background: var(--border); }
.secondary-button:disabled { opacity: .48; }
.status {
  min-height: 44px;
  margin-top: 17px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.status-file-base { word-break: break-all; }

/* fix7 #5: the extension (plus the last character of the name) never wraps, so ".mp3" is never split across lines. */
.status-file-ext { white-space: nowrap; }
.upload-guide {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 5px;
  min-height: 44px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.upload-guide a { display: inline-flex; align-items: center; min-height: 44px; color: var(--green); font-weight: 700; text-underline-offset: 3px; }
.row { display: grid; gap: 12px; }
.col {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
}
.track-label { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.track-label strong { min-width: 0; font-size: 14px; }
.track-index { width: 27px; height: 27px; border-radius: 8px; font-size: 12px; }
.reversed-index { border-color: var(--purple-border); background: var(--purple-surface); color: var(--purple); }
.attempt-index { border-color: var(--alert-edge); background: var(--alert-surface); color: var(--danger); }
audio { display: block; width: 100%; max-width: 100%; }
.download-step .step-head { margin-bottom: 15px; }
.result-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.quality-note { margin: 13px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.result-next { margin-top: 20px; padding: 15px 17px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.result-next p { margin: 0; color: var(--muted); line-height: 1.6; }
.result-next .result-next-title { margin-bottom: 4px; color: var(--text); font-weight: 720; }
.result-next a { display: inline-block; min-height: 44px; align-content: center; color: var(--green); text-underline-offset: 3px; }
.result-next a:hover { color: var(--green-strong); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  max-width: 100%;
  padding: 11px 18px;
  background: var(--green);
  color: var(--bg);
  line-height: 1.4;
  text-align: center;
}
.btn:hover:not(.disabled) { background: var(--green-strong); }
.btn svg { width: 20px; height: 20px; flex: 0 0 auto; }
.btn.disabled { background: var(--surface-soft); color: var(--text); opacity: .72; pointer-events: none; }
.side-card { padding: 24px; }
.side-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 17px;
  border: 1px solid var(--purple-border);
  border-radius: 14px;
  background: var(--purple-surface);
  color: var(--purple);
}
.side-icon svg { width: 28px; height: 28px; }
.side-eyebrow {
  margin: 0 0 8px;
  color: var(--purple);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: .14em;
}
.side-card p:not(.side-eyebrow) { margin: 13px 0 19px; color: var(--muted); font-size: 14px; }
.side-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--purple-border);
  color: var(--purple);
  background: var(--purple-surface);
}
.side-link:hover { background: var(--purple-surface); }
.side-link span { font-size: 20px; line-height: 1; }
.singing-step { margin-top: 8px; border-color: var(--purple-border); scroll-margin-top: 24px; }
.singing-number { border-color: var(--purple-border); background: var(--purple-surface); color: var(--purple); }
.headphone-tip {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--alert-edge);
  border-radius: 10px;
  background: var(--alert-surface);
  color: var(--danger);
  font-size: 14px;
}
.sing-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.sing-controls .record-button { width: auto; }
.singing-tracks { margin-top: 18px; }
.secondary-download { width: 100%; margin-top: 13px; }
.content-guide {
  max-width: 900px;
  margin: 72px auto 0;
  color: var(--muted);
}
.content-guide h2, .content-guide h3 { color: var(--text); line-height: 1.2; }
.content-guide h2 { margin: 42px 0 14px; font-size: clamp(1.5rem, 4vw, 2rem); letter-spacing: -.025em; }
.content-guide h3 { margin: 0 0 11px; font-size: 1.13rem; }
.content-guide p { margin: 0 0 17px; }
.content-guide strong { color: var(--text); }
.content-guide a { color: var(--green); text-underline-offset: 3px; }
.content-guide-intro h2 { margin-top: 0; }
.guide-grid { display: grid; gap: 16px; margin: 28px 0 0; padding-left: 26px; }
.guide-panel, .guide-faq {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.guide-panel p:last-child, .guide-faq p:last-child { margin-bottom: 0; }
.guide-figure { margin: 36px 0; }
/* fix7 #4: placeholder colour (close to the picture's own) so the frame is never an empty box before the image loads. */
.guide-figure img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-soft); }
.guide-figure figcaption { margin-top: 9px; font-size: 13px; }
.guide-faq h3:not(:first-child) { margin-top: 25px; }
.use-list { padding-left: 24px; }
.use-list li { margin-bottom: 17px; }
.facts-table-wrap { overflow-x: auto; margin: 28px 0 36px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.facts-table { width: 100%; border-collapse: collapse; text-align: left; }
.facts-table caption { padding: 18px 18px 8px; color: var(--text); font-size: 1.1rem; font-weight: 700; text-align: left; }
.facts-table th, .facts-table td { padding: 11px 18px; border-top: 1px solid var(--border); vertical-align: top; }
.facts-table th { width: 35%; min-width: 135px; color: var(--text); font-weight: 650; }
.author-note { margin-top: 30px !important; font-size: 14px; }
.info-page { min-height: 45vh; margin-top: 48px; }
.info-page h1 { margin: 0 0 22px; color: var(--text); font-size: clamp(2rem, 5vw, 3rem); line-height: 1.12; }
.guide-back { margin-top: 25px !important; font-weight: 700; }
.site-footer { margin-top: 52px; border-top: 1px solid var(--surface-soft); }
.site-footer .site-shell {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding-block: 26px;
  color: var(--muted);
  font-size: 13px;
}
.site-footer span:first-child { color: var(--text); font-weight: 700; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-left: -10px; }
.site-footer nav a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 10px; color: var(--green); text-underline-offset: 3px; }
.site-footer nav a:hover { color: var(--text); }
.site-footer .footer-email { display: inline-flex; align-items: center; min-height: 44px; color: var(--green); text-underline-offset: 3px; overflow-wrap: anywhere; }

@media (min-width: 680px) {
  .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(210px, .72fr); }
  .hero-art { display: block; }
  .row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-controls { grid-template-columns: minmax(0, 1fr) auto minmax(150px, .42fr); }
  .singing-tracks { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 980px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr) 292px; }
}
@media (max-width: 420px) {
  .site-shell { width: min(100% - 24px, 1140px); }
  .header-note { display: none; }
  .hero { padding-block: 38px 34px; }
  .step { padding: 16px; }
  .upload-control { padding: 13px; }
  .btn, .sing-controls > button { width: 100%; }
}
/* Mobile first screen (QA 1021 #3): upload box and Record button must fit in 375x667 without scrolling. */
@media (max-width: 520px) {
  .header-inner { min-height: 54px; }
  .brand-mark { width: 32px; height: 32px; }
  .hero { gap: 0; padding-block: 14px 12px; }
  .eyebrow { margin-bottom: 8px; font-size: 12px; }
  h1 { font-size: 1.8rem; line-height: 1.1; }
  .hero-lead { margin-top: 8px; font-size: 14px; line-height: 1.42; }
  .hero-facts { gap: 4px; margin-top: 10px; }
  .hero-facts span { padding: 2px 6px; font-size: 12px; letter-spacing: -.01em; }
  .step { padding: 12px 14px 14px; }
  .step-head { gap: 10px; margin-bottom: 10px; }
  .step-number { width: 32px; height: 32px; }
  .step-head p { font-size: 13px; line-height: 1.4; }
  .source-controls { gap: 4px; }
  .upload-control { padding: 10px 12px; }
  .upload-control label { margin-bottom: 6px; }
  .upload-control p { margin-top: 5px; font-size: 12px; line-height: 1.4; }
  .or-label { font-size: 12px; line-height: 1.1; }
  .status { margin-top: 12px; }
}
/* QA fix4: 360x640 phones - Record button must also fit in the first screen (bottom <= 640px). Only below 375px wide. */
@media (max-width: 374px) {
  .header-inner { min-height: 48px; }
  .hero { padding-block: 10px; }
  h1 { font-size: 1.7rem; }
  .hero-lead { margin-top: 6px; line-height: 1.38; }
  .hero-facts { gap: 3px; margin-top: 8px; }
  .hero-facts span { padding: 2px 5px; letter-spacing: -.02em; }
  .step-head { margin-bottom: 8px; }
  .upload-control p { line-height: 1.33; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  button { transition: none; }
}
/* A37: MP3 is the primary download (green .btn); WAV is the secondary one. */
button.btn { border: 0; }
button.btn:disabled, button.btn:disabled:hover { background: var(--surface-soft); color: var(--text); opacity: .72; }
button.btn[aria-busy="true"] { opacity: 1; cursor: progress; }
.btn.btn-secondary { border: 1px solid var(--border-strong); background: var(--surface-soft); color: var(--text); }
.btn.btn-secondary:hover:not(.disabled) { background: var(--border); }
.btn.btn-secondary.disabled { background: var(--surface-soft); color: var(--text); opacity: .48; }

/* fix7 #6: "Preparing MP3…" must stay readable (contrast >= 4.5:1): solid dark background, light text, no fade, and no
   colour transition from the green button (the old mid-transition frame was what failed). */
button.btn[aria-busy="true"], button.btn[aria-busy="true"]:disabled { background: var(--surface-soft); color: var(--text); opacity: 1; transition: none; }

/* fix7 #9: 1280x800 and other desktop screens - the whole upload box must fit in the first screen (it was 38 px below
   the fold after the fix6b copy made the intro one line longer). Desktop hero only; phones and tablets unchanged. */
@media (min-width: 980px) {
  .hero { padding-block: 30px 24px; }

  .hero-lead { max-width: 640px; margin-top: 16px; }

  .hero-facts { margin-top: 18px; }

}

/* fix7 #1: phones - after a clip is ready, the status line, the Reversed player and Download MP3 must fit on one
   screen (360x640 and 375x667). Tighter spacing in steps 01-03 only; the first screen above the status line is unchanged. */
@media (max-width: 520px) {
  .tool-main > .step { margin-bottom: 10px; }

  .upload-guide { min-height: 44px; margin-top: 2px; font-size: 13px; line-height: 1.3; }

  .row { gap: 8px; }

  .col { padding: 8px 10px 10px; border-radius: 12px; }

  .track-label { margin-bottom: 5px; }

  .track-index { width: 24px; height: 24px; }

  .download-step .step-head { margin-bottom: 8px; }

}

.clip-editor{min-width:0;margin:1.2rem 0 0;padding:1rem;border:1px solid var(--border);border-radius:14px}
.clip-editor legend{padding:0 .4rem;color:var(--green);font-weight:700}
.clip-editor p,.clip-status,.offline-save small{font-size:.88rem;color:var(--muted)}
.clip-editor p{margin:0 0 .65rem}.clip-editor:disabled canvas{opacity:.45;cursor:default}
#clipWave{display:block;width:100%;height:76px;background:var(--bg);border-radius:8px;touch-action:none;cursor:crosshair}
.clip-controls,.clip-formats,.offline-save{display:flex;align-items:end;flex-wrap:wrap;gap:.65rem;margin-top:.75rem}
.clip-controls label,.clip-formats label{display:grid;gap:.25rem;font-size:.85rem;font-weight:650;color:var(--muted)}
.clip-controls input[type=number],.clip-controls select,.clip-formats select{background:var(--bg);color:var(--text);border:1px solid var(--border-strong);border-radius:8px;min-height:44px;font:inherit;padding:.35rem .6rem;max-width:100%}
.clip-controls input[type=number]{width:6.75rem}.clip-controls .clip-check{display:flex;align-items:center;min-height:44px;gap:.4rem}
.clip-editor:disabled .clip-controls,.clip-formats:disabled{opacity:.65}.clip-status{min-height:1.4em;margin-top:.55rem}.clip-practice{border-top:1px solid var(--border);padding-top:.65rem}
.clip-formats{min-width:0;border:0;padding:0}.offline-save{align-items:center}.offline-save small{flex:1 1 15rem}
@media(max-width:420px){.clip-editor{padding:.65rem}.clip-controls{gap:.45rem}.clip-controls input[type=number]{width:5.5rem}}


  [data-batch-reverse] summary { cursor: pointer; font-size: 1.1em; }
  [data-batch-reverse] [hidden] { display: none !important; }
  [data-batch-reverse] .result-actions { margin-top: 1rem; }
  [data-batch-reverse] input[type=file] { max-width: 100%; }
  [data-batch-reverse] li { overflow-wrap: anywhere; }
