:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e232b;
  --line: #2a313b;
  --text: #e8ebef;
  --muted: #8b95a3;
  --accent: #ff7a45;
  --accent-2: #ffa47a;
  --ok: #4cc38a;
  --err: #ff5d5d;
  --paper: #ffffff;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; padding: 24px; }
button, .btn, select, input[type=number] {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 12px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: #45505e; background: #232933; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1b0f08; font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button.ghost { background: transparent; }
button.danger:hover { color: var(--err); border-color: var(--err); }
.sm { padding: 4px 10px; font-size: 13px; }
input[type=number] { width: 90px; cursor: text; }
input[type=range] { accent-color: var(--accent); }

.topbar {
  height: 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.topbar-note { color: var(--muted); font-size: 12px; }

.layout { display: grid; grid-template-columns: 300px 1fr; height: calc(100% - 52px); }
.sidebar { border-right: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.main { overflow: auto; padding: 20px 24px 60px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.grow { flex: 1; min-height: 160px; }

.drop {
  display: flex; gap: 12px; align-items: center; border: 1.5px dashed #3a4350; border-radius: 9px;
  padding: 16px 14px; cursor: pointer; transition: .15s; margin-bottom: 12px;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(255,122,69,.06); }
.drop-icon { font-size: 22px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); color: var(--accent); flex: none; }
.check { display: block; margin: 8px 0; cursor: pointer; }
.check.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }
.check input { accent-color: var(--accent); margin-right: 6px; }
.hint { display: block; color: var(--muted); font-size: 12px; margin: 2px 0 0 22px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0; }
.field .hint { margin-left: 0; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; align-self: end; }
output { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; }

.jobs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.jobs li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; border: 1px solid transparent; }
.jobs li:hover { background: var(--panel-2); }
.jobs li.active { background: var(--panel-2); border-color: var(--line); }
.jobs .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jobs .s { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.done { background: var(--ok); } .dot.error { background: var(--err); }
.dot.running, .dot.queued { background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.welcome { max-width: 720px; margin: 40px auto; }
.welcome h1 { font-size: 30px; margin-bottom: 16px; }
.steps { padding-left: 20px; line-height: 1.7; }
.steps li { margin-bottom: 6px; }

.job-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 12px; }
.progress { max-width: 640px; }
.progress-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-weight: 600; }
.bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.error { border-color: var(--err); color: #ffc9c9; white-space: pre-wrap; }

.player { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; position: sticky; top: -20px; z-index: 5; margin-bottom: 12px; }
.play { width: 40px; height: 40px; border-radius: 50%; justify-content: center; padding: 0; font-size: 15px; background: var(--accent); color: #1b0f08; border: none; }
.play:hover { background: var(--accent-2); }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 34px; }
.seek { flex: 1; min-width: 160px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 5px 10px; font-size: 12px; background: transparent; }
.seg button.on { background: var(--accent); color: #1b0f08; font-weight: 600; }
.mini { display: inline-flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 0; }
.mini input { width: 90px; }

.toolbar { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 12px; }
.settings { flex: 1; min-width: 320px; padding: 10px 14px; }
.settings summary { cursor: pointer; font-weight: 600; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 18px; margin-top: 8px; }
.downloads { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; }

.stats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px; font-size: 12px; color: var(--muted); }
.chip b { color: var(--text); font-weight: 600; }

.paper-wrap { background: var(--paper); border-radius: var(--radius); padding: 18px 10px 30px; color: #111; }
.paper { min-height: 200px; }
.legend { display: flex; justify-content: center; margin-bottom: 4px; }
.legend svg { max-width: 100%; height: auto; }

#pdf-stage { position: absolute; left: -10000px; top: 0; width: 1100px; background: #fff; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 50; box-shadow: 0 6px 30px rgba(0,0,0,.4); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .main { padding: 16px; }
}

/* tabs, youtube, genre */
.tabs { display: flex; margin-bottom: 12px; }
.tabs button { flex: 1; justify-content: center; }
.yt { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.yt input { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; }
.yt input:focus { outline: 1px solid var(--accent); }
.yt .hint { margin-left: 0; }
.genre { max-width: 760px; margin-bottom: 12px; }
.genre-sugg { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.genre-opt { display: grid; grid-template-columns: 170px 1fr 48px; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; }
.genre-opt.on { border-color: var(--accent); background: rgba(255,122,69,.1); }
.genre-opt .gbar { height: 6px; background: var(--panel); border-radius: 3px; overflow: hidden; }
.genre-opt .gbar > div { height: 100%; background: var(--accent); }
.genre-opt .pct { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.genre-row { gap: 18px; margin: 6px 0 12px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.genre audio { width: 100%; margin-bottom: 10px; }
.chip.genre-chip { color: var(--text); border-color: var(--accent); }
.badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: var(--accent); color: #1b0f08; font-weight: 600; }
.speed { padding: 2px 6px; font-size: 12px; }

/* editor */
.paper { position: relative; }
.bar-hl { position: absolute; border: 2px solid var(--accent); background: rgba(255,122,69,.10); border-radius: 4px; pointer-events: none; z-index: 2; }
body.editing .paper { cursor: pointer; }
.editor { position: fixed; left: 300px; right: 0; bottom: 0; z-index: 20; margin: 0; border-radius: 12px 12px 0 0;
  max-height: 46vh; overflow: auto; box-shadow: 0 -8px 30px rgba(0,0,0,.5); }
body.editing .main { padding-bottom: 48vh; }
@media (max-width: 860px) { .editor { left: 0; } }
.ed-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ed-head input[type=number] { width: 64px; padding: 3px 6px; }
.ed-grid-wrap { overflow-x: auto; margin-bottom: 6px; }
.ed-grid { border-collapse: collapse; font-size: 12px; }
.ed-grid th { font-weight: 600; color: var(--muted); padding: 2px 4px; text-align: left; white-space: nowrap; }
.ed-grid th.beat { text-align: center; border-left: 2px solid var(--line); }
.ed-grid th.beat select { font-size: 11px; padding: 1px 4px; margin-left: 4px; }
.ed-grid td { padding: 0; }
.ed-grid td.first { border-left: 2px solid var(--line); }
.ed-cell { width: 26px; height: 22px; display: block; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; border-radius: 3px; margin: 1px; padding: 0; font-size: 11px; line-height: 20px; text-align: center; color: #1b0f08; }
.ed-cell.down { background: #262c36; }
.ed-cell.on { background: var(--accent); border-color: var(--accent); }
.ed-cell.ghost { background: transparent; border: 2px solid var(--accent); color: var(--accent); }
.ed-cell:hover { border-color: var(--accent-2); }
.ed-grid td.name { padding-right: 8px; white-space: nowrap; color: var(--text); }
/* notation key dialog */
.keydlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; max-width: 760px; width: 95vw; }
.keydlg::backdrop { background: rgba(0,0,0,.6); }
.key-preview { background: #fff; border-radius: 8px; padding: 8px; margin: 8px 0 12px; }
.key-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.key-table td, .key-table th { padding: 4px 6px; text-align: left; font-size: 13px; }
.key-table th { color: var(--muted); font-weight: 600; }
.key-table select { width: 100%; }
.paper-wrap { position: relative; }
.ok-text { color: var(--ok); }
.err-text { color: var(--err); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-size: 20px; }
.login input { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px; }
.login button { justify-content: center; }
.topbar-note { display: flex; align-items: center; gap: 12px; }
