* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); font-size: var(--fs-body); background: var(--bg-1); color: var(--ink-0); display: flex; flex-direction: column; height: 100vh; }

/* Feedback Banner */
#feedback-bar { display: none; }
#feedback-btn {
  display: inline-block; padding: 8px 40px;
  background: var(--accent-dim); color: #fff; font-size: var(--fs-body); font-weight: bold;
  text-decoration: none; border-radius: 6px; letter-spacing: 1px;
}
#feedback-btn:hover { background: #f7b06d; }

/* Upload Bar */
#upload-bar {
  display: flex; align-items: center; gap: 15px; padding: 8px 12px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  font-size: var(--fs-body); flex-wrap: wrap;
  position: relative; z-index: 100;
}
#upload-bar label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-label); }
#upload-bar input[type="file"] { width: 340px; font-size: var(--fs-label); }
#upload-bar input[type="number"] { width: 75px; background: var(--bg-3); border: 1px solid var(--line); color: var(--ink-0); padding: 4px 5px; border-radius: 4px; font-size: var(--fs-label); }
#load-btn { padding: 8px 22px; background: linear-gradient(180deg, #f7b06d, #e08840); color: #1c1004; border: none; border-radius: 5px; cursor: pointer; font-weight: 600; font-size: var(--fs-label); }
#load-btn:hover { filter: brightness(1.06); }
#load-status { color: var(--ink-2); font-size: var(--fs-meta); }
#page-nav { display: inline-flex; align-items: center; gap: 6px; }
#page-nav button { padding: 4px 12px; background: var(--bg-3); color: var(--ink-0); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; font-size: var(--fs-label); }
#page-nav button:hover { background: var(--bg-4); }
#page-indicator { font-size: var(--fs-label); font-family: var(--font-mono); color: var(--ink-0); min-width: 60px; text-align: center; }

/* Toolbar */
#toolbar {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--bg-3); border-bottom: 1px solid var(--line); flex-wrap: wrap;
  font-size: var(--fs-body);
  position: relative; z-index: 50;
}
.tool-group { display: flex; align-items: center; gap: 4px; padding: 0 6px; border-right: 1px solid var(--line); }
.tool-group:last-child { border-right: none; }
.tool-group.right { margin-left: auto; }
#toolbar button {
  padding: 10px 22px; background: var(--bg-2); color: var(--ink-0); border: 1px solid var(--line-strong);
  border-radius: 3px; cursor: pointer; font-size: 20px;
}
#toolbar button:hover { background: var(--bg-4); border-color: var(--line-strong); }
#toolbar button:active { background: var(--accent-soft); color: var(--accent); }
#btn-show-free-glyphs { padding: 10px 18px; font-size: var(--fs-label); font-weight: bold; background: rgba(255,153,0,.12); border-color: rgba(255,153,0,.4); color: #ffcc88; }
#btn-show-free-glyphs:hover { background: rgba(255,153,0,.2); }
#btn-show-free-glyphs.active { background: rgba(255,153,0,.25); border-color: #ff9900; color: #ffd9a3; }
#btn-download-menu { padding: 8px 22px; background: linear-gradient(180deg, #f7b06d, #e08840); color: #1c1004; border: none; border-radius: 5px; cursor: pointer; font-weight: 600; font-size: var(--fs-label); }
#btn-download-menu:hover { filter: brightness(1.06); }
/* Custom tooltip (replaces browser title) */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%);
  margin-bottom: 6px; padding: 4px 8px;
  background: rgba(0,0,0,0.88); color: #fff; font: 12px/1.4 monospace;
  border-radius: 4px; white-space: pre; pointer-events: none; z-index: 9999;
}
#lang-menu.hidden { display: none; }
.lang-option:hover { background: var(--bg-4); }
.lang-option.active { color: var(--accent); font-weight: 600; }
.dl-opt:hover { background: var(--bg-4); }
#toolbar label { font-size: var(--fs-label); }
#toolbar input[type="number"] { font-size: var(--fs-label); width: 68px; }
#toolbar input[type="range"] { width: 112px; height: 12px; }

#zoom-slider { width: 112px; vertical-align: middle; }
#zoom-label { font-size: var(--fs-meta); color: var(--ink-2); min-width: 38px; display: inline-block; }

