:root {
  color-scheme: light;
  --bg: #f5f7f8; --panel: #fff; --ink: #18212b; --muted: #586779;
  --line: #d4dce5; --accent: #2457c5; --soft: #eaf0ff; --danger: #b3121b;
  --accent-ink: #fff; --link: #2457c5; --success: #176645; --error-bg: #fff0f0;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11161c; --panel: #1a212a; --ink: #e8edf2; --muted: #a9b5c4;
  --line: #2f3a47; --accent: #5b9bff; --soft: #20334e; --danger: #ff9a91;
  --accent-ink: #07101f; --link: #8ab8ff; --success: #81d5ac; --error-bg: #3b2025;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 "Avenir Next", "Segoe UI", system-ui, sans-serif; }
button, input, select { font: inherit; }
button, .button, .file-button { cursor: pointer; }
button, .button, .file-button { display: inline-block; border: 1px solid transparent; border-radius: 8px; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-align: center; text-decoration: none; }
button.secondary { border-color: var(--line); background: var(--panel); color: var(--ink); }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
a { color: var(--link); }
.app-header { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px max(20px, calc((100% - 1000px) / 2)); border-bottom: 1px solid var(--line); background: var(--panel); }
.back { font-size: 12px; text-decoration: none; }
h1 { margin: 2px 0 0; font-size: 25px; letter-spacing: -.035em; }
.header-actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.privacy-badge { color: var(--success); font-size: 12px; font-weight: 600; }
.theme-toggle { position: relative; display: inline-block; width: 58px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); flex: none; }
.theme-icon { position: absolute; top: 6px; width: 16px; height: 16px; z-index: 1; opacity: .55; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon.sun { left: 6px; }
.theme-icon.moon { left: 34px; }
.theme-knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); transition: transform .18s ease; }
.theme-toggle[aria-checked="true"] .theme-knob { transform: translateX(28px); }
.theme-toggle[aria-checked="false"] .sun, .theme-toggle[aria-checked="true"] .moon { color: var(--accent-ink); opacity: 1; }
@media (prefers-reduced-motion: reduce) { .theme-knob { transition: none; } }
main { width: min(1000px, calc(100% - 32px)); margin: 28px auto 40px; }
.intro { margin-bottom: 24px; }
.intro h2 { font-size: clamp(24px, 4vw, 34px); margin: 0 0 8px; letter-spacing: -.035em; }
.intro p { max-width: 720px; color: var(--muted); }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 24px; margin: 16px 0; box-shadow: 0 4px 20px rgba(20,35,55,.04); }
.panel h2 { font-size: 18px; margin: 0 0 16px; }
.drop-zone { border: 2px dashed var(--line); border-radius: 10px; padding: 24px 16px; text-align: center; background: var(--bg); }
.drop-zone.over { border-color: var(--accent); background: var(--soft); }
.drop-zone p { margin: 8px 0; color: var(--muted); }
.drop-zone small { color: var(--muted); }
.drop-zone:focus-within .file-button { outline: 3px solid var(--accent); outline-offset: 3px; }
.file-info { margin-bottom: 0; font-size: 13px; overflow-wrap: anywhere; }
#status { padding: 12px 16px; border-radius: 8px; background: var(--soft); overflow-wrap: anywhere; }
#status.error { color: var(--danger); background: var(--error-bg); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .55; }
.wave-wrap { position: relative; height: 180px; background: #101d31; border-radius: 8px; overflow: hidden; }
#waveform { display: block; width: 100%; height: 180px; cursor: crosshair; }
.wave-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #b9c8de; pointer-events: none; }
.timeline { display: flex; justify-content: space-between; font-size: 12px; margin-top: 5px; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }
.selection-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.control-group label { flex-direction: row; align-items: baseline; justify-content: space-between; }
label span { font-size: 12px; font-weight: 400; color: var(--muted); }
input:not([type=range]):not([type=file]), select { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--panel); font-size: 16px; }
input[type=range] { width: 100%; margin: 14px 0 0; accent-color: var(--accent); min-height: 30px; }
.transport { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.selection-info { color: var(--muted); font-size: 13px; }
.fades { max-width: 480px; margin-top: 20px; }
.export-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.export-row label { flex: 1; min-width: 180px; }
#exportProgress { display: flex; gap: 12px; align-items: center; margin: 16px 0; }
progress { width: min(100%, 300px); }
.download { max-width: 100%; overflow-wrap: anywhere; margin-top: 12px; background: #86efac; color: #123322; }
.download:hover { background: #a7f3c3; }
.support { text-align: center; }
.support p { max-width: 700px; margin: 12px auto; color: var(--muted); }
.support .button { margin-top: 8px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 0 20px 24px; }
dialog { width: min(580px, 94vw); max-height: 90dvh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 24px; background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(10,15,20,.6); }
dialog h2 { margin-top: 0; }
dialog ol { padding-left: 22px; }
dialog li { margin: 12px 0; }
dialog p { color: var(--muted); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 600px) {
  .app-header { padding: 10px 16px; gap: 6px; }
  .header-actions { gap: 8px; }
  .privacy-badge { display: none; }
  h1 { font-size: 22px; }
  .panel { padding: 16px; }
  .selection-grid { gap: 12px; }
  .control-group label { flex-direction: column; gap: 0; }
  .transport button { flex: 1 1 140px; }
}
