:root {
  color-scheme: dark;
  --background: #131416;
  --surface: #1b1d20;
  --surface-deep: #17181b;
  --line: #37393c;
  --text: #f5f2eb;
  --muted: #afafb2;
  --signal: #ffca45;
  --signal-hover: #ffdc75;
  --paper: #faf8f2;
  --ink: #232326;
  --font: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif;
  --numbers: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--text); font: 14px/1.55 var(--font); }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled, input:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 4px; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 21px; height: 21px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.icon.small { width: 16px; height: 16px; }

.shell { width: min(1320px, calc(100% - 96px)); margin: 0 auto; }
.site-header { border-bottom: 1px solid #2a2b2e; background: #17181a; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 750; }
.brand-icon { display: grid; place-items: center; height: 34px; width: 34px; color: #201a10; background: var(--signal); border-radius: 6px; }
.brand-icon .icon { width: 20px; height: 20px; }
.local-label { display: flex; align-items: center; gap: 9px; font-size: 12px; color: #d1cfc8; }
.local-label span { width: 7px; height: 7px; background: var(--signal); border-radius: 50%; }
.local-label b { font-weight: inherit; }

.hero { position: relative; isolation: isolate; display: flex; align-items: center; min-height: 294px; overflow: hidden; margin: 28px 0 34px; border: 1px solid #343336; border-radius: 13px; background: #1a1a1c; }
.hero-image { position: absolute; z-index: -1; inset: 0 0 0 35%; background: url('/drum-kit.jpg') 63% 55%/cover; }
.hero-image::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #1a1a1c 0%, #1a1a1cbb 25%, #17171920 67%), linear-gradient(0deg, #24201166, transparent 64%); }
.hero::after { content: ''; position: absolute; right: 24px; top: 25px; width: 47px; height: 8px; transform: skew(-30deg); background: repeating-linear-gradient(90deg, var(--signal) 0 5px, transparent 5px 9px); pointer-events: none; }
.hero.dragging { border-color: var(--signal); box-shadow: inset 0 0 0 2px var(--signal); }
.hero-copy { padding: 34px 44px; }
.hero h1 { font-size: clamp(38px, 5vw, 68px); font-weight: 850; letter-spacing: .01em; line-height: 1.08; }
.hero h1 span { color: var(--signal); }
.hero-copy > p { margin-top: 14px; color: #d0cdc7; font-size: 15px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.hero-copy .upload-hint { margin-top: 10px; color: #b8b6af; font-size: 12px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 39px; padding: 8px 15px; border: 1px solid transparent; border-radius: 7px; color: var(--text); background: transparent; font-weight: 650; white-space: nowrap; }
.button.primary { background: var(--signal); color: #211a10; padding: 10px 17px; }
.button.primary:hover { background: var(--signal-hover); }
.button.quiet { border-color: #595860; background: #1d1e20dc; }
.button.quiet:hover, .button.secondary:hover, .icon-button:hover { background: #2b2d31; }
.button.secondary { background: #272526; color: var(--signal); border-color: #665326; }
.button:disabled, .icon-button:disabled { opacity: .44; }
.button:disabled:hover, .icon-button:disabled:hover { background: transparent; }
.button.reset { color: var(--muted); padding-inline: 7px; font-size: 12px; }
.button.reset:not(:disabled):hover { color: var(--text); }
.button.compact { min-height: 34px; padding: 6px 10px; border-color: #414247; font-size: 12px; }
.button.compact:hover { border-color: var(--signal); }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid #424247; border-radius: 6px; background: transparent; color: inherit; }
.icon-button .icon { width: 17px; height: 17px; }

.notice { margin: -14px 0 22px; padding: 11px 15px; border: 1px solid #755827; border-radius: 7px; background: #2a241b; color: #ffdc90; }
.notice.error { background: #2e2120; border-color: #794845; color: #ffb6a9; }
.workspace { padding-bottom: 52px; scroll-margin-top: 18px; }
.workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0 0 14px; }
.workspace-heading h2 { font-size: 23px; line-height: 1.3; font-weight: 760; }
.workspace-heading p { margin-top: 5px; color: var(--muted); font-size: 13px; }
.song-picker { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.song-picker span { white-space: nowrap; }
.song-picker select { color: var(--text); background: #1c1d20; border: 1px solid #3c3d41; border-radius: 6px; min-height: 36px; max-width: 240px; width: 100%; padding: 6px 10px; }
.desk { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 19px; align-items: start; }
.score-panel, .side-panel { min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.score-toolbar, .score-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; min-height: 57px; }
.score-toolbar { position: relative; z-index: 2; }
.score-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.score-actions, .page-controls { display: flex; align-items: center; gap: 8px; }
.score-actions { flex-wrap: wrap; justify-content: flex-end; }
.page-controls { font-size: 12px; color: #c4c1ba; }
.page-controls span { min-width: 62px; text-align: center; white-space: nowrap; }
.page-controls .icon-button { width: 29px; height: 34px; }
.score-title > .icon { color: var(--signal); }
.edit-button { color: var(--signal); }
.measure-editor { border-top: 1px solid var(--line); padding: 16px; background: var(--surface-deep); }
.measure-editor-header, .measure-editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.measure-editor h4 { margin: 0; font-size: 15px; }
.measure-editor p, #edit-status { color: var(--muted); font-size: 12px; margin-top: 3px; }
.measure-editor-footer { margin-top: 13px; flex-wrap: wrap; justify-content: flex-start; }
.editor-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.compare-toolbar { padding: 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.compare-toolbar label { color: var(--muted); }
.compare-toolbar select { color: var(--text); background: var(--surface-deep); border: 1px solid var(--line); border-radius: 4px; padding: 5px; }
.compare-toolbar button[aria-pressed='true'] { color: var(--signal); border-color: var(--signal); }
#preview-range { margin-left: auto; color: var(--muted); }
#save-measure { margin-left: auto; min-height: 34px; padding: 6px 12px; }
#save-measure:disabled { color: var(--muted); }
.measure-grid-scroll { overflow-x: auto; padding: 5px 3px 6px; }
.hit-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.hit-tools button[aria-pressed='true'] { color: var(--signal); border-color: var(--signal); background: #272526; }
.measure-grid { margin: 7px 0 0; min-width: 570px; display: grid; grid-template-columns: 52px repeat(16, minmax(25px, 1fr)); align-items: center; gap: 4px; }
.grid-beat { grid-column: span 4; padding: 1px 5px; border-left: 1px solid #746338; color: #e8d7ab; font-size: 11px; }
.grid-row-label { padding-right: 4px; font-size: 12px; color: #d7d2c8; white-space: nowrap; }
.hit-cell { height: 27px; padding: 0; border: 1px solid #35363b; border-radius: 3px; background: #292a2e; font-size: 12px; font-weight: 750; white-space: nowrap; }
.hit-cell.beat-start { border-left-color: #8a744a; }
.hit-cell:hover { border-color: var(--signal); }
.hit-cell[aria-pressed='true'] { color: #201a10; background: var(--signal); border-color: #e7b636; }
.hit-cell[aria-pressed='true']:empty::after { content: ''; display: block; background: currentColor; width: 7px; height: 7px; border-radius: 50%; margin: auto; }
.hit-cell:disabled { cursor: progress; }
.score-content g[data-bar].editing .measure-hit { stroke: #a96c08; stroke-width: 24; }
.score-content g[data-bar].draft:not(.editing) .measure-hit { stroke: #a96c08; stroke-width: 18; stroke-dasharray: 45 35; }
.score-title h3, .side-heading h3 { font-size: 15px; font-weight: 720; white-space: nowrap; }
.score-status { padding: 1px 7px; border: 1px solid #5b4b2a; border-radius: 4px; color: #ffcf65; font-size: 11px; white-space: nowrap; }
.export { position: relative; }
.export summary { list-style: none; }
.export summary::-webkit-details-marker { display: none; }
.export-list { position: absolute; z-index: 4; right: 0; top: calc(100% + 7px); width: 202px; border: 1px solid #4a4b4e; border-radius: 7px; overflow: hidden; background: #232427; box-shadow: 0 12px 24px #0005; }
.export-list a { display: flex; justify-content: space-between; gap: 6px; padding: 11px; font-size: 12px; }
.export-list a:hover { background: #323134; color: var(--signal); }
.export-list a span { color: var(--muted); font-size: 11px; }
.score-frame { min-height: 300px; overflow: auto; background: #24262a; color: var(--ink); border-block: 1px solid var(--line); padding: 14px; }
.score-content { width: 100%; max-width: 210mm; aspect-ratio: 210 / 297; margin: 0 auto; padding: 3% 4%; background: var(--paper); box-shadow: 0 2px 12px #0004; }
.score-content > svg { width: 100%; height: auto; display: block; }
.score-content svg text { font-family: Georgia, var(--font); }
.score-content g[data-bar] { cursor: pointer; }
.score-content .measure-hit { fill: transparent; pointer-events: all; }
.score-content g[data-bar]:hover .measure-hit, .score-content g[data-bar]:focus-visible .measure-hit { fill: #ffbd2730; }
.score-content g[data-bar].active .measure-hit { fill: #ffbd275b; stroke: #ad760f; stroke-width: 18; }
.score-content g[data-bar]:focus-visible { outline: none; }
.score-content g[data-bar]:focus-visible .measure-hit { stroke: #946100; stroke-width: 24; }
.score-empty { min-height: 310px; display: grid; place-content: center; justify-items: center; padding: 20px; gap: 7px; text-align: center; border-top: 1px solid #333438; }
.score-empty .empty-icon { margin-bottom: 4px; color: var(--signal); width: 33px; height: 33px; }
.score-empty p { font-size: 18px; font-weight: 700; }
.score-empty span { color: var(--muted); max-width: 375px; }
.score-empty progress { width: min(200px, 85vw); height: 9px; margin-top: 10px; accent-color: var(--signal); }
.score-empty .retry { margin-top: 8px; }
.score-footer { color: #c4c1ba; font-size: 12px; min-height: 44px; }

.desk-sidebar { display: grid; gap: 14px; }
.side-panel { padding: 16px; }
.side-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.side-heading h3 { display: flex; align-items: center; gap: 7px; }
.side-heading h3 .icon { color: var(--signal); }
.measure-label { color: var(--signal); font-size: 11px; white-space: nowrap; }
.track-name { margin-top: 7px; font-weight: 750; color: #f4eee1; font-size: 18px; overflow-wrap: anywhere; }
.transport { display: flex; align-items: center; gap: 13px; margin: 13px 0 10px; }
.play-button { display: grid; place-items: center; flex: none; width: 42px; height: 42px; color: #1d170c; border: 0; border-radius: 50%; background: var(--signal); }
.play-button:not(:disabled):hover { background: var(--signal-hover); }
.play-button:disabled { opacity: .38; }
.play-button .icon { width: 23px; height: 23px; }
.timeline { flex: 1; min-width: 0; }
.timeline input { width: 100%; display: block; accent-color: var(--signal); margin: 0 0 3px; height: 16px; }
.time-codes { display: flex; justify-content: space-between; color: var(--muted); font: 11px/1.4 var(--numbers); }
.follow { display: inline-flex; align-items: center; gap: 5px; color: #d0cfcb; font-size: 12px; cursor: pointer; }
.follow input { accent-color: var(--signal); }
.panel-hint { color: var(--muted); font-size: 12px; margin-top: 7px; }
.offset-control { display: flex; align-items: stretch; justify-content: space-between; margin-top: 13px; gap: 8px; }
.offset-control .icon-button { height: 38px; }
.offset-field { display: flex; align-items: center; justify-content: center; min-width: 0; flex: 1; gap: 8px; border: 1px solid #424247; border-radius: 6px; background: var(--surface-deep); color: var(--muted); font-size: 12px; }
.offset-field input { max-width: 68px; min-width: 0; text-align: center; color: var(--text); border: 0; background: transparent; font: 16px var(--numbers); appearance: textfield; }
.offset-field input::-webkit-inner-spin-button, .offset-field input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.calibration-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 11px; }
.offset-status { margin-top: 8px; min-height: 1.4em; font-size: 11px; color: var(--muted); }
.review-note { padding: 12px 14px; border-left: 2px solid #987432; background: #231f19; color: #dfcba6; font-size: 12px; }
.review-note p { margin-top: 3px; color: #c7bbab; }

@media (min-width: 761px) and (min-height: 550px) {
  .desk-sidebar { position: sticky; top: 16px; }
}

@media (max-width: 1000px) {
  .shell { width: calc(100% - 50px); }
  .desk { grid-template-columns: minmax(0, 1fr) 260px; gap: 13px; }
  .hero-copy { padding-inline: 31px; }
}
@media (max-width: 760px) {
  .shell { width: calc(100% - 30px); }
  .header-inner { height: 56px; }
  .hero { margin-top: 16px; margin-bottom: 22px; min-height: 242px; }
  .hero-copy { padding: 24px 17px; }
  .hero-image { left: 25%; opacity: .65; }
  .hero-copy > p { font-size: 13px; }
  .desk { grid-template-columns: minmax(0, 1fr); }
  .desk-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-note { grid-column: 1 / -1; }
  .score-content { min-width: 535px; }
}
@media (max-width: 490px) {
  .hero h1 { font-size: 38px; }
  .hero::after { right: 15px; top: 16px; }
  .workspace-heading { flex-wrap: wrap; }
  .song-picker { flex-basis: 100%; }
  .desk-sidebar { grid-template-columns: minmax(0, 1fr); }
  .score-toolbar, .score-footer { padding-inline: 9px; }
  .score-toolbar { flex-wrap: wrap; }
  .score-actions { margin-left: auto; }
  .page-controls, .score-actions { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
