:root {
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', 'Cascadia Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
  --bg: #111315;
  --surface: #171a1d;
  --surface-2: #1d2126;
  --surface-3: #252a31;
  --line: #2e343d;
  --line-strong: #454d59;
  --text: #e4e7ec;
  --muted: #949ca8;
  --dim: #656d78;
  --gold: #d29922;
  --gold-dark: #2b2416;
  --danger: #d9685b;
  --ok: #7fa650;
  --row: #14171a;
  --scale: #1b2024;
}

:root[data-theme=light] {
  color-scheme: light;
  --bg: #dfe3e8;
  --surface: #f0f2f5;
  --surface-2: #e4e7ec;
  --surface-3: #d5dae2;
  --line: #b8c0cc;
  --line-strong: #848e9c;
  --text: #14171a;
  --muted: #4a525d;
  --dim: #6c7582;
  --gold: #9e6b00;
  --gold-dark: #e8dec5;
  --danger: #b83c2e;
  --ok: #4d7322;
  --row: #e6e9ee;
  --scale: #eff2f6;
}

* {
  box-sizing: border-box;
  border-radius: 0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  font-variant-numeric: tabular-nums;
}

button, a, input, select, textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 30px;
  min-height: 30px;
  padding: 5px 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
}

button:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--line-strong);
}

button:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

button:focus-visible, a:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: -1px;
}

button svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

input, select, textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  outline: none;
  padding: 6px 8px;
  font-size: 11px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  background: var(--surface-2);
}

input[type=range] {
  accent-color: var(--gold);
  height: 4px;
  padding: 0;
  cursor: pointer;
  border: 0;
  background: var(--surface-3);
}

input[type=number] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input::-webkit-inner-spin-button {
  opacity: 0.5;
}

a {
  color: var(--gold);
}

h1, h2, h3, p {
  margin: 0;
}

h2 {
  font-size: 15px;
  letter-spacing: 1px;
  font-weight: 700;
  text-transform: uppercase;
}

h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

svg {
  vertical-align: middle;
}

small {
  font-size: 10px;
}

/* HEADER */
.header {
  height: 46px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand img {
  width: 22px;
  height: 22px;
}

.brand > span {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
}

.brand small {
  font-family: var(--font-mono);
  letter-spacing: 1.2px;
  font-size: 9px;
  color: var(--dim);
  border-left: 1px solid var(--line);
  padding: 2px 0 2px 12px;
  margin-left: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-right button {
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.header-right button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.local-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 5px 10px;
  margin-right: 4px;
}

.local-badge i {
  width: 6px;
  height: 6px;
  background: var(--ok);
  display: inline-block;
}

/* WORKSPACE & NAVIGATION RAIL */
.workspace {
  display: flex;
  min-height: calc(100vh - 46px);
}

.rail {
  width: 52px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
}

.rail > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rail button {
  width: 38px;
  height: 38px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface-2);
  position: relative;
  padding: 0;
}

.rail button svg {
  width: 17px;
  height: 17px;
}

.rail button.active {
  background: var(--gold-dark);
  color: var(--gold);
  border-color: var(--gold);
}

.rail button.active::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 0;
  height: 100%;
  width: 3px;
  background: var(--gold);
}

main {
  flex: 1;
  min-width: 0;
  padding: 14px 18px 0;
  max-width: 2200px;
  margin: 0 auto;
}

/* PROJECT HEADER BAR */
.song-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  gap: 12px;
}

.song-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.eyebrow {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--dim);
  text-transform: uppercase;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.title-row input {
  font-size: 15px;
  letter-spacing: 0.3px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 4px 8px;
  width: min(360px, 42vw);
}

.title-row input:hover {
  border-color: var(--line-strong);
}

.project-tag {
  font-size: 9px;
  color: var(--gold);
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 4px 6px;
  letter-spacing: 1px;
}

.save-state {
  display: flex;
  gap: 5px;
  align-items: center;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.8px;
  border-left: 1px solid var(--line);
  padding-left: 10px;
}

.save-state svg {
  width: 12px;
  height: 12px;
  color: var(--ok);
}

.song-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.text {
  padding: 6px 10px;
  min-height: 30px;
  font-size: 10px;
  font-weight: 600;
}

.text svg {
  width: 14px;
  height: 14px;
}

.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #111315;
  font-weight: 700;
}

