:root {
  --nav: #1f2937;
  --nav-hover: #4b5563;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --page: #ffffff;
  --band: #f9fafb;
  --red: #d14836;
  --red-hover: #b91c1c;
  --red-soft: #fdf2f0;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06);
  --radius: 6px;
  color-scheme: light;
  font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--page);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.875rem; line-height: 2.25rem; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1rem; line-height: 1.5rem; font-weight: 600; }
h3 { font-size: 0.95rem; margin-bottom: 0.4rem; }

.skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: #fff;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  z-index: 1000;
}
.skip:focus { left: 0.5rem; }

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: 48px;
  background: #1f2937;
  z-index: 40;
  color: #d1d5db;
}
.nav-inner {
  max-width: 72rem;
  margin: 0 auto;
  height: 100%;
  padding: 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.35rem 0.45rem;
  border-radius: var(--radius);
}
.brand:hover { background: var(--nav-hover); }
.mark { width: 22px; height: 12px; display: block; }
.nav-links { display: flex; gap: 0.25rem; margin-left: 0.75rem; }
.nav-links a {
  color: #d1d5db;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
}
.nav-links a:hover, .nav-links a[aria-current="page"] { background: var(--nav-hover); color: #fff; }
.nav-toggle {
  display: none;
  margin-left: auto;
  background: transparent;
  color: #e5e7eb;
  border: 0;
  border-radius: var(--radius);
  padding: 0.35rem 0.6rem;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 4.25rem 1rem 4rem;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.lede, .muted, .summary, .hint, .detail, .crumb { color: var(--muted); }
.lede { margin-top: 0.35rem; font-size: 0.95rem; }
.crumb { font-size: 0.85rem; margin-bottom: 0.35rem; }
.crumb a { color: var(--red); text-decoration: none; font-weight: 600; }
.crumb a:hover { text-decoration: underline; }

#result, #help, .job { scroll-margin-top: 56px; }
.job {
  position: sticky;
  top: 56px;
  z-index: 20;
  margin-bottom: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0.85rem 1.15rem 0.95rem;
}
.job-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
#job-title { font-weight: 700; font-size: 1.05rem; }
#job-percent { color: var(--red); font-weight: 700; font-variant-numeric: tabular-nums; }
.job-track { height: 10px; margin-top: 0.6rem; background: #f3f4f6; border-radius: 999px; overflow: hidden; }
#job-bar { height: 100%; width: 0; background: var(--red); border-radius: inherit; transition: width 0.2s linear; }
#job-bar.is-indeterminate { width: 38%; animation: job-slide 1.1s ease-in-out infinite; }
.job-detail { margin-top: 0.45rem; color: var(--muted); font-size: 0.85rem; }
@keyframes job-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--line);
}
.summary { font-size: 0.85rem; text-align: right; max-width: 40rem; }
.card-body { padding: 1rem 1.15rem 1.15rem; }

.btn-primary, .btn-white, .btn-s {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25rem;
  padding: 0.5rem 1rem;
  text-decoration: none;
}
.btn-primary { background: var(--red); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover:not(:disabled) { background: var(--red-hover); }
.btn-white { background: #fff; color: var(--text); border-color: var(--line-strong); }
.btn-white:hover:not(:disabled) { background: var(--band); }
.btn-s { padding: 0.35rem 0.7rem; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, .preset:focus-within {
  outline: 2px solid #374151;
  outline-offset: 2px;
}

.dropzone {
  position: relative;
  min-height: 220px;
  border: 3px dashed #111827;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1.5rem 1rem;
  text-align: center;
  background: #fff;
}
.dropzone.is-over { background: var(--band); }
.dropzone.has-file { min-height: 0; border-style: solid; border-width: 1px; border-color: var(--line-strong); }
.drop-label { font-size: 1.05rem; font-weight: 600; }
.or { color: var(--muted); font-size: 0.8rem; }
#file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.dropzone.has-file #file-input,
.dropzone.has-file .drop-label,
.dropzone.has-file .or { display: none; }
.dropzone .btn-white,
.text-btn { position: relative; z-index: 2; }
.text-btn {
  background: none;
  border: 0;
  color: var(--red);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0;
}
.text-btn:hover { text-decoration: underline; }
.file-chip { font-size: 0.95rem; font-weight: 600; }
.alert {
  margin-top: 0.8rem;
  background: #fef2f2;
  color: #991b1b;
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.preset {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  background: #fff;
}
.preset input { position: absolute; opacity: 0; pointer-events: none; }
.preset.is-selected { border-color: var(--red); background: var(--red-soft); box-shadow: inset 0 0 0 1px var(--red); }
.preset-title { font-weight: 600; font-size: 0.92rem; }
.preset-desc { color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.template-label { margin: 0.9rem 0 0.45rem; }
#neural-engines { margin-top: 0.65rem; }
.voice-box { margin-top: 0.85rem; }
.voice-box > .preset-desc { display: block; margin-top: 0.2rem; }
.voice-box .leveler { margin-top: 0.65rem; }
.leveler {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-top: 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  cursor: pointer;
}
.leveler.is-on { border-color: var(--red); background: var(--red-soft); box-shadow: inset 0 0 0 1px var(--red); }
.leveler input { width: 1.05rem; height: 1.05rem; margin-top: 0.15rem; accent-color: var(--red); flex: none; }
.leveler span { display: flex; flex-direction: column; gap: 0.2rem; }
.detail { margin-top: 0.85rem; font-size: 0.9rem; }
.form-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.hint { font-size: 0.82rem; }
.hint.is-dirty { color: var(--red); font-weight: 600; }

.editor-body { padding-top: 0; }
.transport {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.7rem 0 0.8rem;
  position: sticky;
  top: 48px;
  background: #fff;
  z-index: 5;
}
.play {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 0;
  background: var(--nav);
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
}
.play svg { width: 16px; height: 16px; fill: currentColor; }
.play:hover:not(:disabled) { background: #111827; }
.time { font-variant-numeric: tabular-nums; font-size: 0.85rem; min-width: 9.2rem; }
.listen, .zoom { display: flex; }
.listen button, .zoom button {
  background: #fff;
  border: 1px solid var(--line-strong);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
}
.listen button:first-child, .zoom button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.listen button:last-child, .zoom button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.listen button + button, .zoom button + button { margin-left: -1px; }
.listen button.is-active { background: var(--red-soft); color: var(--red); border-color: #e7b2aa; position: relative; }
.zoom { margin-left: auto; }
.tracks { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.track { display: grid; grid-template-columns: 7.2rem 1fr; }
.track + .track { border-top: 1px solid var(--line); }
.track-label {
  display: flex;
  align-items: center;
  padding: 0 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #4b5563;
  background: var(--band);
  border-right: 1px solid var(--line);
}
.track.is-hot .track-label { color: var(--red); }
.wave-wrap { position: relative; height: 96px; background: #fff; }
canvas { width: 100%; height: 96px; display: block; cursor: ew-resize; }
.wave-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  pointer-events: none;
}
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--red);
  pointer-events: none;
}
.stats-grid {
  display: grid;
  grid-template-columns: 16rem 1fr;
  gap: 0.8rem;
  margin-top: 0.9rem;
}
.stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.stats caption {
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  padding-bottom: 0.35rem;
}
.stats th, .stats td {
  text-align: left;
  padding: 0.4rem 0.45rem;
  border-top: 1px solid var(--line);
  font-weight: 500;
}
.stats th { color: #4b5563; font-weight: 600; }
.stats thead th { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.help ol, .help ul { margin: 0.2rem 0 0.8rem; padding-left: 1.15rem; }
.help li { margin: 0.28rem 0; font-size: 0.92rem; }
.help h3 { margin-top: 0.4rem; }

.empty { padding: 2rem 1.2rem; text-align: center; }
.empty .muted { margin-top: 0.3rem; font-size: 0.9rem; }
.table-wrap { overflow-x: auto; }
.prod-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.prod-table th, .prod-table td { text-align: left; padding: 0.75rem 1rem; border-top: 1px solid var(--line); }
.prod-table th { font-size: 0.75rem; color: var(--muted); font-weight: 600; border-top: 0; }
.prod-table tbody tr { cursor: pointer; }
.prod-table tbody tr:hover { background: var(--band); }
.badge {
  display: inline-flex;
  background: #f0fdf4;
  color: #166534;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
}
.delta-good { color: #166534; font-weight: 600; }

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    background: var(--nav);
    flex-direction: column;
    padding: 0.4rem;
    margin: 0;
  }
  .nav-links.is-open { display: flex; }
  .page-head { flex-direction: column; align-items: stretch; }
  .card-head { flex-direction: column; align-items: flex-start; }
  .summary { text-align: left; }
  .preset-grid, .stats-grid, .track { grid-template-columns: 1fr; }
  .track-label { border-right: 0; border-bottom: 1px solid var(--line); padding: 0.35rem 0.7rem; }
  .zoom { margin-left: 0; }
  h1 { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