/* Shortcut Floating Panel */
#shortcut-panel {
  position: fixed; z-index: 8000;
  top: 80px; right: 20px;
  background: var(--bg-2); border: 2px solid var(--accent);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  min-width: 260px; max-width: 340px;
  font-size: var(--fs-label);
  user-select: none;
}
#shortcut-panel.hidden { display: none; }
#shortcut-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; cursor: grab;
  background: var(--accent); color: #fff; border-radius: 8px 8px 0 0;
  font-weight: 700; font-size: var(--fs-body);
}
#shortcut-panel-header:active { cursor: grabbing; }
#shortcut-panel-close {
  background: none; border: none; color: #fff; font-size: 22px;
  cursor: pointer; line-height: 1; padding: 0 4px;
}
#shortcut-panel-body { padding: 10px 14px; max-height: 60vh; overflow-y: auto; }
#shortcut-panel-body table { width: 100%; border-collapse: collapse; }
#shortcut-panel-body td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
#shortcut-panel-body td.sk { font-weight: 700; color: var(--accent); white-space: nowrap; width: 1%; }

/* OMR Apply Button (moved to status-bar in Phase 3) */
#omr-apply-btn {
  margin-left: 8px; padding: 4px 10px;
  background: rgba(124,212,84,.12); border: 1px solid rgba(124,212,84,.4); color: #b6e4a4;
  border-radius: 5px; cursor: pointer; font-size: var(--fs-meta);
}
#omr-apply-btn:hover { background: rgba(124,212,84,.2); }
#omr-apply-badge {
  background: var(--danger); color: #fff; border-radius: 8px;
  padding: 0 5px; margin-left: 4px; font-size: 10px;
}

/* Progress Bar */
#progress-bar-container {
  position: relative; height: 38px; background: var(--bg-0); border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
#progress-bar-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #f7b06d);
  transition: none; pointer-events: none;
}
#progress-time {
  position: absolute; top: 0; right: 8px; line-height: 38px;
  font-size: var(--fs-meta); color: var(--ink-2); pointer-events: none;
}

/* Mode Panel (left aside) */
#mode-panel {
  width: 248px; flex-shrink: 0;
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
#mode-panel .mode-list { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.mode-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; border-radius: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--ink-0); cursor: pointer;
  font-size: var(--fs-body); text-align: left;
  outline: none;
}
.mode-row:focus, .mode-row:focus-visible { outline: none; box-shadow: none; }
.mode-row .ic {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-3); border-radius: 6px; color: var(--ink-1); font-size: 16px;
}
.mode-row .mode-keys { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.kbd-chip {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  background: var(--bg-3); color: var(--ink-2); font-size: 12px;
  font-family: var(--font-mono, monospace); line-height: 1.4;
  border: 1px solid var(--line);
}
.mode-row.is-active { background: var(--accent-soft); border-color: var(--accent-dim); color: var(--accent); }
.mode-row.is-active .ic { background: rgba(243,162,91,.2); color: var(--accent); }

#mode-panel .display-toggles { padding: 4px 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.tg { display: flex; align-items: center; gap: 10px; font-size: var(--fs-label); color: var(--ink-1); cursor: pointer; padding: 4px 0; }
.tg input { accent-color: var(--accent); }

#mode-panel .offset-grid {
  padding: 6px 14px 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
}
.offset-grid label { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-meta); color: var(--ink-2); }
.offset-grid input[type="number"] {
  width: 100%; min-width: 0; box-sizing: border-box;
  background: #0a0d14; border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink-0); padding: 4px 6px; font-family: var(--font-mono); font-size: 11.5px;
}

#warning-list { padding: 6px 14px 12px; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-meta); }

/* Main Area: flex row for mode-panel + score + timeline */
#main-area {
  flex: 1; display: flex; overflow: hidden; min-height: 0;
}

/* Main Canvas */
#canvas-wrapper {
  flex: 1; overflow: auto; background: var(--bg-0); position: relative; min-width: 0;
}
#no-score-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 48px; color: rgba(255,255,255,0.15); pointer-events: none; user-select: none;
}
#canvas-container {
  position: relative; display: inline-block;
  transform-origin: top left;
}
#score-image {
  display: block; user-select: none; -webkit-user-drag: none;
}
#marker-svg {
  position: absolute; top: 0; left: 0; pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   PRESERVED — do not change. See PRESERVED_VALUES.md §1
   ═══════════════════════════════════════════════════════════════ */