.primary:hover {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.secondary {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.secondary:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
}

.danger {
  color: var(--danger);
  border-color: var(--line);
  background: var(--surface-2);
}

.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.compact {
  padding: 4px 8px;
  min-height: 26px;
  font-size: 9px;
}

/* TRANSPORT DECK */
.transport {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 10px;
  margin-bottom: 12px;
}

.transport-play {
  display: flex;
  align-items: center;
  gap: 4px;
}

.transport-play button {
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.play-button {
  background: var(--gold) !important;
  border-color: var(--gold) !important;
  color: #111315 !important;
  width: 34px;
  height: 30px;
}

.play-button:hover {
  background: var(--text) !important;
  border-color: var(--text) !important;
  color: var(--bg) !important;
}

.play-button svg {
  width: 16px;
  height: 16px;
}

.toggled {
  color: var(--gold) !important;
  background: var(--gold-dark) !important;
  border-color: var(--gold) !important;
}

.position {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin: 0 6px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  min-width: 68px;
  text-align: center;
}

.position span {
  color: var(--gold);
  margin: 0 1px;
}

.transport-settings {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tempo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tempo > span {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1px;
  font-weight: 700;
}

.tempo input {
  font-size: 13px;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--line);
  width: 54px;
  padding: 4px 6px;
  text-align: right;
  font-family: var(--font-mono);
}

.divider {
  height: 22px;
  border-left: 1px solid var(--line);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1px;
  font-weight: 700;
  text-transform: uppercase;
}

.field select, .field input:not([type=range]) {
  width: 100%;
  min-height: 28px;
}

.transport-settings .field {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.transport-settings .field select {
  border: 1px solid var(--line);
  background: var(--bg);
  min-height: 28px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
}

.history {
  display: flex;
  gap: 4px;
  border-left: 1px solid var(--line);
  padding-left: 10px;
}

.history button {
  border: 1px solid var(--line);
  background: var(--surface-2);
}

/* COMPOSER GRID LAYOUT */
.composer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 12px;
}

.editor {
  min-width: 0;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface-2);
}

.view-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.8px;
}

.view-name > svg {
  width: 14px;
  height: 14px;
  color: var(--gold);
}

.view-name > span {
  font-size: 9px;
  color: var(--dim);
  border-left: 1px solid var(--line);
  padding-left: 8px;
}

.editor-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.editor-tools label {
  display: flex;
  gap: 6px;
  align-items: center;
}

.editor-tools input[type=number] {
  width: 48px;
  height: 24px;
  padding: 2px 5px;
  background: var(--bg);
}

.editor-tools input[type=range] {
  width: 64px;
}

.editor-tools button {
  font-size: 9px;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.editor-tools button svg {
  width: 11px;
  height: 11px;
}

.note-toolbar {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface);
  padding: 0 10px;
}

.tool-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}

.tool-label svg {
  width: 12px;
  height: 12px;
  color: var(--gold);
}

.duration-controls {
  display: flex;
  gap: 2px;
}

.duration-controls button {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  min-width: 34px;
  height: 24px;
  min-height: 24px;
  padding: 2px 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.duration-controls button.active {
  background: var(--gold-dark);
  color: var(--gold);
  border-color: var(--gold);
}

.duration-text {
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  min-width: 24px;
}

.toolbar-hint {
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.5px;
  margin-left: auto;
}

.note-toolbar .field {
  flex-direction: row;
  align-items: center;
  margin-left: auto;
  gap: 6px;
}

.note-toolbar .field select {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 2px 6px;
  font-size: 10px;
  min-height: 24px;
}

.note-toolbar .field > span {
  font-size: 9px;
}

.accompaniment-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface-2);
}

.accompaniment-bar .field {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.accompaniment-bar .field > span {
  font-size: 9px;
  white-space: nowrap;
  letter-spacing: 0.8px;
}

.accompaniment-bar .field select {
  min-height: 24px;
  font-size: 10px;
  padding: 2px 6px;
  min-width: 0;
  width: 100%;
  background: var(--bg);
}

/* TIMELINE & PIANO ROLL */
.timeline-scroll {
  max-height: 440px;
  height: 440px;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--row);
  scrollbar-color: var(--line-strong) var(--surface);
  scrollbar-width: thin;
  position: relative;
}

.timeline {
  position: relative;
  min-height: 100%;
  overflow: visible;
}

.timeline-head {
  display: grid;
  grid-template-columns: 64px 1fr;
  grid-template-rows: 24px 24px 52px 38px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
}

