:root {
  --bg: #0f0e0d; --panel: #181614; --panel2: #221f1c; --line: #302c27;
  --text: #f3eee7; --muted: #a59c90; --accent: #ffb02e; --accent-ink: #1a1200;
  --danger: #ff6b6b; --lane-a: #151311; --lane-b: #1a1815; --shadow: 0 8px 30px rgb(0 0 0 / 35%);
  --c-vocals: #ff7a9c; --c-drums: #ffb02e; --c-bass: #4cc9f0; --c-guitar: #7bd88f; --c-piano: #b794f6; --c-other: #9aa5b1;
  --radius: 14px; --ease: cubic-bezier(.2, .7, .2, 1);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans CJK", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f1e9; --panel: #fffdf9; --panel2: #efe8dc; --line: #ddd3c4;
  --text: #1c1915; --muted: #6c6357; --accent: #d98300; --accent-ink: #ffffff;
  --danger: #c93a3a; --lane-a: #fbf7f0; --lane-b: #f3ece0; --shadow: 0 8px 30px rgb(60 40 10 / 12%);
  --c-vocals: #d6366a; --c-drums: #c47a00; --c-bass: #0f8fb8; --c-guitar: #2f9e50; --c-piano: #7b4fd1; --c-other: #6b7683;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small-text { font-size: 12.5px; margin: 4px 0 10px; }

.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.song-picker { flex: 1; min-width: 0; max-width: 420px; }
.song-picker select { width: 100%; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
select, input[type="number"] { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 38px; transition: border-color .15s; }
select:hover, input[type="number"]:hover { border-color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-height: 38px; cursor: pointer; transition: background .15s, border-color .15s, transform .08s, color .15s; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.icon { padding: 0; width: 38px; display: inline-grid; place-items: center; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.icon.small { width: 30px; }
.btn.toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 650; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }

.empty { display: grid; place-items: center; min-height: 62vh; }
.drop { text-align: center; max-width: 520px; padding: 48px 32px; border: 2px dashed var(--line); border-radius: 24px; transition: border-color .2s, background .2s, transform .2s var(--ease); }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); transform: scale(1.01); }
.drop h1 { font-size: 28px; letter-spacing: -.02em; margin: 14px 0 8px; }
.drop p { color: var(--muted); margin: 0 0 22px; }
.drop .hint { margin: 18px 0 0; font-size: 13px; }
.drop .hint a { color: var(--accent); }

.processing { max-width: 560px; margin: 14vh auto; text-align: center; }
.processing h2 { font-size: 22px; margin: 0 0 18px; }
.progress { height: 10px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffd37a); border-radius: 99px; transition: width .4s var(--ease); }
.processing p { color: var(--muted); margin-top: 14px; }

.meta-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 14px; }
.song-title { font-size: 24px; letter-spacing: -.02em; margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: 600 12.5px var(--mono); padding: 4px 10px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); }
.chip.subtle { color: var(--muted); font-weight: 500; font-family: var(--font); }
.export { margin-left: auto; position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 250px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 30; animation: pop .14s var(--ease); }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; background: none; border: 0; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--panel2); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

.board { display: grid; grid-template-columns: 184px 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.strips { border-right: 1px solid var(--line); padding-top: var(--head-h, 72px); }
.strip { height: var(--lane-h, 64px); padding: 8px 10px; display: grid; grid-template-columns: 1fr auto auto; grid-template-rows: auto auto; gap: 2px 6px; align-items: center; border-top: 1px solid var(--line); position: relative; transition: opacity .2s; }
.strip::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--stem-color); }
.strip .name { font-weight: 600; font-size: 13.5px; padding-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip .sm { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel2); font: 700 11.5px var(--mono); cursor: pointer; transition: all .15s; padding: 0; }
.strip .sm[aria-pressed="true"].m { background: var(--danger); border-color: transparent; color: #fff; }
.strip .sm[aria-pressed="true"].s { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.strip input[type="range"] { grid-column: 1 / -1; width: 100%; }
.strip.dim { opacity: .55; }
.timeline { position: relative; min-width: 0; touch-action: pan-y; }
#timeline { display: block; width: 100%; cursor: crosshair; }
.zoom { position: absolute; right: 8px; top: 6px; display: flex; gap: 4px; }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 22px; background: transparent; width: 100%; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); margin-top: -6px; border: 0; transition: transform .12s; }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 0; }
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); }

.deck { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.play { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; transition: transform .12s var(--ease), filter .15s; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.play:hover { filter: brightness(1.08); transform: scale(1.04); }
.play:active { transform: scale(.97); }
.clock { display: grid; font: 600 22px var(--mono); letter-spacing: -.02em; }
.clock .muted { font-size: 12.5px; font-weight: 500; }
.loop-row { min-height: 38px; }
.transport input[type="range"] { flex: 1; min-width: 70px; }
.field { display: grid; gap: 4px; }
.field-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; }
.field-head label { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: 11.5px; }
.field-head output { font: 650 15px var(--mono); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.presets button { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 3px 10px; cursor: pointer; font: 600 12px var(--mono); transition: all .15s; }
.presets button:hover { border-color: var(--accent); }
.presets button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.trainer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trainer-grid label { display: grid; gap: 3px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.trainer-grid input { width: 100%; }
.trainer-status { min-height: 30px; display: flex; justify-content: space-between; align-items: center; font: 600 13px var(--mono); }
.chord-card .chord-now { display: flex; gap: 28px; align-items: flex-end; }
.label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.chord-name { font: 700 44px/1.05 var(--font); letter-spacing: -.03em; min-width: 3ch; transition: color .2s; }
.chord-name.small { font-size: 26px; color: var(--muted); }
.diagrams { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.diagram svg { display: block; max-width: 100%; height: auto; }
.diagram.wide { flex: 1; min-width: 150px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; cursor: pointer; }
.credit { color: var(--muted); font-size: 12.5px; margin: 18px 2px 0; }
.credit a { color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); z-index: 50; animation: pop .18s var(--ease); max-width: 90vw; }
.toast.error { border-color: var(--danger); }
.dropveil { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 82%, transparent); display: grid; place-items: center; font: 700 28px var(--font); z-index: 40; border: 3px dashed var(--accent); margin: 10px; border-radius: 24px; pointer-events: none; }

@media (max-width: 760px) {
  main { padding: 12px; }
  .topbar { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .song-picker { order: 3; flex-basis: 100%; max-width: none; }
  .board { grid-template-columns: 120px 1fr; }
  .strip { padding: 6px 6px 6px 8px; grid-template-columns: auto auto 1fr; gap: 3px 5px; }
  .strip .name { grid-column: 1 / -1; }
  .strip .sm { width: 26px; height: 24px; }
  .strip input[type="range"] { grid-column: auto; min-width: 0; }
  .transport { gap: 8px; padding: 12px; }
  .transport .play { width: 44px; height: 44px; }
  .transport .clock { font-size: 18px; }
  .song-title { font-size: 20px; }
  .chord-name { font-size: 36px; }
  .export { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
