/* ==========================================================================
   Partituras — tema claro (único tema de la aplicación, por requisito)
   ========================================================================== */
:root {
  color-scheme: light only;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #1d2433;
  --text-2: #475467;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ring: rgba(79, 70, 229, 0.25);
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --piano: #0e7490;
  --piano-soft: #ecfeff;
  --guitar: #b45309;
  --guitar-soft: #fff7ed;
  --d1: #16a34a; --d2: #65a30d; --d3: #ca8a04; --d4: #ea580c; --d5: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 4px 12px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --topbar-h: 60px;
  --sidebar-w: 264px;
  --details-w: 340px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); overflow: hidden; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
code { font-size: 0.9em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.grow { flex: 1; min-width: 0; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- controles base ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 0.9rem; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); border-color: #fecdca; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.small { padding: 4px 10px; font-size: 0.8rem; }
.btn .icon { width: 16px; height: 16px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-2); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.tiny { width: 24px; height: 24px; border-radius: 6px; }
.icon-btn.tiny .icon { width: 14px; height: 14px; }
.icon-btn.toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: #c7d2fe; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- barra superior ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); width: calc(var(--sidebar-w) - 30px); }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; }
.brand-mark .icon { width: 18px; height: 18px; }
.search { flex: 1; max-width: 520px; position: relative; flex-direction: row; align-items: center; }
.search > span { position: absolute; left: 11px; color: var(--muted); display: flex; }
.search input { padding-left: 36px; background: var(--surface-2); border-color: var(--border); }
.topbar .btn.primary { margin-left: auto; }

/* ---------- layout ---------- */
.layout { position: fixed; inset: var(--topbar-h) 0 0 0; display: flex; }
main { flex: 1; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ---------- barra lateral ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none; overflow-y: auto; padding: 14px 10px 24px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--text-2); font-weight: 500; text-align: left; cursor: pointer; transition: background .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active .count { background: #e0e7ff; color: var(--accent); }
.nav-item.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.count { font-size: 0.75rem; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.nav-fixed { display: flex; flex-direction: column; gap: 2px; }
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 4px 6px 10px; font-size: 0.75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.tree-row { padding-left: calc(4px + var(--depth) * 16px); }
.tree-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .folder-icon { color: #98a2b3; }
.tree-row.active .folder-icon { color: var(--accent); }
.twisty { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 4px; }
.twisty .icon { width: 14px; height: 14px; transition: transform .15s; }
.twisty.open .icon { transform: rotate(90deg); }
.twisty.invisible { visibility: hidden; }
.row-actions { display: none; gap: 1px; }
.tree-row:hover .row-actions, .tree-row:focus-within .row-actions { display: flex; }
.tree-row:hover .count, .tree-row:focus-within .count { display: none; }
.tree-empty { padding: 4px 12px; }
.sidebar-hint { margin: 18px 10px 0; font-size: 0.78rem; color: var(--muted); }
.backdrop { display: none; }

/* ---------- biblioteca ---------- */
.library { flex: 1; overflow-y: auto; padding: 28px 32px 48px; }
.library-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.eyebrow { font-size: 0.8rem; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.library-head h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select { width: auto; padding: 7px 10px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.segmented button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; font-weight: 600; font-size: 0.85rem; color: var(--text-2); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.score-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.score-card {
  display: flex; flex-direction: column; gap: 6px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s, transform .15s;
}
.score-card:hover { border-color: #c7d2fe; box-shadow: var(--shadow); transform: translateY(-1px); }
.score-card h3 { font-size: 1.02rem; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.composer { color: var(--muted); font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-top { display: flex; gap: 6px; align-items: center; min-height: 22px; padding-right: 30px; }
/* Eliminar desde la tarjeta: papelera al pasar el ratón (siempre visible en pantallas táctiles). */
.score-card { position: relative; }
.card-delete {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--muted);
  cursor: pointer; opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.card-delete .icon { width: 16px; height: 16px; }
.score-card:hover .card-delete, .card-delete:focus-visible { opacity: 1; }
.card-delete:hover { background: var(--danger-soft); color: var(--danger); border-color: #fecdca; }
@media (hover: none) { .card-delete { opacity: 1; } }
/* Modo «Seleccionar»: la tarjeta se marca en vez de abrirse. */
.card-check {
  position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; display: none; place-items: center;
  border: 2px solid var(--border-strong, #cbd5e1); border-radius: 6px; background: var(--surface); color: #fff;
}
.card-check .icon { width: 15px; height: 15px; }
.score-grid.selecting .card-check { display: grid; }
.score-grid.selecting .card-delete { display: none; }
.score-grid.selecting .score-card { cursor: pointer; }
.score-grid.selecting .score-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft, #e0e7ff); }
.score-grid.selecting .score-card.selected .card-check { background: var(--accent); border-color: var(--accent); }
.selection-bar {
  position: sticky; top: 8px; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.selection-bar .grow { flex: 1; }
.btn.active { background: var(--accent-soft, #e0e7ff); border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.links-count { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 0.8rem; }
.links-count .icon { width: 14px; height: 14px; }
.folder-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.folder-chip .icon { width: 13px; height: 13px; }
body.dragging-score .sidebar .nav-item[data-filter="unclassified"], body.dragging-score .tree-row { outline: 1px dashed var(--border-strong); outline-offset: -1px; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 0.72rem; font-weight: 700; letter-spacing: .02em; }
.badge.piano { background: var(--piano-soft); color: var(--piano); }
.badge.guitar { background: var(--guitar-soft); color: var(--guitar); }
.badge.other { background: var(--surface-2); color: var(--muted); }

.difficulty { display: inline-flex; align-items: center; gap: 7px; font-size: 0.8rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.difficulty.none { color: var(--muted); font-weight: 500; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.d1 .dots i.on { background: var(--d1); } .d2 .dots i.on { background: var(--d2); }
.d3 .dots i.on { background: var(--d3); } .d4 .dots i.on { background: var(--d4); }
.d5 .dots i.on { background: var(--d5); }

.empty { text-align: center; padding: 64px 16px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); }
.empty-icon .icon { width: 30px; height: 30px; }
.empty h2 { font-size: 1.2rem; color: var(--text); }

/* ---------- visor ---------- */
.viewer { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.viewer-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.viewer-title { flex: 1; min-width: 160px; }
.viewer-title h1 { font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-title p { font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transport { display: flex; align-items: center; gap: 6px; }
.play-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff; cursor: pointer; box-shadow: 0 2px 8px rgba(79, 70, 229, .35);
  transition: background .15s, transform .1s;
}
.play-btn:hover:not(:disabled) { background: var(--accent-hover); }
.play-btn:active:not(:disabled) { transform: scale(.96); }
.play-btn:disabled { background: #a5b4fc; box-shadow: none; cursor: wait; }
.play-btn .icon { width: 20px; height: 20px; }
.time { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--text-2); min-width: 86px; }
.sound-status { font-size: 0.78rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.sound-select { margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--border); gap: 10px; }
.sound-select .hint, .check-row .hint { font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.sound-select .hint strong { color: var(--warn); font-weight: 600; }
.check-row { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 600; color: var(--text); cursor: pointer; }
.check-row input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.tempo.volume .icon { color: var(--text-2); }
.tempo .tempo-icon { display: none; }
.tempo.volume input { width: 90px; }
.viewer-tools { display: flex; align-items: center; gap: 4px; }
.tempo { flex-direction: row; align-items: center; gap: 8px; margin-right: 6px; font-weight: 600; }
.tempo input { width: 110px; padding: 0; border: 0; accent-color: var(--accent); box-shadow: none; }
.tempo output { font-variant-numeric: tabular-nums; min-width: 40px; color: var(--text); }
.divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 260px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.menu-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 6px 8px; }
.check { flex-direction: row; align-items: center; gap: 8px; padding: 6px; border-radius: 6px; font-weight: 500; color: var(--text); cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check input { width: auto; accent-color: var(--accent); }

.viewer-body { flex: 1; display: flex; min-height: 0; }
/* isolation: el cursor de alphaTab usa z-index 1000; sin esto se ve por encima del panel de detalles en móvil. */
.sheet-scroll { flex: 1; min-width: 0; overflow: auto; position: relative; isolation: isolate; background: var(--bg); padding: 20px; }
.sheet-paper { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 8px; min-height: 60vh; max-width: 1200px; margin: 0 auto; }
.sheet-status {
  position: absolute; top: 40px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 99px; box-shadow: var(--shadow); font-weight: 500; color: var(--text-2);
}

/* alphaTab: cursor y selección en el color de acento */
.at-cursor-bar { background: rgba(79, 70, 229, 0.07); }
.at-selection div { background: rgba(79, 70, 229, 0.14); }
.at-cursor-beat { background: var(--accent); width: 3px; }
.at-highlight * { fill: var(--accent); stroke: var(--accent); }

/* ---------- modo práctica (piano MIDI) ---------- */
#sheet { position: relative; }
.pr-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 999; pointer-events: none; }
.pr-mark { position: absolute; border-radius: 50%; box-sizing: border-box; }
.pr-mark.expected { border: 2.5px solid var(--accent); background: rgba(79, 70, 229, 0.15); animation: pr-pulse 1.2s ease-in-out infinite; }
.pr-mark.hit { border: 2.5px solid var(--ok); background: rgba(6, 118, 71, 0.25); }
.pr-mark.done { border: 2.5px solid var(--ok); background: rgba(6, 118, 71, 0.22); animation: pr-fade 0.9s ease-out forwards; }
@keyframes pr-pulse { 50% { box-shadow: 0 0 0 5px rgba(79, 70, 229, 0.18); } }
@keyframes pr-fade { to { opacity: 0; transform: scale(1.5); } }

.icon-btn.live { position: relative; }
.icon-btn.live::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px var(--surface); }

.practice {
  display: grid; grid-template-columns: 260px 210px 1fr; gap: 18px; align-items: start;
  padding: 12px 16px 14px; background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.05);
}
.practice-info { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.midi-status { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; }
.midi-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); flex: none; }
.midi-status[data-state="connected"] .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.midi-status[data-state="waiting"] .dot { background: #f5b83d; animation: pr-blink 1.2s infinite; }
.midi-status[data-state="insecure"] .dot, .midi-status[data-state="denied"] .dot, .midi-status[data-state="unsupported"] .dot { background: var(--danger); }
@keyframes pr-blink { 50% { opacity: .3; } }
.midi-help { font-size: 0.8rem; line-height: 1.45; color: var(--text-2); background: var(--warn-soft); border: 1px solid #fedf89; border-radius: var(--radius-sm); padding: 8px 10px; }
.midi-help code { background: #fff; }
.segmented.small button { padding: 3px 10px; font-size: 0.8rem; }
.practice-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.practice-staff { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#live-staff { width: 200px; height: 170px; }
.ls-lines line { stroke: #98a2b3; stroke-width: 1; }
.ls-ledger { stroke: #667085; stroke-width: 1.3; }
.ls-clef { font-family: "Segoe UI Symbol", "Noto Music", "Bravura Text", serif; fill: var(--text); }
.ls-clef.treble { font-size: 46px; }
.ls-clef.bass { font-size: 30px; }
.ls-acc { font-size: 14px; fill: var(--text); font-family: "Segoe UI Symbol", system-ui, sans-serif; }
.ls-head { fill: var(--accent); }
.ls-head.expected { fill: none; stroke: var(--ok); stroke-width: 2; stroke-dasharray: 3 2; }
.ls-head.wrong, .ls-acc.wrong { fill: var(--danger); }
.ls-acc.expected { fill: var(--ok); }
.live-names { min-height: 22px; font-weight: 700; font-size: 1rem; text-align: center; }
.live-names small { font-weight: 500; color: var(--muted); font-size: 0.75rem; }
.live-names .bad { color: var(--danger); }
.live-names .pedal { font-size: 0.75rem; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.practice-keys { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
#live-keys { width: 100%; height: 120px; display: block; }
.kb-white { fill: #fff; stroke: #c4c9d4; stroke-width: 1; }
.kb-black { fill: #2b3140; stroke: #1d2433; stroke-width: 1; }
.kb-white.expected, .kb-black.expected { fill: #b7ebc9; }
.kb-white.held, .kb-black.held { fill: var(--accent); }
.kb-white.held.expected, .kb-black.held.expected { fill: var(--ok); }
.kb-white.wrong, .kb-black.wrong { fill: var(--danger); }
.kb-label { font-size: 9px; fill: var(--muted); text-anchor: middle; pointer-events: none; }
.practice-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.lg { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; }
.lg.held { background: var(--accent); }
.lg.expected { background: #b7ebc9; border: 1px solid var(--ok); }
.lg.wrong { background: var(--danger); }

/* notas que suenan en la reproducción (distinto de lo que pulsa el usuario) */
.ls-head.playing { fill: #a5b4fc; }
.ls-acc.playing { fill: #6366f1; }
.ls-head.past { fill: #475467; }
.ls-acc.past { fill: #475467; }
.ls-name { font-size: 8.5px; font-weight: 600; fill: var(--accent); font-family: system-ui, sans-serif; }
.ls-name.past { fill: var(--muted); font-weight: 500; }
.kb-white.playing, .kb-black.playing { fill: #c7d2fe; }
.kb-white.playing.held, .kb-black.playing.held { fill: var(--accent); }
.kb-label.on { fill: #fff; font-weight: 700; }
.kb-label.black { font-size: 7px; }
.live-names .play { color: #6366f1; }
.live-names .muted-label { font-weight: 500; color: var(--muted); font-size: 0.85rem; }
.lg.playing { background: #c7d2fe; border: 1px solid #a5b4fc; }

/* ---------- Teclado y pentagrama (herramienta) ---------- */
.explorer { flex: 1; overflow-y: auto; padding: 28px 32px 40px; display: flex; flex-direction: column; gap: 16px; }
.explorer > * { flex-shrink: 0; } /* sin esto el pentagrama y el teclado se aplastan en pantallas bajas */
.explorer-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.explorer-head h1 { font-size: 1.6rem; }
.explorer-head .muted { margin-top: 4px; }
.explorer-midi { display: flex; align-items: center; gap: 12px; }
.explorer-options { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; }
.explorer-options label.inline { flex-direction: row; align-items: center; gap: 8px; }
.explorer-options select { width: auto; }
.explorer-readout {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 18px; min-height: 86px; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.ex-note { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.01em; color: var(--accent); }
.ex-note small { font-size: 1rem; font-weight: 600; color: var(--muted); margin-left: 6px; }
.ex-note .muted { font-weight: 600; font-size: 1.3rem; }
.ex-note .pedal { font-size: 0.8rem; vertical-align: middle; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }
.ex-detail { font-size: 0.92rem; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.ex-staff-wrap {
  overflow-x: auto; overflow-y: hidden; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 4px;
}
#ex-staff { display: block; height: 300px; }
#ex-staff .ls-clef.treble { font-size: 46px; }
.ex-keys-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
#ex-keys { display: block; width: 100%; min-width: 900px; height: auto; aspect-ratio: 1040 / 90; cursor: pointer; touch-action: none; user-select: none; }
body.in-explorer .nav-item[data-filter].active { background: none; color: var(--text-2); }
body.in-explorer .nav-item[data-filter].active .count { background: var(--surface-2); color: var(--muted); }

/* ---------- grabación (en Teclado y pentagrama) ---------- */
.rec-card {
  display: flex; align-items: center; gap: 14px 20px; flex-wrap: wrap; padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.rec-card[data-state="recording"], .rec-card[data-state="countin"] { border-color: #fda29b; box-shadow: 0 0 0 3px #fee4e2; }
.rec-btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 99px; cursor: pointer;
  border: 1px solid #fecdca; background: #fff; color: var(--danger); font-weight: 700; font-size: 1rem;
}
.rec-btn:hover { background: var(--danger-soft); }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--danger); }
.rec-btn.on { background: var(--danger); color: #fff; border-color: var(--danger); }
.rec-btn.on .rec-dot { border-radius: 3px; background: #fff; animation: pr-blink 1s infinite; }
.rec-settings { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.rec-settings input[type="number"] { width: 72px; }
.rec-settings select, .ed-settings select { width: auto; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
.rec-status { flex-basis: 100%; }
.rec-card[data-state="recording"] .rec-status, .rec-card[data-state="countin"] .rec-status { color: var(--danger); font-weight: 700; font-size: 0.95rem; }
.rec-list-wrap h2 { font-size: 1.05rem; margin-bottom: 10px; }
.rec-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rec-list li { display: flex; align-items: center; gap: 6px; }
.rec-item {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.rec-item:hover { border-color: #c7d2fe; background: var(--surface-2); }
.rec-item strong, .rec-item .small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-item-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-weight: 700; flex: none; }

/* ---------- editor de grabaciones ---------- */
.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor > * { flex-shrink: 0; }
.editor .ed-sheet-scroll { flex: 1 1 auto; min-height: 200px; }
.ed-title { flex: 1; min-width: 160px; max-width: 420px; font-weight: 700; font-size: 1.05rem; border-color: transparent; background: transparent; }
.ed-title:hover, .ed-title:focus { border-color: var(--border-strong); background: var(--surface); }
.ed-save { min-width: 70px; }
.ed-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.ed-actions .btn:disabled { opacity: .55; cursor: default; }
.ed-settings, .ed-tools {
  display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.ed-settings input[type="number"] { width: 72px; }
.ed-tools { gap: 6px; }
.ed-group { display: inline-flex; gap: 4px; }
.ed-tool {
  min-width: 38px; height: 36px; padding: 0 10px; display: inline-grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 0.9rem;
}
.ed-tool:hover { background: var(--surface-2); }
.ed-tool.active { box-shadow: inset 0 -3px 0 var(--accent); }
.ed-tool.current { background: var(--accent-soft); border-color: #c7d2fe; color: var(--accent); }
.ed-tool.danger { color: var(--danger); }
.ed-tool .icon { width: 16px; height: 16px; }
.dur-sym { font-family: "Segoe UI Symbol", "Noto Music", "Bravura Text", serif; font-size: 1.35rem; line-height: 1; }
.ed-info { padding: 8px 16px; font-size: 0.9rem; background: var(--accent-soft); color: var(--text-2); border-bottom: 1px solid #e0e7ff; }
.ed-info strong { color: var(--accent); }
/* Partitura escrita desde cero vs. grabación: cada una muestra sus ajustes. */
.editor.composing .rec-only, .editor:not(.composing) .compose-only { display: none !important; }
.ed-measures { display: inline-flex; align-items: center; gap: 6px; }
.ed-tool.small { min-width: 28px; height: 28px; padding: 0 6px; }
#ed-composer { width: 160px; }
.ed-kb { flex-shrink: 0; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); padding: 6px 16px; }
#ed-kb { display: block; width: 100%; min-width: 640px; max-height: 110px; cursor: pointer; touch-action: none; user-select: none; }
.compose-drafts { border-top: 1px solid var(--border); padding-top: 12px; }
.compose-drafts .eyebrow { margin-bottom: 8px; }
.ed-help { padding: 8px 16px 12px; background: var(--surface); border-top: 1px solid var(--border); line-height: 1.8; }
kbd { font: 600 0.75rem system-ui, sans-serif; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: #fff; }
.pr-mark.ed-sel { border: 2.5px solid var(--accent); background: rgba(79, 70, 229, 0.2); border-radius: 50%; }
.pr-mark.ed-sel.rest { border-radius: 8px; border-style: dashed; background: rgba(79, 70, 229, 0.08); }
#ed-sheet { position: relative; }

/* ---------- progreso / evaluación ---------- */
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.progress { background: var(--surface-2); color: var(--text-2); }
.progress-box { margin-bottom: 20px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.progress-box.done { background: var(--ok-soft); border-color: #abefc6; }
.progress-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.progress-head h3 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.progress-status { font-size: 0.88rem; color: var(--text-2); line-height: 1.45; }
.done-badge { font-weight: 800; color: var(--ok); }
.progress-history { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 0.8rem; color: var(--text-2); }
.progress-history li { display: flex; gap: 8px; }
.progress-history strong.ok { color: var(--ok); }
.practice-result { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 0.85rem; line-height: 1.45; background: var(--surface-2); }
.practice-result > div:last-child { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.practice-result .result-score { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.practice-result.ok { background: var(--ok-soft); border-color: #abefc6; }
.practice-result.ok .result-score { color: var(--ok); }
.practice-result.warn { background: var(--warn-soft); border-color: #fedf89; }
.practice-result.warn .result-score { color: var(--warn); }
.practice-result.info .result-score { color: var(--accent); }

/* ---------- criterios y resultado de evaluación ---------- */
.link-btn { margin-top: 8px; padding: 0; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 0.82rem; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.eval-big { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.eval-fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px 10px; margin: 0; }
.eval-fieldset legend { font-size: 0.85rem; font-weight: 700; color: var(--text-2); padding: 0 4px; }
.eval-criteria { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.eval-crit .hint { display: block; font-weight: 400; }
.inline-input { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.inline-input input { width: 80px; }
.hint { font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.result-summary { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.result-overall { font-size: 2.6rem; font-weight: 800; line-height: 1; color: var(--accent); }
.result-overall.ok { color: var(--ok); }
.result-overall.warn { color: var(--warn); }
.result-message { font-size: 0.95rem; line-height: 1.5; color: var(--text-2); }
.result-criteria { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.result-criteria li { display: grid; grid-template-columns: 90px 1fr 52px; grid-template-rows: auto auto; column-gap: 10px; align-items: center; }
.rc-label { font-weight: 700; font-size: 0.88rem; }
.rc-bar { position: relative; height: 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: visible; }
.rc-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--accent); }
.rc-bar b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text-2); opacity: .5; }
.rc-value { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.rc-detail { grid-column: 2 / 4; font-size: 0.76rem; color: var(--muted); }
.result-criteria li.ok .rc-bar i { background: var(--ok); }
.result-criteria li.ok .rc-value { color: var(--ok); }
.result-criteria li.bad .rc-bar i { background: var(--warn); }
.result-criteria li.bad .rc-value { color: var(--warn); }
.result-criteria li.off { opacity: .5; }
.result-measures h3 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 8px; }
.measure-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.measure-chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 10px; border: 1px solid #fedf89; background: var(--warn-soft); border-radius: var(--radius-sm); cursor: pointer; font-weight: 700; font-size: 0.82rem; color: var(--text); }
.measure-chip span { font-weight: 500; font-size: 0.72rem; color: var(--text-2); }
.measure-chip:hover { border-color: var(--warn); }
@media (max-width: 560px) {
  .eval-criteria { grid-template-columns: 1fr; }
  .result-criteria li { grid-template-columns: 76px 1fr 44px; }
}

.details { width: var(--details-w); flex: none; overflow-y: auto; padding: 18px; background: var(--surface); border-left: 1px solid var(--border); }
body.details-hidden .details { display: none; }
.section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.section h3 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.links, .parts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.links li { display: flex; align-items: center; gap: 4px; }
.link-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); transition: border-color .15s, background .15s; }
.link-item:hover { border-color: #c7d2fe; background: var(--surface-2); }
.link-item strong, .link-item .small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-item strong { font-size: 0.88rem; }
.link-kind { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; flex: none; background: var(--surface-2); color: var(--muted); }
.link-kind.video { background: #fef3f2; color: #d92d20; }
.link-kind.tutorial { background: var(--accent-soft); color: var(--accent); }
.link-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.parts li { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
#stave-profile-wrap { margin-top: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
#file-info { margin-top: 12px; word-break: break-all; }

/* ---------- diálogos ---------- */
.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--border);
  border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog.wide { width: min(640px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(16, 24, 40, 0.35); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dialog-head h2 { font-size: 1.15rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
#confirm-message { line-height: 1.5; }
.dropzone {
  align-items: center; text-align: center; gap: 6px; padding: 28px 16px; margin-bottom: 14px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  color: var(--text); font-weight: 500; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); margin-bottom: 4px; }
.dropzone .muted { font-size: 0.8rem; }
.upload-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.upload-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 0.88rem; }
.upload-list li strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list .msg { display: block; font-size: 0.82rem; }
.upload-list li.ok { background: var(--ok-soft); border-color: #abefc6; }
.upload-list li.ok .status-icon { color: var(--ok); }
.upload-list li.warn { background: var(--warn-soft); border-color: #fedf89; }
.upload-list li.warn .status-icon { color: var(--warn); }
.upload-list li.error { background: var(--danger-soft); border-color: #fecdca; }
.upload-list li.error .status-icon { color: var(--danger); }
.inline-actions { display: flex; gap: 6px; }

.drop-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(79, 70, 229, 0.08); border: 3px dashed var(--accent); pointer-events: none; }
.drop-overlay > div { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 36px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); color: var(--accent); font-weight: 700; }
.drop-overlay .icon { width: 32px; height: 32px; }

/* ---------- toast y spinner ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 10px; background: #1d2433; color: #fff; font-weight: 500; font-size: 0.9rem;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok .icon { color: #75e0a7; }
.toast.error { background: var(--danger); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
.spinner.small { width: 16px; height: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cuentas: inicio de sesión, menú del usuario, administración ---------- */
body.booting .topbar, body.booting .layout { visibility: hidden; }
body.logged-out .topbar, body.logged-out .layout { display: none; }
.login-view { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: var(--bg); overflow-y: auto; }
.login-card {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px 26px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.3rem; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.login-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 0.88rem; }
.login-card .btn.primary { justify-content: center; padding: 10px; }

.user-menu { flex: none; }
.topbar .btn.primary + .user-menu { margin-left: 0; }
.user-btn {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid transparent; border-radius: 99px;
  background: none; color: var(--text); font-weight: 600; cursor: pointer; max-width: 200px;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border); }
.user-btn > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.avatar.small { width: 28px; height: 28px; font-size: 0.85rem; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font-weight: 500; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }
.admin-only { display: none; }
body.is-admin .admin-only { display: revert; }
body.is-admin .menu-item.admin-only { display: flex; }

.admin-list { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow-y: auto; }
.admin-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.admin-list li.inactive { opacity: .6; }
.admin-list .badge { margin-left: 4px; }
.admin-list .btn .icon { width: 14px; height: 14px; }
.block { display: block; }
.row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-inline input { flex: 1; min-width: 160px; }
.key-created { margin: 12px 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); display: flex; flex-direction: column; gap: 8px; }
.key-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.key-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 6px 8px; background: var(--surface); border-radius: 6px; color: var(--text); font-size: 0.85rem; }
.check-row.align-end { align-self: flex-end; margin-bottom: 8px; }
#user-new .inline-input input { width: auto; flex: 1; min-width: 0; }

/* ---------- bibliotecas: personal y global ---------- */
.library-switch { display: flex; width: 100%; margin-bottom: 12px; }
.library-switch button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 5px 6px; white-space: nowrap; font-size: 0.82rem; }
.library-switch .icon { width: 15px; height: 15px; }
.readonly-note {
  display: flex; align-items: flex-start; gap: 8px; margin: -8px 0 18px; padding: 10px 12px;
  background: var(--accent-soft); color: var(--text-2); border-radius: var(--radius-sm); font-size: 0.88rem;
}
.readonly-note .icon { width: 18px; height: 18px; color: var(--accent); flex: none; margin-top: 1px; }
.readonly-note[hidden] { display: none; }
.row-actions.hidden { display: none !important; }
body.lib-readonly #upload-btn, body.lib-readonly #select-mode-btn, body.lib-readonly #empty-upload-btn,
body.lib-readonly .sidebar-hint { display: none; }
body.lib-global .brand-mark { background: #0e7490; }
.library-box { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.library-box .btn .icon { width: 14px; height: 14px; }
body.score-readonly #meta-form input, body.score-readonly #meta-form select, body.score-readonly #meta-form textarea {
  background: var(--surface-2); color: var(--text-2);
}

/* ---------- responsive ---------- */
.only-mobile { display: none; }
body.in-viewer .sidebar { display: none; }
body.in-viewer .only-mobile { display: inline-grid; }
body.in-viewer .brand { width: auto; }
body.in-viewer.sidebar-open .sidebar { display: block; }

@media (max-width: 1100px) {
  .tempo input { width: 80px; }
  .practice { grid-template-columns: 240px 200px 1fr; }
}

@media (max-width: 900px) {
  .only-mobile { display: inline-grid; }
  .brand { width: auto; }
  .brand span:last-child { display: none; }
  .sidebar, body.in-viewer .sidebar {
    display: block; position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 25;
    transform: translateX(-100%); transition: transform .2s;
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open .backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 24; background: rgba(16, 24, 40, .3); }
  .row-actions { display: flex; }
  .tree-row .count { display: none; }
  .sidebar-hint { display: none; }
  .library { padding: 20px 16px 40px; }
  .library-head h1 { font-size: 1.35rem; }
  .viewer-bar { gap: 8px; padding: 8px 12px; }
  .viewer-title { order: 0; flex-basis: calc(100% - 50px); }
  .transport { order: 1; }
  .viewer-tools { order: 2; margin-left: auto; }
  .tempo .tempo-text { display: none; }
  .tempo .tempo-icon { display: flex; color: var(--text-2); }
  .details { position: fixed; right: 0; top: var(--topbar-h); bottom: 0; z-index: 22; width: min(var(--details-w), 92vw); box-shadow: var(--shadow-lg); }
  .sheet-scroll { padding: 8px; }
  .practice { grid-template-columns: 1fr 150px; gap: 10px; padding: 10px 12px; max-height: 48vh; overflow-y: auto; }
  .practice-keys { grid-column: 1 / -1; }
  #live-staff { width: 150px; height: 128px; }
  #live-keys { height: 90px; }
  .practice-legend { display: none; }
  .explorer { padding: 18px 14px 32px; gap: 12px; }
  .ed-help { display: none; }
  .ed-actions { margin-left: 0; }
  .ed-settings, .ed-tools { padding: 8px 12px; }
  .explorer-head h1 { font-size: 1.35rem; }
  #ex-staff { height: 220px; }
  .ex-note { font-size: 1.5rem; }
  .sheet-paper { padding: 8px 0; border-radius: 8px; }
}

@media (max-width: 560px) {
  .hide-mobile { display: none; }
  .user-btn { padding: 2px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .btn.primary { padding: 8px 10px; }
  .filters { width: 100%; }
  .filters select { flex: 1; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .score-grid { grid-template-columns: 1fr; }
  .divider, #zoom-out, #zoom-in { display: none; }
  .tempo input, .tempo.volume input { width: 64px; }
  .tempo output { display: none; }
  .time { min-width: 0; }
  .row { flex-direction: column; }
}