.lane-label {
  position: sticky;
  left: 0;
  z-index: 7;
  background: var(--surface);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section-lane {
  position: relative;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.section-block {
  position: absolute;
  top: 0;
  height: 23px;
  min-height: 23px;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 2px solid #7fa650;
  background: color-mix(in srgb, #7fa650 14%, var(--surface));
  color: var(--text);
}

.section-block svg {
  width: 10px;
  height: 10px;
}

.section-1 {
  border-bottom-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 14%, var(--surface));
}

.section-2 {
  border-bottom-color: #6497c4;
  background: color-mix(in srgb, #6497c4 14%, var(--surface));
}

.ruler {
  position: relative;
  cursor: crosshair;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.ruler > span {
  position: absolute;
  height: 23px;
  border-left: 1px solid var(--line);
  padding: 4px 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
}

.ruler > span i {
  position: absolute;
  top: 4px;
  font-style: normal;
  color: var(--dim);
  transform: translateX(-2px);
  pointer-events: none;
}

.chord-lane {
  position: relative;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(var(--bar-width) - 1px),
    var(--line) calc(var(--bar-width) - 1px),
    var(--line) var(--bar-width)
  );
}

.chord-block {
  position: absolute;
  top: 4px;
  height: 43px;
  min-width: 8px;
  min-height: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--degree) 18%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--degree) 55%, var(--line));
  border-left: 3px solid var(--degree);
  color: var(--text);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  text-transform: none;
}

.chord-block:hover {
  background: color-mix(in srgb, var(--degree) 28%, var(--surface));
  border-color: var(--degree);
}

.chord-block.selected {
  outline: 1px solid var(--text);
  outline-offset: -1px;
  background: color-mix(in srgb, var(--degree) 30%, var(--surface));
}

.block-roman {
  font-size: 8px;
  color: var(--degree);
  font-weight: 700;
}

.chord-block strong {
  font-size: 13px;
  font-weight: 700;
  line-height: 15px;
}

.resize-handle, .note i {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 7px;
  cursor: ew-resize;
  border-right: 2px solid #0004;
  z-index: 2;
}

.chord-placeholder {
  position: absolute;
  top: 18px;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.8px;
  white-space: nowrap;
  pointer-events: none;
}

.bass-lane {
  position: relative;
  background: var(--surface);
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(var(--bar-width) - 1px),
    var(--line) calc(var(--bar-width) - 1px),
    var(--line) var(--bar-width)
  );
  border-bottom: 1px solid var(--line);
}

.bass-note {
  position: absolute;
  background: color-mix(in srgb, #56a89f 35%, var(--surface));
  border: 1px solid #56a89f;
  color: var(--text);
  height: 12px;
  font-size: 7px;
  line-height: 10px;
  padding: 0 3px;
  overflow: hidden;
  white-space: nowrap;
}

.piano-area {
  position: relative;
  display: flex;
}

.piano-keys {
  position: sticky;
  left: 0;
  width: 64px;
  z-index: 4;
  flex-shrink: 0;
  background: var(--surface);
}

.piano-key {
  width: 64px;
  min-height: 21px;
  height: 21px;
  padding: 0 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  justify-content: space-between;
  background: var(--surface-2);
  font-size: 8px;
  color: var(--muted);
  text-transform: none;
}

.piano-key.black {
  background: var(--bg);
  padding-left: 10px;
  color: var(--dim);
}

.piano-key span {
  font-size: 7px;
  font-weight: 700;
}

.piano-key.root {
  color: var(--text);
  font-weight: 700;
  border-left: 2px solid var(--gold);
}

.piano-key:hover {
  background: var(--gold-dark);
  color: var(--gold);
}

.piano-roll {
  position: relative;
  cursor: crosshair;
  background: var(--row);
  touch-action: none;
}

.piano-row {
  position: absolute;
  left: 0;
  width: 100%;
  height: 21px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--snap-width, var(--beat-width)) - 1px),
      color-mix(in srgb, var(--line) 28%, transparent) calc(var(--snap-width, var(--beat-width)) - 1px),
      color-mix(in srgb, var(--line) 28%, transparent) var(--snap-width, var(--beat-width))
    ),
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--beat-width) - 1px),
      color-mix(in srgb, var(--line) 65%, transparent) calc(var(--beat-width) - 1px),
      color-mix(in srgb, var(--line) 65%, transparent) var(--beat-width)
    ),
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--bar-width) - 1px),
      var(--line-strong) calc(var(--bar-width) - 1px),
      var(--line-strong) var(--bar-width)
    );
}

.piano-row.in-scale {
  background-color: var(--scale);
}

.piano-row.tonic-row {
  background-color: color-mix(in srgb, var(--gold) 8%, var(--scale));
  border-bottom-color: color-mix(in srgb, var(--gold) 25%, var(--line));
}

