:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1b1b1f; --muted: #6b6b75; --line: #e3e1dc;
  --staff: #8a8a93; --accent: #e0592a; --accent-ink: #fff; --hover: rgba(224, 89, 42, .06);
  --sel: rgba(224, 89, 42, .12); --mark: rgba(60, 120, 220, .08); --cell: #efede8; --cell-on: #1b1b1f;
  --radius: 10px;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141417; --panel: #1d1d22; --ink: #ececf1; --muted: #9a9aa6; --line: #2d2d35;
    --staff: #6b6b76; --hover: rgba(255, 120, 70, .08); --sel: rgba(255, 120, 70, .09);
    --mark: rgba(90, 150, 255, .12); --cell: #2a2a31; --cell-on: #ececf1;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 3px 9px; font-size: 13px; }
button.danger:hover { border-color: #d33; color: #d33; }
button.wide { width: 100%; margin-top: 10px; padding: 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; }
.logo { color: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tab { border: none; background: transparent; padding: 8px 14px; border-radius: 8px; color: var(--muted); }
.tab.active { background: var(--sel); color: var(--ink); font-weight: 600; }

.layout { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 55px); }
.side { border-right: 1px solid var(--line); padding: 16px; background: var(--panel); }
.main { padding: 16px 20px 40px; min-width: 0; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.panel h3:first-child { margin-top: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border-radius: 999px; padding: 4px 11px; font-size: 13px; }
.chips button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: none; border-radius: 0; padding: 6px 4px; font-size: 13px; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--bg); }
.small-seg button { padding: 4px 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0; }
.big { font-size: 22px; font-weight: 700; min-width: 70px; }
.check { display: flex; align-items: center; gap: 6px; user-select: none; }
.slider { display: grid; grid-template-columns: 80px 1fr; align-items: center; margin: 6px 0; }
.hint { font-size: 12px; color: var(--muted); }

.drop { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 12px; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--hover); }
.drop span { font-size: 12px; color: var(--muted); }
.progress { position: relative; height: 26px; border-radius: 8px; background: var(--cell); overflow: hidden; margin: 10px 0; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); opacity: .35; transition: width .2s; }
.progress span { position: relative; font-size: 12px; line-height: 26px; padding: 0 10px; }

.library { list-style: none; margin: 0; padding: 0; }
.library li { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.library li .name { flex: 1; cursor: pointer; }
.library li .name:hover { color: var(--accent); }
.library li small { color: var(--muted); display: block; }

.transport { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); position: sticky; top: 64px; z-index: 4; }
.play { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; border: none; font-size: 18px; padding: 0; }
.play.on { background: var(--ink); color: var(--bg); }
.bpm { display: flex; align-items: baseline; gap: 4px; }
.bpm input { width: 70px; font-family: inherit; font-weight: 700; font-size: 20px; background: transparent; color: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.bpm span { color: var(--muted); font-size: 12px; }
#bpmSlider { width: 140px; accent-color: var(--accent); }
.kitsel { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.kitsel select { font: inherit; font-size: 13px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
input[type=range] { accent-color: var(--accent); }

.title { display: block; width: 100%; font-family: inherit; font-weight: 700; font-size: 22px; color: inherit; background: transparent; border: none; margin: 18px 0 6px; padding: 2px 0; }
.title:focus { outline: none; border-bottom: 1px dashed var(--line); }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 4px; overflow-x: auto; }

.notation * { pointer-events: none; }
.notation .barbg { pointer-events: all; fill: transparent; cursor: pointer; }
.notation .barbg:hover { fill: var(--hover); }
.notation .barbg.sel { fill: var(--sel); stroke: var(--accent); stroke-opacity: .5; }
.notation .staff { stroke: var(--staff); stroke-width: 1; }
.notation .barline { stroke: var(--ink); stroke-width: 1.2; }
.notation .ink { fill: var(--ink); }
.notation .stem { stroke: var(--ink); stroke-width: 1.2; }
.notation .xhead { stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.notation .flag, .notation .paren, .notation .accent, .notation .open { stroke: var(--ink); fill: none; stroke-width: 1.5; }
.notation .paren { stroke-width: 1.1; }
.notation .rest { stroke: var(--ink); fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.notation .rest.thin { stroke-width: 1.4; }
.notation .tsig { font: 700 20px/1 Georgia, serif; fill: var(--ink); text-anchor: middle; }
.notation .barnum { font-size: 11px; fill: var(--muted); }
.notation .tuplet { font: italic 11px Georgia, serif; fill: var(--ink); text-anchor: middle; }
.notation .playhead { fill: var(--accent); opacity: .28; }
.pictures .lane { stroke: var(--staff); stroke-width: 1; }
.pictures .barsep { stroke: var(--line); stroke-width: 1.5; }
.pictures .lanename { font-size: 12px; fill: var(--muted); }
.pictures .syl { font-size: 17px; fill: var(--ink); text-anchor: middle; }
.pictures .syl.strong { font-weight: 700; }
.pictures .beatno { font-size: 10px; fill: var(--muted); text-anchor: middle; }
.pictures .acc { font: 700 15px sans-serif; fill: var(--accent); }
.pictures .hit.ghost { opacity: .5; }
.pictures .hit.flash { filter: drop-shadow(0 0 5px var(--accent)) brightness(1.25); }

.editor { margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.editor-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.editor-head .muted { font-size: 12px; }
.grid { display: grid; gap: 3px; overflow-x: auto; }
.grid .lbl { font-size: 12px; white-space: nowrap; padding-right: 8px; cursor: pointer; align-self: center; }
.grid .lbl:hover { color: var(--accent); }
.grid .cell { height: 26px; min-width: 22px; border-radius: 5px; background: var(--cell); border: none; padding: 0; font-size: 11px; font-weight: 700; }
.grid .cell.beat { box-shadow: inset 2px 0 0 var(--staff); }
.grid .cell.v1 { background: color-mix(in srgb, var(--cell-on) 30%, var(--cell)); }
.grid .cell.v2 { background: var(--cell-on); color: var(--bg); }
.grid .cell.v3 { background: var(--accent); color: #fff; }
.grid .cell.now { outline: 2px solid var(--accent); outline-offset: -2px; }
.grid .cnt { font-size: 10px; color: var(--muted); text-align: center; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: none; border-bottom: 1px solid var(--line); }
  .transport { top: 0; position: static; }
  .main { padding: 12px 16px 40px; }
}

@media print {
  .top, .side, .transport, .editor { display: none !important; }
  .layout { display: block; }
  .sheet { border: none; }
  .notation .barbg, .notation .playhead { display: none; }
  body { background: #fff; color: #000; }
}