/* Markers */
.marker {
  pointer-events: all; cursor: pointer;
  transition: r 0.1s, stroke-width 0.1s;
}
.marker:hover { r: 10; }
.marker.chord-hover { stroke: rgba(100,200,255,0.9); stroke-width: 4; r: 11; filter: drop-shadow(0 0 6px rgba(100,200,255,0.7)); }
.measure-highlight { fill: rgba(255, 215, 0, 0.08); stroke: rgba(255, 215, 0, 0.35); stroke-width: 1.5; stroke-dasharray: 6 3; pointer-events: none; }
.marker.selected { stroke: #ffd700; stroke-width: 6; r: 18; filter: drop-shadow(0 0 12px #ffd700) drop-shadow(0 0 24px rgba(255,215,0,0.7)) drop-shadow(0 0 40px rgba(255,215,0,0.4)); animation: sel-pulse 0.8s ease-in-out infinite alternate; }
@keyframes sel-pulse { from { r: 18; filter: drop-shadow(0 0 12px #ffd700) drop-shadow(0 0 24px rgba(255,215,0,0.7)) drop-shadow(0 0 40px rgba(255,215,0,0.4)); } to { r: 22; filter: drop-shadow(0 0 18px #ffee44) drop-shadow(0 0 36px rgba(255,230,50,0.8)) drop-shadow(0 0 56px rgba(255,215,0,0.5)); } }
.marker.multi-selected { stroke: #e02020 !important; stroke-width: 4 !important; r: 11; filter: drop-shadow(0 0 4px rgba(224,32,32,0.8)) !important; }
.marker.multi-selected.selected { stroke: #e02020 !important; stroke-width: 5 !important; r: 12; filter: drop-shadow(0 0 6px rgba(224,32,32,0.9)) !important; }
.marker.playback-highlight { stroke: #ff3333; stroke-width: 3; r: 11; fill: rgba(255,50,50,0.9); }
.marker.tie-linked { stroke: #ff6b35; stroke-width: 2.5; filter: drop-shadow(0 0 4px rgba(255,107,53,0.8)); }
.marker.modified { stroke: #00ff88; stroke-width: 2.5; filter: drop-shadow(0 0 3px #00ff88); }
.marker.modified.selected { stroke: #ffd700; stroke-width: 6; r: 18; filter: drop-shadow(0 0 12px #ffd700) drop-shadow(0 0 24px rgba(255,215,0,0.7)) drop-shadow(0 0 6px #00ff88); animation: sel-pulse 0.8s ease-in-out infinite alternate; }
.marker.voice1 { fill: rgba(68, 136, 255, 0.7); stroke: #4488ff; stroke-width: 1; }
.marker.voice2 { fill: rgba(255, 68, 68, 0.7); stroke: #ff4444; stroke-width: 1; }
.marker.voice3 { fill: rgba(68, 170, 68, 0.7); stroke: #44aa44; stroke-width: 1; }
.marker.voice4 { fill: rgba(255, 170, 0, 0.7); stroke: #ffaa00; stroke-width: 1; }
.marker.rest-marker { fill: rgba(150, 150, 150, 0.4); stroke: #888; stroke-width: 1; r: 6; }
/* OMR grade confidence coloring */
.marker.grade-low { fill: rgba(255, 40, 40, 0.85); stroke: #ff2020; stroke-width: 2; filter: drop-shadow(0 0 4px rgba(255,0,0,0.6)); }
.marker.grade-mid { fill: rgba(255, 165, 0, 0.8); stroke: #ffa500; stroke-width: 1.5; }
.marker.grade-ok { fill: rgba(255, 220, 50, 0.7); stroke: #ddcc33; stroke-width: 1; }

/* PRESERVED §2 — Accidental & ghost labels */
.acc-label {
  pointer-events: none; font-size: 28px; fill: #ffd700; font-weight: bold;
  stroke: #000; stroke-width: 4px; paint-order: stroke fill;
}
.ghost-marker {
  fill: rgba(255, 50, 50, 0.5); stroke: #ff3333; stroke-width: 2.5;
  stroke-dasharray: 4 2;
}
.ghost-label {
  fill: #ff3333; font-size: 14px; font-weight: bold; opacity: 0.9;
}

/* ═══════════════════════════════════════════════════════════════
   CHROME — retokened
   ═══════════════════════════════════════════════════════════════ */

/* Chord Popup — chrome retokened, position PRESERVED §6 */
#chord-popup {
  position: absolute; background: var(--bg-2); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 6px 0; z-index: 100; min-width: 140px;
  box-shadow: var(--shadow-md);
}
#chord-popup.hidden { display: none; }
#chord-popup-title { padding: 4px 12px; font-size: 11px; color: var(--ink-2); border-bottom: 1px solid var(--line); }
#chord-popup-list { list-style: none; }
#chord-popup-list li {
  padding: 6px 12px; cursor: pointer; font-size: 13px;
}
#chord-popup-list li:hover { background: var(--bg-3); }
#chord-popup-list li .voice-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px;
}

/* PRESERVED §4 — Barline overlays */
.barline-overlay {
  pointer-events: none;
  transition: stroke-width 0.1s, opacity 0.1s;
}
.barline-overlay.high { stroke: #00cc44; stroke-width: 1.5; opacity: 0.5; }
.barline-overlay.medium { stroke: #ccaa00; stroke-width: 1.5; opacity: 0.5; }
.barline-overlay.low { stroke: #cc6600; stroke-width: 1.5; opacity: 0.5; stroke-dasharray: 4 4; }
.barline-overlay.manual { stroke: #0088ff; stroke-width: 2; opacity: 0.7; }
.barline-overlay.implicit { stroke: #cc44cc; stroke-width: 2; opacity: 0.6; stroke-dasharray: 6 3; }
.barline-overlay.bl-selected { stroke: #0066ff; stroke-width: 3; opacity: 1.0; }
.barline-overlay.bl-hover { stroke-width: 2.5; opacity: 0.8; }

/* PRESERVED §5 — Free glyph overlays */
.free-glyph-box {
  fill: rgba(255, 153, 0, 0.15);
  stroke: #ff9900;
  stroke-width: 1.5;
  opacity: 0.7;
  cursor: pointer;
  pointer-events: all;
}
.free-glyph-box:hover {
  fill: rgba(255, 153, 0, 0.3);
  stroke-width: 2;
  opacity: 1;
}
.free-glyph-box.assigned {
  stroke: #00cc44;
  fill: rgba(0, 204, 68, 0.15);
}

/* PRESERVED §6 — Glyph shape popup (sizes/position locked, chrome retokened) */
#glyph-popup {
  position: fixed; background: var(--bg-2); border: 2px solid #ff9900;
  border-radius: 8px; padding: 10px 0; z-index: 10000; min-width: 280px;
  max-height: 70vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
#glyph-popup.hidden { display: none; }
#glyph-popup-title { padding: 8px 20px; font-size: 20px; color: var(--ink-1); border-bottom: 1px solid var(--line); font-weight: bold; }
#glyph-popup-list { list-style: none; }
#glyph-popup-list li {
  padding: 10px 20px; cursor: pointer; font-size: 22px;
}
#glyph-popup-list li:hover { background: var(--bg-3); }
#glyph-popup-list .glyph-cat {
  padding: 6px 20px; font-size: 18px; color: #ff9900; pointer-events: none; font-weight: bold; border-top: 1px solid var(--line);
}

/* PRESERVED §4 — Ghost barline & barline label */
.ghost-barline {
  stroke: #ff3333; stroke-width: 1.5; opacity: 0.5;
  stroke-dasharray: 6 3; pointer-events: none;
}
.barline-label {
  fill: #00cc44; font-size: 9px; pointer-events: none; opacity: 0.7;
}

/* Barline toolbar — chrome retokened */
#barline-toolbar {
  display: none;
  height: 44px; padding: 0 16px; align-items: center; gap: 12px;
  background: linear-gradient(180deg, rgba(255,108,122,.16), rgba(255,108,122,.05));
  border-bottom: 1px solid rgba(255,108,122,.35);
  font-size: var(--fs-label); color: var(--ink-1);
}
#barline-toolbar.active { display: flex; }
#barline-toolbar .bl-mode-label {
  padding: 4px 12px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  background: rgba(255,108,122,.25); color: #ffd0d4; border: 1px solid rgba(255,108,122,.4);
}
#barline-toolbar #bl-count { font-family: var(--font-mono); color: var(--ink-1); }
#barline-toolbar .bl-hint { color: var(--ink-2); font-size: var(--fs-meta); margin-left: auto; }
#barline-toolbar button {
  height: 28px; padding: 0 12px; border-radius: var(--r-md);
  background: var(--bg-3); border: 1px solid var(--line-strong); color: var(--ink-0);
  font-size: var(--fs-label); cursor: pointer;
}
#barline-toolbar button:hover { background: var(--bg-4); }
#barline-toolbar #bl-btn-accept {
  background: linear-gradient(180deg, #f7b06d, #e08840); border-color: #bf6c2f; color: #1c1004; font-weight: 600;
}

/* Dim markers during barline edit mode */
body.mode-barline #marker-svg .marker { opacity: 0.3; transition: opacity .15s; }

/* PRESERVED §8 — Rhythm validation warnings */
.rhythm-warning {
  pointer-events: none;
  animation: rhythm-pulse 2s ease-in-out infinite;
}
#rhythm-warning-panel {
  background: #1a1010; border-top: 1px solid #442222; padding: 8px 12px;
  color: #ff9999; overflow-y: auto;
}
#rhythm-warning-panel.rw-single {
  font-size: 18px; max-height: 120px;
}
#rhythm-warning-panel.rw-single .rw-notes { font-size: 15px; }
#rhythm-warning-panel.rw-all {
  font-size: 12px; max-height: 200px;
}
#rhythm-warning-panel .rw-header {
  color: #ff6666; font-weight: 700; font-size: 13px; margin-bottom: 6px;
  padding-bottom: 4px; border-bottom: 1px solid #442222;
}
#rhythm-warning-panel .rw-item {
  margin-bottom: 4px; line-height: 1.5;
}
#rhythm-warning-panel .rw-measure { color: #ff6666; font-weight: 600; }
#rhythm-warning-panel .rw-notes { color: #ccaa88; margin-left: 12px; font-size: 11px; }
@keyframes rhythm-pulse {
  0%, 100% { fill: rgba(255, 40, 40, 0.10); }
  50% { fill: rgba(255, 40, 40, 0.25); }
}

/* Timeline Panel (Piano Roll) — chrome retokened */
#timeline-panel {
  flex: 1; min-width: 0;
  background: var(--bg-1); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
#timeline-header {
  display: flex; align-items: center; padding: 10px 14px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-bottom: 1px solid var(--line); gap: 10px; flex-shrink: 0;
}
#timeline-title {
  font-weight: bold; color: var(--ink-0); font-size: var(--fs-display);
  white-space: nowrap;
}
#timeline-controls { display: flex; align-items: center; gap: 12px; margin-left: auto; }
#btn-tl-auto-align { background: #2a6; color: #fff; border: none; border-radius: 4px; padding: 6px 14px; font-size: 14px; font-weight: bold; cursor: pointer; }
#btn-tl-auto-align:hover { background: #3b7; }
#btn-tl-auto-align-all { background: #268; color: #fff; border: none; border-radius: 4px; padding: 6px 14px; font-size: 14px; font-weight: bold; cursor: pointer; }
#btn-tl-auto-align-all:hover { background: #379; }
#btn-tl-lineup { background: #864; color: #fff; border: none; border-radius: 4px; padding: 6px 14px; font-size: 14px; font-weight: bold; cursor: pointer; }
#btn-tl-lineup:hover { background: #975; }
#timeline-snap-label {
  color: var(--ink-1); font-size: var(--fs-label); display: flex; align-items: center; gap: 6px;
  cursor: pointer;
}
#timeline-snap-label input[type="checkbox"] { width: 20px; height: 20px; }
#timeline-snap-label:hover { color: var(--ink-0); }
#timeline-grid-select {
  background: var(--bg-3); color: var(--ink-0); border: 1px solid var(--line);
  border-radius: 4px; font-size: var(--fs-label); padding: 6px 10px;
}
#timeline-close {
  background: none; border: none; color: var(--ink-3);
  font-size: 20px; cursor: pointer; padding: 0 8px; line-height: 1;
}
#timeline-close:hover { color: var(--accent); }
#timeline-body {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px;
}

/* Staff lane */
.tl-lane {
  margin-bottom: 6px; position: relative;
  background: #0a0a16; border: 1px solid var(--line); border-radius: 4px;
  overflow: hidden;
}
.tl-lane-label {
  position: absolute; left: 0; top: 0; bottom: 0; width: 80px;
  background: var(--bg-2); border-right: 1px solid var(--line);
  font-size: var(--fs-meta); color: var(--ink-2); padding: 4px 6px;
  z-index: 2; line-height: 1.3;
  display: flex; flex-direction: column; justify-content: center;
}
.tl-lane-label.tl-clef-toggle { cursor: pointer; transition: background .15s; }
.tl-lane-label.tl-clef-toggle:hover { background: var(--bg-3, #2a2a3a); }
.tl-lane-label .staff-id { font-size: var(--fs-label); color: var(--ink-1); font-weight: 700; }
.tl-grid-line {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--bg-1); pointer-events: none; z-index: 0;
}
.tl-grid-line.beat { background: var(--line); }
.tl-grid-line.bar-start { background: var(--line-strong); width: 2px; }
.tl-grid-label {
  position: absolute; bottom: 1px; font-size: 8px; color: var(--ink-3);
  pointer-events: none; transform: translateX(-50%); z-index: 0;
}

/* PRESERVED §7 — Note block (height/font-size changeable, voice gradients locked) */
.tl-note {
  position: absolute; height: 56px;
  border-radius: 4px; cursor: grab; z-index: 1;
  font-size: var(--fs-label); font-weight: 600; line-height: 52px;
  text-align: center; padding: 0 3px; margin: 7px 0;
  color: #fff; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
  user-select: none; min-width: 18px;
  border: 1px solid rgba(255,255,255,0.15);
  transition: box-shadow 0.15s, transform 0.1s;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.tl-note:hover {
  box-shadow: 0 0 8px rgba(255,255,255,0.25), inset 0 0 12px rgba(255,255,255,0.08);
  z-index: 3; transform: scaleY(1.15);
}
.tl-note.dragging {
  cursor: grabbing; opacity: 0.9; z-index: 4;
  box-shadow: 0 0 14px rgba(243,162,91,0.7), 0 2px 8px rgba(0,0,0,0.5);
  transform: scaleY(1.2);
}
.tl-note.chord-linked {
  border-left: 3px solid rgba(100,200,255,0.6);
}
.tl-note.chord-hover {
  background: rgba(100,200,255,0.25) !important;
  border-color: rgba(100,200,255,0.9);
  box-shadow: 0 0 8px rgba(100,200,255,0.5);
}
#tl-tooltip {
  position: fixed;
  display: none;
  background: rgba(0,0,0,0.88);
  color: #fff;
  font: 12px/1.4 monospace;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: pre;
  pointer-events: none;
  z-index: 9999;
}
.tl-note.tuplet-grouped {
  border-top: 2px solid rgba(255,180,50,0.8);
}
.tl-tuplet-bracket {
  position: absolute;
  height: 12px;
  border: 2px solid rgba(255,180,50,0.8);
  border-bottom: none;
  text-align: center;
  font-size: 10px;
  font-weight: bold;
  color: rgba(255,180,50,0.9);
  line-height: 10px;
  pointer-events: none;
}
.tl-note.selected {
  border: 2px solid #ffd700;
  box-shadow: 0 0 8px rgba(255,215,0,0.7), 0 0 16px rgba(255,215,0,0.35);
  transform: scaleY(1.18);
}
.tl-note.playback-highlight {
  border: 2px solid #ff3333;
  box-shadow: 0 0 10px rgba(255,50,50,0.8), 0 0 20px rgba(255,50,50,0.4);
  transform: scaleY(1.25);
  z-index: 5;
}
.tl-note.rest {
  background: #222233 !important; color: #777; border-style: dashed;
  border-color: #444; font-style: italic;
}
.tl-note.orphan {
  background: linear-gradient(135deg, #442244, #553366) !important; border-color: #775599;
  border-style: dashed;
}
.tl-note.voice1 { background: linear-gradient(135deg, #2255cc, #3366ee); }
.tl-note.voice2 { background: linear-gradient(135deg, #cc3333, #ee4444); }
.tl-note.voice3 { background: linear-gradient(135deg, #228833, #33aa44); }
.tl-note.voice4 { background: linear-gradient(135deg, #cc8800, #eea500); }
.tl-note.voice5 { background: linear-gradient(135deg, #7733aa, #9944cc); }
.tl-note.voice6 { background: linear-gradient(135deg, #aa3366, #cc4488); }
.tl-note.voice7 { background: linear-gradient(135deg, #338877, #44aa99); }
.tl-note.voice8 { background: linear-gradient(135deg, #aa7722, #cc9933); }

/* PRESERVED §3 — Rubber-band selection */
.tl-rubber {
  border: 2px dashed #ffd700; background: rgba(255,215,0,0.1);
  pointer-events: none; z-index: 100;
}
.score-rubber {
  border: 2px dashed #e02020; background: rgba(224,32,32,0.08);
  pointer-events: none; z-index: 100;
}

/* Vertical sync line */
.tl-sync-line {
  position: absolute; width: 2px; pointer-events: none; z-index: 5;
  background: linear-gradient(180deg, rgba(255,215,0,0.6), rgba(255,215,0,0.15));
  box-shadow: 0 0 4px rgba(255,215,0,0.3);
}

/* Tie arc (score SVG) */
.tie-arc {
  fill: none; stroke: #ff6b35; stroke-width: 2.5;
  stroke-linecap: round; pointer-events: none;
  filter: drop-shadow(0 0 3px rgba(255,107,53,0.7));
}
/* Tie connector (timeline) */
.tl-tie-conn {
  position: absolute; height: 4px; pointer-events: none; z-index: 6;
  background: #ff6b35; border-radius: 2px;
  box-shadow: 0 0 6px rgba(255,107,53,0.6);
}
/* Tie indicator dots on tl-note */
.tl-note.tie-start::after {
  content: ''; position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 7px; height: 7px; border-radius: 50%;
  background: #ff6b35; box-shadow: 0 0 4px rgba(255,107,53,0.8);
}
.tl-note.tie-stop::before {
  content: ''; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
  width: 7px; height: 7px; border-radius: 50%;
  background: #ff6b35; box-shadow: 0 0 4px rgba(255,107,53,0.8);
}

/* Measure navigation arrows */
.tl-nav { display: flex; gap: 8px; margin-bottom: 8px; }
.tl-nav button {
  padding: 6px 16px; background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--line);
  border-radius: 4px; cursor: pointer; font-size: var(--fs-label);
}
.tl-nav button:hover { background: var(--bg-4); color: var(--ink-0); }

/* Multi-Edit Panel (inside TL panel bottom) */
#multi-edit-panel {
  flex-shrink: 0;
  background: var(--bg-2); border-top: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding-bottom: 12px; overflow-y: auto; max-height: 240px;
}
#multi-edit-panel[hidden] { display: none; }
.me-block { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.me-block:last-of-type { border-bottom: 0; flex-direction: row; gap: 8px; }
.me-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.me-row { display: flex; gap: 6px; flex-wrap: wrap; }
.me-row .btn { flex: 1; min-width: 0; }

/* Status Bar */
#status-bar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 14px; height: 30px;
  background: var(--bg-2); border-top: 1px solid var(--line);
  font-size: var(--fs-meta); color: var(--ink-2);
  flex-shrink: 0;
}
#status-mode { color: var(--accent); font-weight: 600; }
#status-selection { color: var(--ink-1); }
#status-total { margin-left: auto; }

/* ── Tutorial Tour ── */
#btn-tutorial, #btn-shortcut-panel {
  width: 28px; height: 28px; border-radius: 50%;
  font-weight: 700; font-size: 14px; padding: 0;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
}
#btn-tutorial:hover, #btn-shortcut-panel:hover { filter: brightness(1.15); }

#tour-prompt {
  position: fixed; inset: 0; z-index: 9100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5);
}
#tour-prompt.hidden { display: none; }
#tour-prompt-inner {
  background: var(--bg-2); border: 1px solid var(--line-strong);
  border-radius: 18px; padding: 60px 80px;
  box-shadow: var(--shadow-lg); text-align: center; min-width: 500px;
}
#tour-prompt-msg {
  font-size: 42px; color: var(--ink-0); margin-bottom: 36px; font-weight: 600;
}
#tour-prompt-skip-label {
  display: block; font-size: 24px; color: var(--ink-2); margin-bottom: 40px; cursor: pointer;
}
#tour-prompt-skip-label input[type="checkbox"] { width: 20px; height: 20px; vertical-align: middle; }
#tour-prompt-btns { display: flex; gap: 24px; justify-content: center; }
#tour-prompt-btns button {
  padding: 18px 56px; border-radius: 10px; font-size: 28px; cursor: pointer; border: none;
}
#tour-btn-yes { background: var(--accent); color: #fff; }
#tour-btn-yes:hover { filter: brightness(1.1); }
#tour-btn-no { background: var(--bg-3); color: var(--ink-1); }
#tour-btn-no:hover { background: var(--bg-4, #ccc); }

#tour-overlay {
  position: fixed; inset: 0; z-index: 9200; pointer-events: all;
}
#tour-overlay.hidden { display: none; }
#tour-spotlight {
  position: absolute; border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  transition: top 0.3s ease, left 0.3s ease, width 0.3s ease, height 0.3s ease;
  pointer-events: none;
}

#tour-tooltip {
  position: fixed; z-index: 9300;
  background: var(--bg-2); border: 3px solid var(--accent);
  border-radius: 14px; padding: 36px 44px;
  box-shadow: var(--shadow-lg); max-width: 600px;
  animation: tour-fade-in 0.25s ease;
}
#tour-tooltip.hidden { display: none; }
@keyframes tour-fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
#tour-tooltip-body {
  font-size: 28px; color: var(--ink-0); line-height: 1.7; margin-bottom: 28px;
}
#tour-tooltip-footer {
  display: flex; align-items: center; justify-content: space-between;
}
#tour-step-indicator {
  font-size: 22px; color: var(--ink-2); font-family: var(--font-mono, monospace);
}
#tour-tooltip-btns { display: flex; gap: 14px; }
#tour-tooltip-btns button {
  padding: 12px 30px; border-radius: 8px; font-size: 22px; cursor: pointer; border: none;
}
#tour-btn-prev { background: var(--bg-3); color: var(--ink-1); }
#tour-btn-next { background: var(--accent); color: #fff; }
#tour-btn-skip { background: transparent; color: var(--ink-2); text-decoration: underline; }

/* ── MML Edit Mode ── */
#mml-toolbar {
  display: flex; flex-wrap: wrap;
  padding: 6px 14px; align-items: center; gap: 8px;
  border-bottom: 1px solid rgba(93,119,221,.35);
  font-size: var(--fs-label); color: var(--ink-1);
  flex-shrink: 0;
}
.mml-sep { color: var(--line-strong); font-size: 18px; }
#mml-toolbar button {
  height: 28px; padding: 0 12px; border-radius: var(--r-md);
  background: var(--bg-3); border: 1px solid var(--line-strong); color: var(--ink-0);
  font-size: var(--fs-label); cursor: pointer;
}
#mml-toolbar button:hover { background: var(--bg-4); }
#mml-status { font-size: var(--fs-meta); color: var(--ink-2); margin-left: auto; }

/* MML Preview Floating Panel */
#mml-preview {
  position: fixed; z-index: 8000;
  bottom: 60px; right: 20px;
  width: 420px; height: 480px; min-width: 280px; min-height: 220px;
  background: var(--bg-2); border: 2px solid #5577dd;
  border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: var(--fs-label); user-select: none;
  display: flex; flex-direction: column;
  overflow: hidden;
}
#mml-preview.hidden { display: none; }
#mml-preview-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; cursor: grab;
  background: #5577dd; color: #fff; border-radius: 8px 8px 0 0;
  font-weight: 700; font-size: var(--fs-body);
}
#mml-preview-header:active { cursor: grabbing; }
#mml-unassigned-count { color: #ffcc88; font-weight: 400; font-size: var(--fs-meta); }
#mml-preview-close {
  background: none; border: none; color: #fff; font-size: 22px;
  cursor: pointer; line-height: 1; padding: 0 4px; margin-left: auto;
}
#mml-preview-body { padding: 10px 14px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.mml-pv-track { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; }
.mml-pv-label { font-size: 11px; font-weight: 700; letter-spacing: .04em; flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.mml-copy-btn { background: none; border: 1px solid rgba(255,255,255,.2); border-radius: 3px; cursor: pointer; font-size: 11px; padding: 1px 4px; color: inherit; opacity: .6; transition: opacity .15s; }
.mml-copy-btn:hover { opacity: 1; }
.mml-pv-code {
  width: 100%; flex: 1; min-height: 32px;
  background: var(--bg-0); color: var(--ink-0);
  border: 1px solid var(--line); border-left: 3px solid;
  border-radius: 4px; padding: 5px 8px; font-family: var(--font-mono); font-size: 11px;
  resize: none; box-sizing: border-box; line-height: 1.4; overflow-y: auto;
}
.mml-pv-combined { border-left-color: var(--ink-2) !important; background: var(--bg-1); }
.mml-pv-empty { color: var(--ink-3); font-size: var(--fs-meta); text-align: center; padding: 20px 0; }
.mml-pv-group-header { font-weight: bold; font-size: 13px; padding: 6px 0 2px; border-top: 1px solid #444; margin-top: 6px; }
.mml-group-dim { opacity: 0.2 !important; }
#mml-preview-footer {
  display: flex; gap: 6px; padding: 6px 14px;
  border-top: 1px solid var(--line); flex-shrink: 0;
}
#mml-preview-footer button {
  padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600;
  background: var(--bg-3); border: 1px solid var(--line-strong); color: var(--ink-0);
  cursor: pointer;
}
#mml-preview-footer button:hover { background: var(--bg-4); }
#mml-play-stop { margin-left: auto; }
#mml-preview-resize {
  position: absolute; bottom: 0; right: 0;
  width: 16px; height: 16px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(85,119,221,0.5) 50%);
  border-radius: 0 0 8px 0;
}