.note {
  position: absolute;
  min-width: 5px;
  border: 1px solid #0006;
  color: #111315;
  font-weight: 700;
  display: flex;
  align-items: center;
  padding: 0 4px;
  overflow: hidden;
  cursor: grab;
  font-size: 8px;
  user-select: none;
  touch-action: none;
  z-index: 2;
}

.note.selected {
  outline: 2px solid var(--text);
  outline-offset: 0;
  z-index: 3;
}

.note span {
  white-space: nowrap;
  pointer-events: none;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--gold);
  z-index: 6;
  pointer-events: none;
}

.playhead-head::before {
  content: '';
  position: absolute;
  top: 24px;
  left: -4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid var(--gold);
}

.timeline-bottom {
  display: flex;
  height: 26px;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.timeline-bottom > span {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface);
  width: 64px;
  text-align: center;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scale-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
  padding-left: 4px;
}

.scale-legend > span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.scale-legend i {
  width: 7px;
  height: 7px;
  background: var(--dim);
  display: inline-block;
}

.scale-legend .out-key {
  margin-left: 8px;
  color: var(--dim);
}

/* TRACK STRIP */
.track-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--surface);
}

.track-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border-right: 1px solid var(--line);
  padding: 4px 8px;
  min-width: 0;
}

.track-item:last-child {
  border-right: 0;
}

.track-dot {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
}

.track-item > span:not(.track-dot) {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.track-item small {
  font-size: 9px;
  color: var(--dim);
  margin-left: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-item button {
  margin-left: auto;
  min-width: 24px;
  min-height: 24px;
  padding: 2px;
}

.track-item button svg {
  width: 13px;
  height: 13px;
}

.muted {
  color: var(--danger) !important;
}

/* CHORD WORKBENCH */
.chord-workbench {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 12px;
}

.workbench-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.workbench-heading .eyebrow {
  margin-bottom: 2px;
}

.workbench-heading > button {
  margin-left: auto;
}

.scale-badge {
  font-size: 9px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.8px;
}

.scale-badge i {
  color: var(--dim);
  margin: 0 4px;
  font-style: normal;
}

.palette-options {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.palette-options small {
  margin-left: 8px;
  font-size: 9px;
  letter-spacing: 0.6px;
  color: var(--dim);
}

.chord-palette {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  max-height: 230px;
  overflow: auto;
}

.chord-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  padding: 8px 10px;
  min-width: 0;
  min-height: 78px;
  border: 1px solid color-mix(in srgb, var(--degree) 40%, var(--line));
  background: color-mix(in srgb, var(--degree) 8%, var(--surface-2));
  border-top: 3px solid var(--degree);
  position: relative;
  color: var(--text);
  text-transform: none;
}

.chord-card:hover {
  background: color-mix(in srgb, var(--degree) 18%, var(--surface-3));
  border-color: var(--degree);
  color: var(--text);
}

.roman {
  font-size: 9px;
  font-weight: 700;
  color: var(--degree);
}

.chord-card strong {
  font-size: 18px;
  line-height: 22px;
  font-weight: 700;
}

.chord-type {
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 0.6px;
}

.card-plus {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
  color: var(--dim);
}

.subtle {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.palette-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  letter-spacing: 0.5px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--dim);
}

.palette-hint svg {
  width: 12px;
  height: 12px;
  color: var(--gold);
}

.palette-hint > span {
  margin-left: auto;
}

/* INSPECTOR PANEL */
.inspector {
  border: 1px solid var(--line);
  background: var(--surface);
  align-self: start;
  min-height: 690px;
  overflow: hidden;
}

.inspector-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.inspector-tabs button {
  padding: 10px 6px;
  font-size: 9px;
  font-weight: 700;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  gap: 6px;
  min-height: 36px;
}

.inspector-tabs button:last-child {
  border-right: 0;
}

.inspector-tabs button svg {
  width: 13px;
  height: 13px;
}

.inspector-tabs button.active {
  background: var(--surface);
  border-bottom-color: var(--gold);
  color: var(--gold);
}

.idea-subtabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.idea-subtabs button {
  font-size: 8px;
  font-weight: 700;
  min-height: 28px;
  padding: 4px;
  background: var(--surface-2);
  border: 0;
}

.idea-subtabs button:hover {
  background: var(--surface-3);
}

.idea-subtabs button.active {
  background: var(--gold-dark);
  color: var(--gold);
}

.idea-content {
  padding: 14px;
}

.small-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggestion {
  width: 100%;
  border: 1px solid var(--line);
  padding: 8px 10px;
  min-height: 48px;
  justify-content: flex-start;
  gap: 10px;
  background: var(--surface-2);
  text-align: left;
  text-transform: none;
}

.suggestion-degree {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 30px;
  border: 1px solid color-mix(in srgb, var(--degree) 45%, var(--line));
  background: color-mix(in srgb, var(--degree) 14%, var(--surface));
  color: var(--degree);
  font-size: 11px;
  font-weight: 700;
}

.suggestion > span:nth-child(2) {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.suggestion strong {
  font-size: 12px;
  color: var(--text);
  font-weight: 700;
}

.suggestion small {
  font-size: 9px;
  color: var(--muted);
}

.suggestion > svg {
  margin-left: auto;
  width: 12px;
  height: 12px;
  color: var(--dim);
}

.idea-divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.idea-action {
  display: flex;
  text-align: left;
  justify-content: flex-start;
  width: 100%;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  text-transform: none;
}

.idea-action > svg:first-child {
  color: var(--gold);
  width: 15px;
}

.idea-action > span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.idea-action strong {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
}

.idea-action small {
  font-size: 9px;
  color: var(--muted);
}

.idea-action > svg:last-child {
  width: 11px;
  height: 11px;
  margin-left: auto;
  color: var(--dim);
}

.theory-tip {
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  background: var(--surface-2);
  padding: 10px 12px;
  margin-top: 14px;
}

.theory-tip > span {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--gold);
}

.theory-tip > p {
  font-size: 9px;
  color: var(--muted);
  line-height: 1.65;
  margin-top: 6px;
}

.theory-link {
  display: inline-flex;
  justify-content: flex-start;
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  padding: 6px 0 0;
  border: 0;
}

.theory-link:hover {
  background: transparent;
  text-decoration: underline;
}

.theory-link svg {
  width: 11px;
  height: 11px;
}

.progression {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 10px;
  margin-bottom: 8px;
  gap: 5px;
  text-align: left;
  position: relative;
  text-transform: none;
}

.progression strong {
  font-size: 11px;
  color: var(--text);
  font-weight: 700;
}

.progression > small {
  font-size: 9px;
  color: var(--muted);
  line-height: 1.5;
}

.progression > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  margin: 4px 0;
}

