﻿/* ── Keyboard shortcut bindings ── */
.kb-bindings-table {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.kb-row {
  display: grid;
  grid-template-columns: 70px 18px 60px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(127,127,127,0.06);
  font-size: 13px;
}
.kb-row:hover { background: rgba(127,127,127,0.12); }
.kb-key {
  display: inline-block;
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 0 1px 0 #999;
  color: #222;
}
.kb-arrow { color: #888; font-weight: 600; }
.kb-note { font-weight: 600; }
.kb-rebind-btn, .kb-remove-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(127,127,127,0.3);
  background: transparent;
  cursor: pointer;
}
.kb-remove-btn { color: #c44; padding: 4px 8px; }
.kb-rebind-btn:hover { background: rgba(94,92,230,0.12); border-color: #5E5CE6; color: #5E5CE6; }
.kb-row-add {
  grid-template-columns: 1fr auto;
  margin-top: 6px;
  padding: 8px 6px;
  background: rgba(94,92,230,0.06);
}
.kb-row-add input {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(127,127,127,0.3);
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* ── Web login overlay (shown on first visit outside Telegram) ── */
#web-login-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 106, 0, 0.10), transparent 30%),
    #050505;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.web-login-card {
  background: #0f0f13;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 40px 32px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
}

.web-login-logo {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.web-login-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 24px;
}

.web-login-brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #ff6a00;
  margin-bottom: 6px;
}

.web-login-hint {
  color: #9ea0aa;
  margin: 0 0 28px;
  font-size: 14px;
}

.web-login-input {
  width: 100%;
  background: #101010;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 16px;
  color: #f2f2f4;
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.web-login-input:focus {
  border-color: #ff6a00;
}

.web-login-btn {
  width: 100%;
  background: #ff6a00;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

.web-login-btn:hover {
  opacity: 0.88;
}

/* ── Bottom nav overrides (4 items, clean grid) ── */
.bottom-nav {
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 4px;
}
.nav-item {
  font-size: 12px;
  border-radius: 12px;
  transition: all 0.18s ease;
}
.nav-item.active {
  background: rgba(255, 106, 0, 0.12);
  color: var(--orange-2);
  box-shadow: inset 0 0 0 1px rgba(255, 106, 0, 0.3);
}
.nav-item:hover:not(.active) {
  background: rgba(255,255,255,0.04);
  color: #c7cad5;
}

/* ── Learning screen ── */
.learn-stats-row {
  display: flex;
  justify-content: space-around;
  padding: 4px 0;
}
.learn-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.learn-stat-val {
  font-size: 22px;
  font-weight: 700;
  color: #ff6a00;
}
.learn-stat-lbl {
  font-size: 11px;
  color: #9ea0aa;
}
.theme-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  gap: 8px;
}
.theme-item:last-child { border-bottom: none; }
.theme-item-title { font-size: 14px; font-weight: 500; flex: 1; }
.theme-item-progress { font-size: 12px; color: #9ea0aa; white-space: nowrap; }
.theme-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.theme-progress-fill {
  height: 100%;
  background: #ff6a00;
  border-radius: 2px;
  transition: width 0.3s;
}
.lesson-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
}
.lesson-item:last-child { border-bottom: none; }
.lesson-item-title { font-size: 14px; flex: 1; }
.lesson-status-done { color: #4caf50; font-size: 16px; }
.lesson-status-locked { color: #555; font-size: 16px; }
.lesson-status-available { color: #ff6a00; font-size: 16px; }
.learn-content {
  font-size: 14px;
  line-height: 1.7;
  color: #d0d0d8;
  white-space: pre-wrap;
  margin: 8px 0;
}
.learn-section { margin-top: 16px; }
.learn-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #ff6a00;
  margin-bottom: 8px;
}
.learn-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}
.badge-done { background: rgba(76,175,80,0.15); color: #4caf50; }
.badge-available { background: rgba(255,106,0,0.12); color: #ff6a00; }
.badge-locked { background: rgba(255,255,255,0.06); color: #9ea0aa; }
.question-item {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.question-item:last-child { border-bottom: none; margin-bottom: 0; }
.question-prompt {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 10px;
  line-height: 1.5;
}
.option-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: #f2f2f4;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.option-btn:hover:not(:disabled) { background: rgba(255,106,0,0.1); border-color: rgba(255,106,0,0.4); }
.option-btn.selected { background: rgba(255,106,0,0.18); border-color: #ff6a00; }
.option-btn.correct { background: rgba(76,175,80,0.2); border-color: #4caf50; }
.option-btn.wrong { background: rgba(220,50,50,0.15); border-color: #dc3232; }
.option-btn:disabled { cursor: default; }

/* ── Library screen ── */
.lib-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.lib-search-row .field-input { flex: 1; margin: 0; }
.lib-file-item {
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.lib-file-item:last-child { border-bottom: none; }
.lib-file-name { font-size: 14px; font-weight: 500; margin-bottom: 3px; }
.lib-file-date { font-size: 12px; color: #9ea0aa; margin-bottom: 8px; }
.lib-file-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-btn {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: #f2f2f4;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.lib-btn:hover { background: rgba(255,106,0,0.15); border-color: rgba(255,106,0,0.5); }
.lib-btn.danger { border-color: rgba(220,50,50,0.3); }
.lib-btn.danger:hover { background: rgba(220,50,50,0.2); border-color: #dc3232; }
.lib-btn.accent { background: rgba(255,106,0,0.18); border-color: #ff6a00; }

/* ── Profile screen ── */
.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 0 10px;
}
.profile-avatar {
  font-size: 36px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,106,0,0.1);
  border-radius: 50%;
  border: 2px solid rgba(255,106,0,0.25);
  flex-shrink: 0;
}
.profile-name { font-size: 18px; font-weight: 700; }
.profile-sub {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.sub-free { background: rgba(255,255,255,0.06); color: #9ea0aa; }
.sub-pro { background: rgba(255,106,0,0.2); color: #ff6a00; }
/* ────────────────────────────────────────────────────────────── */

:root {
  --bg: #050505;
  --bg-soft: #101010;
  --panel: #0f0f13;
  --panel-2: #15161c;
  --panel-3: #1f2128;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f2f2f4;
  --muted: #9ea0aa;
  --orange: #ff6a00;
  --orange-2: #ff8a00;
  --white-key: #ececec;
  --black-key: #090909;
  --danger: #6f2929;
  --ok: #214e33;
  --radius: 18px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 106, 0, 0.08), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.03), transparent 26%),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 14px 12px 92px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #b8c0d6;
}

.stats-line {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.play-main {
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 22px rgba(255, 106, 0, 0.28);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

.playback-voice-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.playback-voice-unit {
  display: grid;
  grid-template-columns: minmax(78px, auto) minmax(74px, 96px);
  align-items: center;
  gap: 8px;
}

.playback-voice-chip {
  min-height: 36px;
  padding: 8px 13px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.playback-voice-chip.active {
  background: rgba(126, 115, 255, 0.28);
  color: #fff;
}

.playback-voice-chip.muted {
  opacity: 0.62;
}

.playback-voice-chip.disabled {
  opacity: 0.46;
}

.playback-voice-slider {
  width: 100%;
  accent-color: #8b7bff;
}

.content {
  display: block;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.composer-card,
.panel-card,
.keyboard-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.composer-card {
  position: relative;
  padding: 12px;
  margin-bottom: 14px;
}

.composer-surface {
  position: relative;
  min-height: 270px;
  border-radius: 20px;
  border: 2px dashed rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0.005));
  padding: 24px;
  overflow: hidden;
}

.composer-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.composer-icon {
  font-size: 56px;
  opacity: 0.35;
}

.composer-draft {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 220px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: center;
  justify-content: center;
  align-items: center;
}

.draft-chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
  color: #f9c89b;
  font-family: Consolas, monospace;
}

.composer-side-actions {
  position: absolute;
  top: 22px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-btn,
.pill,
.duration-btn,
.dot-btn,
.action-chip,
.dyn-btn,
.secondary-wide,
.primary-wide,
.toggle-row,
.nav-item,
.mini-select,
.field-input,
.oct-btn {
  border: 1px solid var(--line);
}

.side-btn {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--panel-2);
  color: #d7d7dc;
  font-size: 22px;
}

.compact-card,
.keyboard-card,
.panel-card {
  padding: 14px;
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.section-title.no-margin {
  margin-bottom: 0;
}

.pill-row,
.duration-row,
.score-actions-row,
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill,
.duration-btn,
.dot-btn,
.action-chip,
.dyn-btn,
.secondary-wide,
.primary-wide,
.toggle-row,
.oct-btn {
  border-radius: 16px;
  background: var(--panel-2);
  color: #e6e7ea;
  padding: 12px 14px;
  min-height: 48px;
}

.pill.active,
.duration-btn.active,
.dyn-btn.active,
.action-chip.active {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.pill.accent-outline,
.dot-btn.active {
  border-color: rgba(255, 106, 0, 0.45);
  color: #fff;
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
}

.icon-pill {
  width: 48px;
  padding: 12px 0;
}

.duration-btn {
  min-width: 68px;
  justify-content: center;
}

.dot-btn {
  width: 52px;
  font-size: 22px;
  font-weight: 800;
  background: var(--panel-2);
  color: #eceef3;
}

.insert-stack,
.group-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insert-row,
.group-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.insert-row.single-row {
  align-items: center;
}

.insert-label {
  width: 104px;
  flex: 0 0 104px;
  padding-top: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
}

.insert-row.single-row .insert-label,
.group-row .insert-label {
  padding-top: 0;
}

.insert-control,
.group-control-row {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-control-row {
  flex-wrap: nowrap;
  align-items: center;
}

.wide-chip {
  width: 100%;
}

.action-chip,
.mini-select,
.pill,
.dyn-btn {
  min-width: 0;
}

.action-chip {
  flex: 0 0 auto;
}

.mini-select,
.field-input {
  width: 100%;
  border-radius: 14px;
  background: var(--panel-2);
  color: #fff;
  padding: 12px 14px;
}

.insert-control .mini-select {
  flex: 1 1 220px;
}

.keyboard-card {
  position: relative;
  overflow: hidden;
  padding-bottom: 18px;
}

.octave-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.oct-btn {
  width: 44px;
  background: var(--panel-2);
  color: #fff;
}

.oct-label {
  min-width: 92px;
  text-align: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: #d8dae0;
  font-weight: 700;
}

.piano-wrap {
  width: 100%;
}

.piano-frame {
  width: 100%;
  overflow: hidden;
  border-radius: 18px;
  background: #0a0a0d;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.piano {
  position: relative;
  width: 100%;
  height: clamp(152px, 32vw, 190px);
  overflow: hidden;
}

.white-keys {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.piano-key {
  user-select: none;
}

.piano-key.white {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 14px;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, #ffffff, var(--white-key));
  color: #47484f;
  font-weight: 700;
  box-shadow: inset 0 -12px 0 rgba(0, 0, 0, 0.08);
}

.piano-key.black {
  position: absolute;
  top: 0;
  z-index: 2;
  width: 8.9%;
  height: 58%;
  transform: translateX(-50%);
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, #1d1d22, var(--black-key));
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.piano-key.playing {
  filter: brightness(1.2);
}

.key-cs { left: 14.35%; }
.key-ds { left: 28.65%; }
.key-fs { left: 57.25%; }
.key-gs { left: 71.55%; }
.key-as { left: 85.85%; }

.dynamic-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.keyboard-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.top-editor-actions {
  margin-bottom: 14px;
  grid-template-columns: 1fr 1fr 1fr;
}

.secondary-wide,
.primary-wide {
  width: 100%;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.secondary-wide {
  background: var(--panel-2);
  color: #eceef3;
}

.primary-wide {
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  color: #fff;
  border-color: rgba(255, 125, 0, 0.2);
  box-shadow: 0 14px 28px rgba(255, 106, 0, 0.24);
}

.primary-wide.small,
.secondary-wide.small {
  width: auto;
  min-width: 180px;
}

.editor-textarea {
  width: 100%;
  border-radius: 18px;
  background: #0a0a0d;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #eef0f6;
  padding: 16px;
  resize: vertical;
  min-height: 150px;
  line-height: 1.6;
  font-family: Consolas, monospace;
}

.token-board {
  min-height: 90px;
  border-radius: 18px;
  background: #09090c;
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 16px;
  color: #dfe3f1;
  font-family: Consolas, monospace;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score-board-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  font-family: "Inter", "Segoe UI", sans-serif;
}

.measure-board {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  text-align: left;
  color: inherit;
}

.measure-board.active {
  border-color: rgba(255, 125, 0, 0.4);
  background: rgba(255, 106, 0, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 125, 0, 0.18);
}

.measure-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-family: "Inter", "Segoe UI", sans-serif;
}

.measure-board-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.measure-board-meta {
  font-size: 11px;
  color: var(--muted);
}

.measure-board-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.score-token-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: #eceef3;
  font-family: Consolas, monospace;
  padding: 7px 11px;
  text-align: left;
}

.score-token-chip.active {
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  border-color: rgba(255, 125, 0, 0.2);
  color: #fff;
}

.score-token-chip.drag-target,
.measure-token-chip.drag-target {
  border-color: rgba(255, 125, 0, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 125, 0, 0.22);
}

.measure-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.measure-strip-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: #dfe3f1;
  padding: 8px 12px;
  min-height: 40px;
  font-size: 12px;
  font-weight: 700;
}

.compact-score-empty {
  width: 100%;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.measure-strip-chip.active {
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  border-color: rgba(255, 125, 0, 0.2);
  color: #fff;
}

.measure-strip-chip.follow {
  color: #f9c89b;
}

.score-sheet-card {
  margin-bottom: 14px;
}

.sheet-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.sheet-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: #eceef3;
  padding: 9px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.sheet-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 125, 0, 0.42);
}

.sheet-chip.active {
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  border-color: rgba(255, 125, 0, 0.2);
  color: #fff;
}

.measure-nav-row,
.instrument-settings-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.measure-nav-btn {
  width: 64px;
  min-width: 64px;
}

.measure-label {
  flex: 1;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: #fff;
  font-weight: 700;
  text-align: center;
  padding: 0 14px;
}

.measure-token-list {
  min-height: 74px;
  border-radius: 18px;
  background: #09090c;
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.measure-board-tokens.drag-target-row,
.measure-token-list.drag-target-row {
  background: rgba(255, 106, 0, 0.05);
  border-radius: 14px;
}

.measure-token-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: #eceef3;
  font-family: Consolas, monospace;
  padding: 8px 12px;
}

.measure-note-chip {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: #dfe3f1;
  font-family: Consolas, monospace;
  padding: 8px 12px;
}

.measure-note-chip.active {
  background: rgba(255, 106, 0, 0.16);
  border-color: rgba(255, 125, 0, 0.45);
  color: #fff;
}

.measure-token-chip.active {
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  border-color: rgba(255, 125, 0, 0.2);
  color: #fff;
}

.measure-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.measure-editor-box {
  margin-bottom: 12px;
}

.measure-line-textarea {
  min-height: 92px;
}

.instrument-settings-row {
  align-items: flex-end;
}

.instrument-settings-select {
  flex: 1;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.preview-card {
  overflow: hidden;
}

.preview-status {
  margin-top: 0;
  margin-bottom: 10px;
}

.preview-status.preview-status-error {
  color: #ffb2b2;
}

.preview-image {
  width: 100%;
  display: block;
  min-height: 120px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-row {
  width: 100%;
  background: var(--panel-2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-row.static-row {
  cursor: default;
}

.field-help {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* ============================================
   EDITOR SUB-NAV (Клавиатура ↔ Партитура)
   ============================================ */
.editor-subnav {
  display: none;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 4px;
  background: var(--bg-card, #1a1a24);
  border-radius: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}
body.ctx-editor .editor-subnav { display: flex; }

.editor-subnav .sub-tab {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: transparent;
  color: var(--muted, #9aa3b2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.editor-subnav .sub-tab:hover {
  color: var(--text, #fff);
  background: rgba(255,255,255,0.04);
}
.editor-subnav .sub-tab.active {
  background: linear-gradient(135deg, #6d5bff, #8b7bff);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(109, 91, 255, 0.25);
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 2px 6px;
  margin-left: 5px;
  border-radius: 999px;
  background: rgba(255, 193, 7, 0.16);
  color: #ffd36a;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.beta-badge.inline {
  vertical-align: middle;
}

.harmonization-layout {
  display: block;
}

.harmonization-card {
  max-width: 100%;
}

.harmonization-result {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.harm-result-title {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.harm-token-preview {
  margin: 10px 0;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  color: #f9c89b;
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* Topbar visibility per context */
body:not(.ctx-editor) .topbar .stats-line,
body:not(.ctx-editor) .topbar .play-main {
  display: none !important;
}
body:not(.ctx-editor) .topbar {
  justify-content: flex-start;
}

/* ============================================
   POLISH: cleaner headers, cards, preview
   ============================================ */
.topbar {
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border: 1px solid var(--line);
  border-radius: 18px;
  align-items: center !important;
  margin-bottom: 14px;
  backdrop-filter: blur(8px);
}
.brand {
  background: linear-gradient(135deg, #ff6a00, #ffb36a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Preview: bigger, framed, centered */
.preview-card {
  padding: 16px !important;
}
.preview-card .section-title {
  font-size: 16px;
  margin-bottom: 10px;
}
.preview-image {
  display: block;
  width: 100%;
  max-width: 100%;
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  min-height: 160px;
  object-fit: contain;
}
.preview-status {
  font-size: 12px;
  padding: 6px 10px;
  background: rgba(109, 91, 255, 0.08);
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 10px !important;
  color: #b8b8ff !important;
}

/* Cards: consistent spacing */
.panel-card {
  padding: 16px;
  margin-bottom: 12px;
}
.panel-card .section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.01em;
}

/* Desktop: turn bottom nav into a proper top main menu */
@media (min-width: 900px) {
  .app-shell {
    max-width: 1100px;
    padding-top: 20px;
    padding-bottom: 24px;
  }
  .bottom-nav {
    position: sticky !important;
    top: 0;
    bottom: auto !important;
    transform: none !important;
    left: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-top: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    margin-bottom: 14px;
    order: -1;
    background: rgba(10, 10, 14, 0.85);
  }
  .nav-item {
    font-size: 14px;
    padding: 14px 10px;
  }
  .app-shell {
    display: flex;
    flex-direction: column;
  }
  .topbar { order: 0; }
  .content { order: 1; }
  /* more breathing room */
  .editor-subnav {
    padding: 10px;
  }
  .editor-subnav .sub-tab {
    padding: 12px 16px;
    font-size: 15px;
  }
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(760px, 100%);
  background: rgba(0, 0, 0, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px 12px 12px;
  backdrop-filter: blur(12px);
  z-index: 300;
}

.nav-item {
  background: transparent;
  border: 0;
  color: #7f828d;
  font-weight: 700;
  padding: 12px 8px;
}

.nav-item.active {
  color: var(--orange-2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 94px;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(20, 20, 24, 0.96);
  color: #fff;
  font-size: 13px;
  z-index: 50;
  transition: opacity 0.2s ease, transform 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: rgba(110, 40, 40, 0.96);
}

@media (max-width: 640px) {
  .app-shell {
    padding-inline: 10px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .insert-row,
  .group-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .insert-label {
    width: auto;
    flex: none;
  }

  .insert-control,
  .group-control-row {
    width: 100%;
  }

  .keyboard-actions {
    grid-template-columns: 1fr;
  }

  .top-editor-actions {
    grid-template-columns: 1fr;
  }

  .play-main {
    padding: 11px 14px;
  }

  .composer-surface {
    min-height: 230px;
    padding-right: 66px;
  }

  .composer-draft {
    min-height: 180px;
  }

  .composer-side-actions {
    top: 16px;
    right: 10px;
  }

  .side-btn {
    width: 46px;
    height: 46px;
  }

  .primary-wide.small,
  .secondary-wide.small {
    min-width: 0;
    width: 100%;
  }

  .score-actions-row,
  .settings-actions {
    flex-direction: column;
  }

  .measure-nav-row,
  .instrument-settings-row {
    flex-direction: column;
    align-items: stretch;
  }

  .measure-nav-btn {
    width: 100%;
  }
}

/* ============================================
   LEGACY EDITOR / SCORE REFRESH
   Light, spacious, easier-to-scan workspace
   ============================================ */
body:not(.v2-active) {
  --bg: #fafafa;
  --bg-soft: #f3f3f5;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-2: #f6f6f8;
  --panel-3: #efeff4;
  --line: #ececef;
  --text: #0a0a0a;
  --muted: #6b6b73;
  --orange: #5e5ce6;
  --orange-2: #7270ff;
  --white-key: #fcfcfe;
  --black-key: #121216;
  --danger: #ffefee;
  --ok: #ecf9f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
  background:
    radial-gradient(circle at top left, rgba(94, 92, 230, 0.1), transparent 28%),
    radial-gradient(circle at bottom right, rgba(94, 92, 230, 0.05), transparent 24%),
    linear-gradient(180deg, #fcfcfd 0%, #f6f6f8 100%);
  color: var(--text);
}

body.ctx-editor:not(.v2-active) .bottom-nav {
  display: none;
}

body.ctx-editor:not(.v2-active) .app-shell {
  max-width: 1280px;
  padding: 20px 24px 40px;
  overflow-x: clip;
}

body:not(.v2-active) .topbar {
  position: static;
  padding: 14px 18px;
  border: 1px solid rgba(236, 236, 239, 0.92);
  border-radius: 24px;
  background: rgba(250, 250, 250, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

body:not(.v2-active) .brand {
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: none;
}

body:not(.v2-active) .stats-line {
  gap: 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

body:not(.v2-active) .play-main {
  align-self: center;
  padding: 12px 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  box-shadow: 0 12px 28px rgba(94, 92, 230, 0.24);
}

body:not(.v2-active) .topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

body:not(.v2-active) .playback-voice-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

body:not(.v2-active) .playback-voice-chip {
  min-height: 38px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

body:not(.v2-active) .playback-voice-chip.active {
  background: rgba(94, 92, 230, 0.1);
  color: #2f2d73;
}

body:not(.v2-active) .playback-voice-chip.muted {
  background: #f3f3f6;
  color: #a1a1ab;
}

body:not(.v2-active) .playback-voice-chip.disabled {
  opacity: 0.72;
}

body.ctx-editor:not(.v2-active) .editor-subnav {
  position: static;
  display: flex;
  width: fit-content;
  margin: 0 0 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

body.ctx-editor:not(.v2-active) .editor-subnav .sub-tab {
  min-width: 156px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

body.ctx-editor:not(.v2-active) .editor-subnav .sub-tab:hover {
  background: rgba(94, 92, 230, 0.08);
  color: var(--text);
}

body.ctx-editor:not(.v2-active) .editor-subnav .sub-tab.active {
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  color: #fff;
  box-shadow: 0 10px 24px rgba(94, 92, 230, 0.22);
}

body.ctx-editor:not(.v2-active) .editor-layout,
body.ctx-editor:not(.v2-active) .score-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.92fr);
  gap: 20px;
  align-items: start;
}

body.ctx-editor:not(.v2-active) .editor-main-column,
body.ctx-editor:not(.v2-active) .editor-side-column,
body.ctx-editor:not(.v2-active) .score-main-column,
body.ctx-editor:not(.v2-active) .score-side-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

body:not(.v2-active) .composer-card,
body:not(.v2-active) .panel-card,
body:not(.v2-active) .keyboard-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

body:not(.v2-active) .composer-card,
body:not(.v2-active) .compact-card,
body:not(.v2-active) .keyboard-card,
body:not(.v2-active) .panel-card {
  padding: 22px;
  margin-bottom: 0;
}

body:not(.v2-active) .section-head {
  margin-bottom: 16px;
  align-items: center;
}

body:not(.v2-active) .section-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

body:not(.v2-active) .keyboard-actions,
body:not(.v2-active) .score-actions-row,
body:not(.v2-active) .settings-actions,
body:not(.v2-active) .pill-row,
body:not(.v2-active) .duration-row {
  gap: 10px;
}

body:not(.v2-active) .top-editor-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0;
}

body:not(.v2-active) .composer-card {
  padding: 18px;
}

body:not(.v2-active) .composer-surface {
  min-height: 310px;
  padding: 24px 78px 24px 24px;
  border-radius: 22px;
  border: 1px dashed rgba(94, 92, 230, 0.2);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 247, 250, 0.9)),
    repeating-linear-gradient(
      180deg,
      transparent 0,
      transparent 31px,
      rgba(236, 236, 239, 0.8) 31px,
      rgba(236, 236, 239, 0.8) 32px
    );
}

body:not(.v2-active) .composer-placeholder {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 28px;
  text-align: left;
  gap: 10px;
  color: var(--muted);
}

body:not(.v2-active) .composer-icon {
  font-size: 44px;
  color: rgba(94, 92, 230, 0.4);
  opacity: 1;
}

body:not(.v2-active) .composer-draft {
  min-height: 250px;
  align-content: flex-start;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 10px;
}

body:not(.v2-active) .draft-chip {
  padding: 10px 14px;
  border: 1px solid rgba(94, 92, 230, 0.12);
  background: rgba(94, 92, 230, 0.08);
  color: #23234a;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

body:not(.v2-active) .composer-side-actions {
  top: 18px;
  right: 18px;
}

body:not(.v2-active) .side-btn,
body:not(.v2-active) .pill,
body:not(.v2-active) .duration-btn,
body:not(.v2-active) .dot-btn,
body:not(.v2-active) .action-chip,
body:not(.v2-active) .dyn-btn,
body:not(.v2-active) .secondary-wide,
body:not(.v2-active) .primary-wide,
body:not(.v2-active) .toggle-row,
body:not(.v2-active) .mini-select,
body:not(.v2-active) .field-input,
body:not(.v2-active) .oct-btn {
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body:not(.v2-active) .side-btn:hover,
body:not(.v2-active) .pill:hover,
body:not(.v2-active) .duration-btn:hover,
body:not(.v2-active) .dot-btn:hover,
body:not(.v2-active) .action-chip:hover,
body:not(.v2-active) .dyn-btn:hover,
body:not(.v2-active) .secondary-wide:hover,
body:not(.v2-active) .primary-wide:hover,
body:not(.v2-active) .oct-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(94, 92, 230, 0.22);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.05);
}

body:not(.v2-active) .pill.active,
body:not(.v2-active) .duration-btn.active,
body:not(.v2-active) .dyn-btn.active,
body:not(.v2-active) .action-chip.active {
  border-color: rgba(94, 92, 230, 0.28);
  background: rgba(94, 92, 230, 0.1);
  color: #26265a;
}

body:not(.v2-active) .pill.accent-outline,
body:not(.v2-active) .dot-btn.active,
body:not(.v2-active) .primary-wide,
body:not(.v2-active) .measure-strip-chip.active,
body:not(.v2-active) .sheet-chip.active,
body:not(.v2-active) .score-token-chip.active,
body:not(.v2-active) .measure-token-chip.active {
  border-color: transparent;
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  color: #fff;
}

body:not(.v2-active) .secondary-wide {
  background: #fff;
  color: var(--text);
}

body:not(.v2-active) .primary-wide {
  box-shadow: 0 14px 28px rgba(94, 92, 230, 0.2);
}

body:not(.v2-active) .primary-wide.small,
body:not(.v2-active) .secondary-wide.small {
  flex: 1 1 220px;
  min-width: 0;
}

body:not(.v2-active) .insert-control,
body:not(.v2-active) .group-control-row {
  min-width: 0;
}

body:not(.v2-active) .insert-row.single-row .wide-chip {
  width: auto;
  flex: 1 1 auto;
}

body:not(.v2-active) .oct-label {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

body:not(.v2-active) .insert-label,
body:not(.v2-active) .field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

body:not(.v2-active) .field-input,
body:not(.v2-active) .mini-select,
body:not(.v2-active) .editor-textarea {
  background: #f8f8fb;
  color: var(--text);
  border: 1px solid var(--line);
}

body:not(.v2-active) .field-input::placeholder,
body:not(.v2-active) .editor-textarea::placeholder {
  color: #9595a1;
}

body:not(.v2-active) .editor-textarea {
  min-height: 160px;
  border-radius: 18px;
  line-height: 1.65;
}

body:not(.v2-active) .keyboard-card {
  overflow: visible;
}

body:not(.v2-active) .piano-frame {
  padding: 10px;
  border-radius: 22px;
  border: 1px solid #e7e7ec;
  background: linear-gradient(180deg, #f6f6f9, #ededf3);
}

body:not(.v2-active) .piano {
  height: clamp(180px, 24vw, 230px);
}

body:not(.v2-active) .white-keys {
  gap: 6px;
}

body:not(.v2-active) .piano-key.white {
  border: 1px solid #dedee6;
  border-radius: 0 0 16px 16px;
  color: #3c3c44;
  box-shadow:
    inset 0 -14px 0 rgba(0, 0, 0, 0.06),
    0 6px 14px rgba(0, 0, 0, 0.06);
}

body:not(.v2-active) .piano-key.black {
  top: 0;
  width: 9%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, #2b2b31, #121216);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22);
}

body:not(.v2-active) .preview-card {
  position: static;
  min-height: calc(100vh - 220px);
}

body:not(.v2-active) .preview-card .section-title {
  margin-bottom: 8px;
}

body:not(.v2-active) .preview-status {
  display: inline-flex;
  align-items: center;
  margin-bottom: 12px !important;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(94, 92, 230, 0.08);
  color: #3f3db0 !important;
}

body:not(.v2-active) .preview-image {
  min-height: min(560px, calc(100vh - 320px));
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #f7f7fa);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  object-fit: contain;
}

body:not(.v2-active) .token-board,
body:not(.v2-active) .measure-token-list {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #f8f8fb;
  color: var(--text);
}

body:not(.v2-active) .score-board-empty,
body:not(.v2-active) .measure-empty,
body:not(.v2-active) .field-help {
  color: var(--muted);
}

body:not(.v2-active) .section-title + .field-help {
  margin-top: -2px;
  margin-bottom: 14px;
}

body:not(.v2-active) .measure-board {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

body:not(.v2-active) .measure-board.active {
  border-color: rgba(94, 92, 230, 0.35);
  background: rgba(94, 92, 230, 0.05);
  box-shadow: 0 0 0 1px rgba(94, 92, 230, 0.08);
}

body:not(.v2-active) .measure-board-title,
body:not(.v2-active) .measure-label {
  color: var(--text);
}

body:not(.v2-active) .measure-board-meta,
body:not(.v2-active) .measure-strip-chip.follow {
  color: var(--muted);
}

body:not(.v2-active) .score-token-chip,
body:not(.v2-active) .measure-token-chip,
body:not(.v2-active) .measure-note-chip,
body:not(.v2-active) .sheet-chip,
body:not(.v2-active) .measure-strip-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: #24242b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

body:not(.v2-active) .measure-note-chip.active {
  border-color: rgba(94, 92, 230, 0.28);
  background: rgba(94, 92, 230, 0.08);
  color: #2f2d73;
}

body:not(.v2-active) .measure-board-tokens.drag-target-row,
body:not(.v2-active) .measure-token-list.drag-target-row {
  background: rgba(94, 92, 230, 0.05);
}

body:not(.v2-active) .measure-label {
  background: #fff;
}

body:not(.v2-active) .measure-editor-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #fbfbfd);
}

body:not(.v2-active) .settings-grid {
  gap: 14px;
}

body:not(.v2-active) .toast {
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

body:not(.v2-active) .toast.error {
  background: #fff2f1;
}

@media (max-width: 1100px) {
  body.ctx-editor:not(.v2-active) .editor-layout,
  body.ctx-editor:not(.v2-active) .score-layout {
    grid-template-columns: 1fr;
  }

  body:not(.v2-active) .preview-card {
    min-height: 0;
  }
}

@media (max-width: 720px) {
  body.ctx-editor:not(.v2-active) .app-shell {
    padding: 14px 12px 24px;
  }

  body:not(.v2-active) .topbar {
    padding: 14px;
    align-items: flex-start !important;
    flex-wrap: wrap;
  }

  body.ctx-editor:not(.v2-active) .editor-subnav {
    width: 100%;
  }

  body:not(.v2-active) .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  body:not(.v2-active) .playback-voice-controls {
    width: 100%;
    justify-content: space-between;
  }

  body.ctx-editor:not(.v2-active) .editor-subnav .sub-tab {
    min-width: 0;
    flex: 1 1 0;
  }

  body:not(.v2-active) .top-editor-actions {
    grid-template-columns: 1fr;
  }

  body:not(.v2-active) .composer-card,
  body:not(.v2-active) .compact-card,
  body:not(.v2-active) .keyboard-card,
  body:not(.v2-active) .panel-card {
    padding: 18px;
  }

  body:not(.v2-active) .composer-surface {
    min-height: 260px;
    padding: 20px 20px 76px;
  }

  body:not(.v2-active) .composer-side-actions {
    top: auto;
    right: 18px;
    bottom: 18px;
    flex-direction: row;
  }

  body:not(.v2-active) .insert-row,
  body:not(.v2-active) .group-row,
  body:not(.v2-active) .measure-nav-row,
  body:not(.v2-active) .instrument-settings-row {
    flex-direction: column;
    align-items: stretch;
  }

  body:not(.v2-active) .insert-label {
    width: auto;
    flex: none;
  }

  body:not(.v2-active) .measure-nav-btn,
  body:not(.v2-active) .primary-wide.small,
  body:not(.v2-active) .secondary-wide.small {
    width: 100%;
  }
}

/* ============================================
   LEGACY EDITOR / SCORE DARK THEME
   Keeps the old editor workspace in sync with the site theme toggle.
   ============================================ */
body.theme-dark:not(.v2-active) {
  --bg: #0b0b0f;
  --bg-soft: #111116;
  --panel: rgba(26, 26, 32, 0.92);
  --panel-2: #17171d;
  --panel-3: #22232b;
  --line: #2a2a32;
  --text: #f5f5f7;
  --muted: #a1a1a8;
  --orange: #7d7bff;
  --orange-2: #9491ff;
  --white-key: #f4f4f6;
  --black-key: #09090d;
  --danger: #3a1818;
  --ok: #15351f;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.34);
  background:
    radial-gradient(circle at top left, rgba(125, 123, 255, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(125, 123, 255, 0.1), transparent 26%),
    linear-gradient(180deg, #0b0b0f 0%, #111116 100%);
  color: var(--text);
}

body.theme-dark:not(.v2-active) .topbar,
body.theme-dark.ctx-editor:not(.v2-active) .editor-subnav {
  border-color: var(--line);
  background: rgba(18, 18, 24, 0.84);
  box-shadow: var(--shadow);
}

body.theme-dark:not(.v2-active) .brand,
body.theme-dark:not(.v2-active) .measure-board-title,
body.theme-dark:not(.v2-active) .measure-label {
  color: var(--text);
}

body.theme-dark:not(.v2-active) .stats-line,
body.theme-dark:not(.v2-active) .section-title,
body.theme-dark:not(.v2-active) .insert-label,
body.theme-dark:not(.v2-active) .field-label,
body.theme-dark:not(.v2-active) .score-board-empty,
body.theme-dark:not(.v2-active) .measure-empty,
body.theme-dark:not(.v2-active) .field-help,
body.theme-dark:not(.v2-active) .measure-board-meta,
body.theme-dark:not(.v2-active) .measure-strip-chip.follow,
body.theme-dark.ctx-editor:not(.v2-active) .editor-subnav .sub-tab {
  color: var(--muted);
}

body.theme-dark.ctx-editor:not(.v2-active) .editor-subnav .sub-tab:hover {
  background: rgba(125, 123, 255, 0.12);
  color: var(--text);
}

body.theme-dark.ctx-editor:not(.v2-active) .editor-subnav .sub-tab.active {
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  color: #fff;
  box-shadow: 0 10px 24px rgba(125, 123, 255, 0.28);
}

body.theme-dark:not(.v2-active) .playback-voice-controls {
  border-color: var(--line);
  background: rgba(26, 26, 32, 0.9);
}

body.theme-dark:not(.v2-active) .playback-voice-chip.active {
  background: rgba(125, 123, 255, 0.18);
  color: #d9d8ff;
}

body.theme-dark:not(.v2-active) .playback-voice-chip.muted {
  background: #121218;
  color: #73737f;
}

body.theme-dark:not(.v2-active) .composer-card,
body.theme-dark:not(.v2-active) .compact-card,
body.theme-dark:not(.v2-active) .panel-card,
body.theme-dark:not(.v2-active) .keyboard-card {
  background: var(--panel);
  border-color: var(--line);
}

body.theme-dark:not(.v2-active) .composer-surface {
  border-color: rgba(125, 123, 255, 0.24);
  background:
    linear-gradient(180deg, rgba(24, 24, 31, 0.94), rgba(17, 17, 23, 0.92)),
    repeating-linear-gradient(
      180deg,
      transparent 0,
      transparent 31px,
      rgba(58, 58, 68, 0.6) 31px,
      rgba(58, 58, 68, 0.6) 32px
    );
}

body.theme-dark:not(.v2-active) .composer-placeholder {
  color: var(--muted);
}

body.theme-dark:not(.v2-active) .composer-icon {
  color: rgba(125, 123, 255, 0.42);
}

body.theme-dark:not(.v2-active) .draft-chip {
  background: rgba(125, 123, 255, 0.14);
  border-color: rgba(125, 123, 255, 0.22);
  color: #e1e0ff;
}

body.theme-dark:not(.v2-active) .side-btn,
body.theme-dark:not(.v2-active) .pill,
body.theme-dark:not(.v2-active) .duration-btn,
body.theme-dark:not(.v2-active) .dot-btn,
body.theme-dark:not(.v2-active) .action-chip,
body.theme-dark:not(.v2-active) .dyn-btn,
body.theme-dark:not(.v2-active) .secondary-wide,
body.theme-dark:not(.v2-active) .toggle-row,
body.theme-dark:not(.v2-active) .mini-select,
body.theme-dark:not(.v2-active) .field-input,
body.theme-dark:not(.v2-active) .oct-btn,
body.theme-dark:not(.v2-active) .oct-label {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

body.theme-dark:not(.v2-active) .side-btn:hover,
body.theme-dark:not(.v2-active) .pill:hover,
body.theme-dark:not(.v2-active) .duration-btn:hover,
body.theme-dark:not(.v2-active) .dot-btn:hover,
body.theme-dark:not(.v2-active) .action-chip:hover,
body.theme-dark:not(.v2-active) .dyn-btn:hover,
body.theme-dark:not(.v2-active) .secondary-wide:hover,
body.theme-dark:not(.v2-active) .primary-wide:hover,
body.theme-dark:not(.v2-active) .oct-btn:hover {
  border-color: rgba(125, 123, 255, 0.32);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

body.theme-dark:not(.v2-active) .pill.active,
body.theme-dark:not(.v2-active) .duration-btn.active,
body.theme-dark:not(.v2-active) .dyn-btn.active,
body.theme-dark:not(.v2-active) .action-chip.active {
  background: rgba(125, 123, 255, 0.16);
  border-color: rgba(125, 123, 255, 0.28);
  color: #e1e0ff;
}

body.theme-dark:not(.v2-active) .field-input,
body.theme-dark:not(.v2-active) .mini-select,
body.theme-dark:not(.v2-active) .editor-textarea {
  background: #121218;
  color: var(--text);
  border-color: var(--line);
}

body.theme-dark:not(.v2-active) .field-input::placeholder,
body.theme-dark:not(.v2-active) .editor-textarea::placeholder {
  color: #73737f;
}

body.theme-dark:not(.v2-active) .piano-frame {
  border-color: #30303a;
  background: linear-gradient(180deg, #1a1a22, #111116);
}

body.theme-dark:not(.v2-active) .piano-key.white {
  border-color: #dedee6;
  background: linear-gradient(180deg, #fff, #e8e8ee);
  color: #2f3038;
}

body.theme-dark:not(.v2-active) .piano-key.black {
  border-color: rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #1d1d24, #07070a);
}

body.theme-dark:not(.v2-active) .preview-status {
  background: rgba(125, 123, 255, 0.16);
  color: #d9d8ff !important;
}

body.theme-dark:not(.v2-active) .preview-image {
  border-color: #30303a;
  background: linear-gradient(180deg, #fff, #f4f4f6);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
}

body.theme-dark:not(.v2-active) .token-board,
body.theme-dark:not(.v2-active) .measure-token-list {
  background: #121218;
  border-color: var(--line);
  color: var(--text);
}

body.theme-dark:not(.v2-active) .measure-board,
body.theme-dark:not(.v2-active) .score-token-chip,
body.theme-dark:not(.v2-active) .measure-token-chip,
body.theme-dark:not(.v2-active) .measure-note-chip,
body.theme-dark:not(.v2-active) .sheet-chip,
body.theme-dark:not(.v2-active) .measure-strip-chip,
body.theme-dark:not(.v2-active) .measure-label,
body.theme-dark:not(.v2-active) .measure-editor-box {
  background: #1a1a20;
  border-color: var(--line);
  color: var(--text);
  box-shadow: none;
}

body.theme-dark:not(.v2-active) .measure-board.active {
  background: rgba(125, 123, 255, 0.12);
  border-color: rgba(125, 123, 255, 0.34);
}

body.theme-dark:not(.v2-active) .pill.accent-outline,
body.theme-dark:not(.v2-active) .dot-btn.active,
body.theme-dark:not(.v2-active) .primary-wide,
body.theme-dark:not(.v2-active) .measure-strip-chip.active,
body.theme-dark:not(.v2-active) .score-token-chip.active,
body.theme-dark:not(.v2-active) .measure-token-chip.active {
  border-color: transparent;
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  color: #fff;
}

body.theme-dark:not(.v2-active) .measure-note-chip.active {
  background: rgba(125, 123, 255, 0.18);
  border-color: rgba(125, 123, 255, 0.34);
  color: #e1e0ff;
}

body.theme-dark:not(.v2-active) .measure-board-tokens.drag-target-row,
body.theme-dark:not(.v2-active) .measure-token-list.drag-target-row {
  background: rgba(125, 123, 255, 0.1);
}

body.theme-dark:not(.v2-active) .measure-editor-box {
  background: linear-gradient(180deg, #1a1a20, #14141a);
}

body.theme-dark:not(.v2-active) .toast {
  background: rgba(24, 24, 31, 0.96);
  color: var(--text);
  border-color: var(--line);
}

body.theme-dark:not(.v2-active) .toast.error {
  background: rgba(58, 24, 24, 0.96);
}
