:root {
  --bg: #ffffff;
  --bg-subtle: #fbfbfa;
  --raise: #ffffff;
  --text: #17181a;
  --muted: #6b6f76;
  --faint: #9aa0a6;
  --border: #ececed;
  --border-strong: #dcdcde;
  --accent: #5e6ad2;
  --accent-hover: #515dc8;
  --accent-subtle: rgba(94, 106, 210, 0.10);
  --on-accent: #ffffff;
  --danger: #d1544e;
  --radius: 7px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0e;
    --bg-subtle: #111214;
    --raise: #16171a;
    --text: #f2f3f4;
    --muted: #8a8f98;
    --faint: #5c6067;
    --border: #232428;
    --border-strong: #33353b;
    --accent: #7c89f5;
    --accent-hover: #8b97f7;
    --accent-subtle: rgba(124, 137, 245, 0.14);
    --on-accent: #0b0c0e;
    --danger: #e2685f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.55 "Inter", ui-sans-serif, system-ui, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; letter-spacing: 0; }
h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
button, textarea, input { font-family: inherit; }
button { cursor: pointer; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.shell { max-width: 540px; margin: 0 auto; padding: 22px 24px 80px; min-height: 100vh; }

.brand {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  letter-spacing: -0.01em; margin-bottom: 22px;
}

.prog { display: flex; align-items: center; gap: 8px; margin-bottom: 40px; }
.prog .seg { height: 2px; flex: 1; border-radius: 1px; background: var(--border); transition: background 0.2s; }
.prog .seg.done, .prog .seg.now { background: var(--accent); }
.prog .txt { font-size: 12px; color: var(--faint); white-space: nowrap; font-weight: 500; }

.err {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border));
  border-radius: 7px; padding: 10px 12px; font-size: 13px; margin-bottom: 20px;
}

.step { display: none; }
.step.active { display: block; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0.4; } to { opacity: 1; } }

.head { margin-bottom: 26px; }
.head h1 { margin-bottom: 5px; }
.head p { margin: 0; color: var(--muted); font-size: 13.5px; }

.row-actions { display: flex; align-items: center; gap: 6px; margin-top: 34px; }
.row-actions .spacer { flex: 1; }
.btn {
  border: 0; border-radius: var(--radius);
  padding: 8px 15px; font-size: 13px; font-weight: 500;
  background: var(--accent); color: var(--on-accent);
  transition: background 0.12s, opacity 0.12s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--accent-hover); }
.btn:not(.ghost)::after { content: "→"; font-size: 12px; line-height: 1; }
.btn.ghost { background: transparent; color: var(--muted); padding: 8px 10px; }
.btn.ghost:hover { background: var(--bg-subtle); color: var(--text); }
.btn.ghost::after { content: none; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.busy::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }

/* 1 · upload */
.drop {
  width: 100%; display: flex; flex-direction: column; align-items: center;
  border: 1px dashed var(--border-strong); border-radius: 10px;
  padding: 40px 24px; text-align: center; background: var(--bg-subtle);
  color: var(--text); transition: border-color 0.12s, background 0.12s;
}
.drop:hover, .drop.drag { border-color: var(--accent); background: var(--accent-subtle); }
.drop svg { color: var(--faint); margin-bottom: 12px; }
.drop .t { font-size: 14px; font-weight: 500; }
.drop .s { font-size: 12.5px; color: var(--faint); margin-top: 4px; }

.uprog { margin-top: 16px; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.uprog-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.uprog-bar i { display: block; height: 100%; width: 10%; background: var(--accent); transition: width 0.2s; }

.textlink { background: none; border: 0; padding: 0; color: var(--accent); font-size: 12.5px; margin-top: 14px; display: inline-block; }
.textlink:hover { text-decoration: underline; }
.listbox { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.listbox textarea, .listbox input {
  background: var(--raise); border: 1px solid var(--border); border-radius: 7px;
  padding: 9px 11px; font-size: 13px; color: var(--text); resize: vertical;
}
.listrow { display: flex; gap: 8px; }
.listrow input { flex: 1; }

/* 2 · density */
.opts { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.opt {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px; background: var(--raise); border: 0; width: 100%; text-align: left;
  border-bottom: 1px solid var(--border);
}
.opt:last-child { border-bottom: 0; }
.opt:hover { background: var(--bg-subtle); }
.opt[aria-checked="true"] { background: var(--accent-subtle); }
.opt .radio { width: 15px; height: 15px; border-radius: 50%; flex: none; border: 1.5px solid var(--border-strong); position: relative; }
.opt[aria-checked="true"] .radio { border-color: var(--accent); }
.opt[aria-checked="true"] .radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.opt .label { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.opt .label .n { font-size: 13.5px; font-weight: 500; }
.opt .label .d { font-size: 12px; color: var(--muted); }
.opt .meta { font-size: 11.5px; color: var(--faint); font-family: "JetBrains Mono", monospace; white-space: nowrap; }

/* 3 · cuesheet */
.cs-meta { font-size: 12.5px; color: var(--faint); margin-bottom: 4px; }
.cs-list { margin: 0 -6px; }
.cs-row {
  display: flex; align-items: baseline; gap: 12px;
  padding: 9px 6px; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.cs-row:last-child { border-bottom: 0; }
.cs-row .tm { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--faint); width: 34px; flex: none; }
.cs-row .sit { color: var(--text); flex: 1; min-width: 0; }
.cs-row .snd { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.cs-row.tex { opacity: 0.62; }
.cs-row.tex .sit { font-size: 12.5px; }

/* 4 · generating */
.gen { text-align: center; padding: 48px 0; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 16px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gen .t { font-size: 14px; font-weight: 500; }
.gen .s { font-size: 12px; color: var(--faint); margin-top: 4px; }

/* 5 · done */
.preview { display: flex; gap: 18px; align-items: flex-start; }
@media (max-width: 460px) { .preview { flex-direction: column; } }
.frame {
  width: 132px; flex: none; aspect-ratio: 9 / 16;
  border-radius: 8px; border: 1px solid var(--border); background: #000;
  object-fit: cover;
}
.preview .side { flex: 1; min-width: 0; padding-top: 2px; }
.verdict { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.dl { display: flex; flex-direction: column; gap: 2px; }
.dlbtn {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 11px 2px; font-size: 13px; color: var(--text); font-weight: 500;
  text-decoration: none;
}
.dlbtn:hover { color: var(--accent); }
.dlbtn .x { color: var(--faint); font-family: "JetBrains Mono", monospace; font-size: 11px; font-weight: 400; }
.dlbtn:hover .x { color: var(--accent); }
.hint { margin-top: 16px; font-size: 12px; color: var(--faint); }