.progression > div > i {
  font-size: 9px;
  color: var(--dim);
  font-style: normal;
}

.progression-use {
  align-self: flex-end;
  color: var(--gold);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.progression-use svg {
  width: 10px;
  height: 10px;
  margin-left: 4px;
}

.search-box {
  display: flex;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 0 8px;
  margin-bottom: 8px;
}

.search-box svg {
  width: 14px;
  height: 14px;
  color: var(--dim);
}

.search-box input {
  width: 100%;
  padding: 7px 0;
  border: 0;
  background: transparent;
  font-size: 10px;
}

.search-results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
  max-height: 460px;
  overflow: auto;
}

.search-results .chord-card {
  min-height: 72px;
  padding: 6px 8px;
}

.search-results .chord-card strong {
  font-size: 15px;
}

.properties {
  padding: 14px;
}

.property-chord {
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 8px 0 4px;
}

.property-chord > span {
  font-size: 13px;
  color: var(--muted);
}

.property-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.property-grid input, .property-grid select {
  font-size: 10px;
  background: var(--bg);
}

.property-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.property-actions .text {
  padding: 5px 8px;
  font-size: 9px;
}

.property-actions svg {
  width: 12px;
  height: 12px;
}

.property-note {
  font-size: 18px;
  font-weight: 700;
  margin-top: 8px;
}

.property-note > span {
  font-size: 9px;
  color: var(--muted);
  margin-left: 8px;
  font-weight: 400;
}

.properties > .field {
  margin-top: 12px;
}

.empty-small {
  color: var(--dim);
  font-size: 10px;
  line-height: 1.6;
  margin: 10px 0 20px;
  padding: 10px;
  border: 1px dashed var(--line);
  background: var(--surface-2);
}

/* SECONDARY PAGE PANELS (LIBRARY, BAND, LYRICS, THEORY) */
.page-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 18px;
  min-height: 600px;
}