/* MML part colors on markers */
.marker.mml-part1 { fill: rgba(233,69,96,0.8); stroke: #e94560; stroke-width: 1.5; }
.marker.mml-part2 { fill: rgba(68,187,136,0.8); stroke: #44bb88; stroke-width: 1.5; }
.marker.mml-part3 { fill: rgba(85,119,221,0.8); stroke: #5577dd; stroke-width: 1.5; }
.marker.mml-unassigned { fill: rgba(136,136,136,0.5); stroke: #888; stroke-width: 1; }

/* MML part colors on TL blocks */
.tl-note.mml-part1 { background: linear-gradient(135deg, #b8254a, #e94560) !important; }
.tl-note.mml-part2 { background: linear-gradient(135deg, #2a8866, #44bb88) !important; }
.tl-note.mml-part3 { background: linear-gradient(135deg, #3355aa, #5577dd) !important; }
.tl-note.mml-unassigned { background: linear-gradient(135deg, #555, #777) !important; }

/* Dim markers in MML mode for unassigned */
body.mode-mml .marker.mml-unassigned { opacity: 0.45; }
/* C4: Overlap warning — pulsing ring */
.marker.mml-overlap { stroke: #ff0 !important; stroke-width: 3px !important; animation: mml-overlap-pulse 0.8s ease-in-out infinite alternate; }
@keyframes mml-overlap-pulse { from { stroke-opacity: 0.5; } to { stroke-opacity: 1; } }
.mml-tick-count { font-weight: 400; font-size: 10px; opacity: .6; }