.page-heading {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.page-heading h2 {
  font-size: 18px;
  margin: 4px 0 6px;
}

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

.song-card {
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 14px;
  min-width: 0;
}

.song-card.current {
  border-color: var(--gold);
}

.mini-bars {
  display: flex;
  height: 24px;
  gap: 3px;
  margin-bottom: 12px;
  align-items: flex-end;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.mini-bars i {
  width: 22px;
  min-width: 8px;
  opacity: 0.85;
  height: 18px;
}

.mini-bars i:nth-child(3n) {
  height: 12px;
}

.mini-bars i:nth-child(3n+1) {
  height: 22px;
}

.song-card h3 {
  font-size: 14px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.song-card p {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 6px;
}

.song-card p span {
  margin: 0 4px;
  color: var(--dim);
}

.song-card > small {
  font-size: 9px;
  color: var(--dim);
}

.song-card > div:last-child {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  align-items: center;
}

.song-card > div:last-child button:first-child {
  margin-right: auto;
}

.song-card > div:last-child button {
  border: 1px solid var(--line);
  background: var(--surface);
}

.new-song-card {
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  min-height: 180px;
  flex-direction: column;
  gap: 8px;
  color: var(--gold);
}

.new-song-card svg {
  width: 22px;
  height: 22px;
}

.new-song-card strong {
  font-size: 12px;
  font-weight: 700;
}

.new-song-card span {
  font-size: 9px;
  color: var(--muted);
}

/* BAND & MIXER */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.preset {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  padding: 12px;
  min-height: 88px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  text-align: left;
  text-transform: none;
}

.preset.active {
  border-color: var(--gold);
  background: var(--gold-dark);
}

.preset-number {
  font-size: 9px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
}

.preset strong {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
}

.preset small {
  font-size: 9px;
  color: var(--muted);
}

.preset > svg {
  position: absolute;
  right: 12px;
  top: 12px;
  color: var(--gold);
}

.band-settings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.band-settings select {
  background: var(--bg);
}

.band-description {
  padding: 10px 12px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.band-description p {
  font-size: 10px;
  line-height: 1.6;
  color: var(--muted);
}

.band-description strong {
  color: var(--text);
  font-weight: 700;
}

.rhythm-study {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  margin-bottom: 16px;
}

.rhythm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}

.rhythm-row > span {
  min-width: 76px;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
}

.rhythm-row > div {
  display: grid;
  grid-template-columns: repeat(var(--pulses), 1fr);
  gap: 4px;
  max-width: 760px;
  width: 100%;
}

.rhythm-row i {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-style: normal;
  height: 24px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--dim);
}

.rhythm-row i.hit {
  background: var(--gold);
  color: #111315;
  font-weight: 700;
  border-color: var(--gold);
}

.mixer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.mixer-track {
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 12px;
}

.mixer-track > div {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.mixer-track > div > svg {
  width: 14px;
  height: 14px;
  color: var(--gold);
}

.mixer-track strong {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.mixer-track button {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--surface);
}

.mixer-track label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mixer-track input {
  width: 100%;
  min-width: 0;
}

.mixer-track label span {
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  min-width: 34px;
  text-align: right;
}

/* LYRICS & SECTIONS */
.lyrics-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

.lyrics-layout textarea {
  min-height: 380px;
  width: 100%;
  resize: vertical;
  line-height: 1.8;
  padding: 12px;
  font-size: 12px;
  background: var(--bg);
}

.section-edit {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.section-edit > input {
  width: 100%;
  min-width: 0;
  background: var(--bg);
}

.section-edit label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
}

.section-edit label input {
  width: 52px;
  background: var(--bg);
}

.section-edit button {
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.section-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* THEORY REFERENCE */
.scale-lab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 14px;
}

.scale-formula {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.scale-formula > span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 40px;
  padding: 6px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--degree);
  background: var(--bg);
  color: var(--degree);
}

.scale-formula strong {
  font-size: 14px;
  font-weight: 700;
}

.scale-formula small {
  font-size: 11px;
  color: var(--text);
  font-weight: 700;
}

.theory-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}

.theory-filters button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 9px;
  font-weight: 700;
  padding: 6px 10px;
}

.theory-filters button.active {
  color: var(--gold);
  background: var(--gold-dark);
  border-color: var(--gold);
}

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

.lesson {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 14px;
}

.lesson-era {
  font-size: 9px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.lesson h3 {
  font-size: 14px;
  line-height: 1.35;
  margin-bottom: 8px;
}

.lesson > p {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.lesson-exercise {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin: 12px 0;
}

.lesson-exercise > span {
  font-size: 8px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
}

.lesson-exercise > p {
  font-size: 9px;
  color: var(--text);
  line-height: 1.65;
  margin-top: 4px;
}

.lesson-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.lesson-bottom > button {
  font-size: 9px;
  padding: 5px 8px;
}

.lesson-bottom > a {
  font-size: 9px;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.lesson-bottom > a:hover {
  text-decoration: underline;
}

.lesson-bottom svg {
  width: 11px;
  height: 11px;
}

.theory-footnote {
  margin-top: 16px;
}

/* FOOTER */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.8px;
  padding: 14px 0;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

footer b {
  font-weight: 400;
  margin: 0 5px;
  color: var(--line-strong);
}

footer a {
  color: var(--gold);
  font-weight: 700;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* TOAST & MODAL DIALOG */
#toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--gold);
  border-left: 4px solid var(--gold);
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  z-index: 50;
  max-width: min(460px, 90vw);
}

#toast.visible {
  opacity: 1;
  visibility: visible;
}

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  padding: 20px;
  width: min(620px, calc(100vw - 24px));
  max-height: 88vh;
}

dialog::backdrop {
  background: #000a;
}

dialog h2 {
  font-size: 16px;
  margin-bottom: 8px;
  padding-right: 24px;
}

dialog h3 {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--gold);
  margin: 16px 0 6px;
}

dialog p {
  font-size: 10px;
  line-height: 1.7;
  margin-bottom: 8px;
}

dialog .eyebrow {
  margin-bottom: 6px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 18px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.export-grid button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 12px;
  gap: 6px;
  text-align: left;
  text-transform: none;
}

.export-grid button:hover {
  border-color: var(--gold);
}

.file-ext {
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 2px 6px;
}

.export-grid strong {
  font-size: 11px;
  color: var(--text);
}

.export-grid small {
  font-size: 9px;
  color: var(--muted);
}

.export-grid svg {
  position: absolute;
  top: 12px;
  right: 12px;
  color: var(--dim);
  width: 14px;
}

.help-steps {
  padding: 0 0 0 18px;
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}

.help-steps strong {
  color: var(--text);
}

.shortcut-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin: 14px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.shortcut-list > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 9px;
  color: var(--muted);
}

kbd {
  font: 700 9px var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  padding: 2px 5px;
  color: var(--gold);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* RESPONSIVE BREAKPOINTS */
@media (min-width: 1700px) {
  .composer-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
  }
  .timeline-scroll {
    height: 490px;
    max-height: 490px;
  }
}

@media (max-width: 1250px) {
  .composer-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
  }
  .toolbar-hint, .view-name > span, .scale-badge, .track-item small, .palette-hint > span, .brand small {
    display: none;
  }
  .lesson-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Unfolded foldables (e.g. Pixel 10 Pro Fold open ~768-900px) & tablets */
@media (max-width: 1024px) {
  .transport {
    flex-wrap: wrap;
    gap: 8px;
  }
  .transport-settings {
    order: 3;
    width: 100%;
    border-top: 1px solid var(--line);
    padding-top: 8px;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }
  .history {
    margin-left: auto;
  }
  .composer-layout {
    grid-template-columns: 1fr;
  }
  .inspector {
    min-height: 0;
  }
  .chord-palette {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    max-height: none;
  }
  .suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 8px;
  }
  .song-actions .secondary span, .project-tag, .save-state span {
    display: none;
  }
  .save-state {
    border-left: 0;
    padding-left: 2px;
  }
  .library-grid, .preset-grid, .band-settings, .mixer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile phones & closed foldables (e.g. Pixel 10 Pro Fold closed ~360-430px) */
@media (max-width: 760px) {
  .header {
    height: 42px;
    padding: 0 10px;
  }
  .local-badge {
    display: none;
  }
  .workspace {
    flex-direction: column;
    min-height: calc(100vh - 42px);
  }
  .rail {
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .rail > div {
    flex-direction: row;
    gap: 4px;
  }
  .rail > div:first-child {
    flex: 1;
  }
  .rail button {
    width: 38px;
    height: 32px;
    flex: 0 1 42px;
  }
  .rail button.active::before {
    left: 0;
    right: 0;
    top: auto;
    bottom: -7px;
    width: 100%;
    height: 2px;
  }
  main {
    width: 100%;
    padding: 8px 8px 0;
  }
  .song-header {
    padding: 6px 8px;
    gap: 8px;
    margin-bottom: 8px;
  }
  .song-meta {
    flex: 1;
    min-width: 0;
  }
  .title-row {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .title-row input {
    width: 100%;
    flex: 1;
    min-width: 0;
    font-size: 13px;
    padding: 4px 6px;
  }
  .song-actions {
    gap: 4px;
  }
  .song-actions .primary span {
    display: none;
  }
  .song-actions .text {
    padding: 5px 8px;
    min-height: 30px;
  }
  .transport {
    padding: 6px 8px;
    gap: 6px;
    margin-bottom: 8px;
  }
  .transport-play {
    gap: 3px;
  }
  .transport-play button, .history button {
    width: 30px;
    height: 28px;
    min-height: 28px;
    padding: 0;
  }
  .play-button {
    width: 32px;
    height: 28px;
  }
  .position {
    font-size: 13px;
    padding: 3px 6px;
    margin: 0 2px;
    min-width: 58px;
    letter-spacing: 1px;
  }
  .history {
    padding-left: 6px;
    gap: 3px;
  }
  .transport-settings {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    padding-top: 6px;
  }
  .transport-settings .divider {
    display: none;
  }
  .transport-settings .tempo,
  .transport-settings .field {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    min-width: 0;
  }
  .transport-settings > label:nth-child(5) {
    grid-column: span 4;
  }
  .transport-settings > label input,
  .transport-settings > label select {
    width: 100%;
    max-width: none;
    min-height: 28px;
    font-size: 11px;
    text-align: left;
    padding: 3px 6px;
  }
  .editor-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
  }
  .editor-tools {
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
  }
  .editor-tools input[type=number] {
    width: 42px;
  }
  .editor-tools input[type=range] {
    width: 56px;
  }
  .note-toolbar {
    height: auto;
    min-height: 34px;
    flex-wrap: wrap;
    gap: 4px 6px;
    padding: 5px 8px;
  }
  .note-toolbar .tool-label {
    margin-right: 0;
    font-size: 8px;
    gap: 4px;
  }
  .note-toolbar .tool-label svg {
    display: none;
  }
  .duration-controls button {
    min-width: 28px;
    height: 24px;
    min-height: 24px;
    padding: 2px 3px;
    font-size: 9px;
  }
  .duration-text {
    display: none;
  }
  .note-toolbar .field {
    margin-left: auto;
    gap: 4px;
  }
  .note-toolbar .field > span {
    font-size: 8px;
    letter-spacing: 0.5px;
  }
  .note-toolbar .field select {
    width: auto;
    min-width: 54px;
    padding: 2px 4px;
  }
  .accompaniment-bar {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
    gap: 6px;
    padding: 6px 8px;
  }
  .accompaniment-bar:has(.field:nth-of-type(3)) {
    grid-template-columns: 1fr 1fr;
  }
  .accompaniment-bar .field {
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    min-width: 0;
  }
  .accompaniment-bar > button {
    min-height: 26px;
    height: 26px;
    padding: 4px 8px;
    justify-content: center;
  }
  .timeline-scroll {
    height: clamp(260px, 44vh, 380px);
    max-height: clamp(260px, 44vh, 380px);
  }
  .track-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .track-item:nth-child(1), .track-item:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }
  .track-item:nth-child(2) {
    border-right: 0;
  }
  .chord-workbench {
    padding: 10px;
    margin-top: 8px;
  }
  .workbench-heading {
    flex-wrap: wrap;
    gap: 8px;
  }
  .palette-options {
    flex-wrap: wrap;
    gap: 6px;
  }
  .palette-options small {
    width: 100%;
    margin-left: 0;
  }
  .chord-palette {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    grid-auto-flow: row;
    max-height: none;
    overflow: visible;
    padding-bottom: 0;
  }
  .chord-card {
    min-height: 66px;
    padding: 6px 8px;
  }
  .chord-card strong {
    font-size: 15px;
    line-height: 18px;
  }
  .idea-content, .properties {
    padding: 10px;
  }
  .suggestions {
    grid-template-columns: 1fr;
  }
  .search-results {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  }
  .page-panel {
    padding: 12px;
    min-height: 0;
  }
  .library-grid, .lesson-grid, .lyrics-layout, .band-description, .preset-grid {
    grid-template-columns: 1fr;
  }
  .band-settings, .mixer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .scale-lab {
    flex-direction: column;
    align-items: stretch;
  }
  .scale-lab > button {
    justify-content: center;
  }
  .rhythm-row {
    gap: 6px;
  }
  .rhythm-row > span {
    min-width: 52px;
    font-size: 8px;
  }
  .rhythm-row > div {
    gap: 2px;
  }
  .rhythm-row i {
    font-size: 7px;
    height: 20px;
  }
  dialog {
    width: min(520px, calc(100vw - 16px));
    max-height: calc(100vh - 20px);
    overflow-y: auto;
  }
  .modal-card {
    padding: 14px;
  }
  footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 0 18px;
  }
}

@media (max-width: 440px) {
  .editor-tools {
    width: 100%;
    justify-content: space-between;
  }
  .duration-text {
    display: none;
  }
  .duration-controls button {
    min-width: 28px;
    padding: 2px 3px;
    font-size: 9px;
  }
  .note-toolbar .field > span {
    font-size: 8px;
  }
  .export-grid, .shortcut-list, .band-settings, .mixer, .property-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
