/* Studio workstation skin. Layout-only: the existing IDs and music engine stay intact. */
:root {
  --studio-bg: #080a0c;
  --studio-bg-elevated: #0d1013;
  --studio-surface: #111519;
  --studio-surface-2: #151a1f;
  --studio-surface-3: #1a2026;
  --studio-line: #282e35;
  --studio-line-soft: #20262c;
  --studio-text: #f3f4f6;
  --studio-muted: #969da6;
  --studio-subtle: #68717c;
  --studio-accent: #7a67e8;
  --studio-accent-strong: #8b79f2;
  --studio-accent-soft: rgba(122, 103, 232, 0.18);
  --studio-accent-line: rgba(139, 121, 242, 0.58);
  --studio-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  --studio-radius: 8px;
  color-scheme: dark;
}

body:not(.dark) {
  --studio-bg: #e9ebee;
  --studio-bg-elevated: #f3f4f6;
  --studio-surface: #fbfbfc;
  --studio-surface-2: #f1f2f4;
  --studio-surface-3: #e8eaed;
  --studio-line: #d4d8dd;
  --studio-line-soft: #e2e5e9;
  --studio-text: #171a1f;
  --studio-muted: #646c75;
  --studio-subtle: #8b929a;
  --studio-accent-soft: rgba(104, 83, 216, 0.11);
  --studio-accent-line: rgba(104, 83, 216, 0.42);
  --studio-shadow: 0 18px 48px rgba(54, 61, 72, 0.12);
  color-scheme: light;
}

html,
body.reference-workstation {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

body.reference-workstation {
  margin: 0;
  background: var(--studio-bg);
  color: var(--studio-text);
  font-family: Inter, "SF Pro Display", "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body.reference-workstation *,
body.reference-workstation *::before,
body.reference-workstation *::after {
  box-sizing: border-box;
}

body.reference-workstation .ambient {
  display: none;
}

body.reference-workstation [hidden] {
  display: none !important;
}

body.reference-workstation .glass {
  background: var(--studio-surface);
  border: 1px solid var(--studio-line);
  box-shadow: none;
  backdrop-filter: none;
}

body.reference-workstation button,
body.reference-workstation input,
body.reference-workstation select {
  font: inherit;
}

body.reference-workstation button {
  color: inherit;
}

body.reference-workstation .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Primary application grid */
body.reference-workstation .app-shell {
  display: grid;
  grid-template-columns: 338px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 102px;
  gap: 8px;
  width: 100%;
  height: 100dvh;
  min-height: 680px;
  padding: 0 8px 8px 0;
  overflow: hidden;
}

body.reference-workstation:not(.right-rail-collapsed) .app-shell {
  grid-template-columns: 338px minmax(0, 1fr) minmax(280px, 320px);
}

body.reference-workstation .sidebar {
  grid-column: 1;
  grid-row: 1 / 3;
  display: grid;
  grid-template-columns: 102px 236px;
  grid-template-rows: 88px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  border-width: 0 1px 0 0;
  border-radius: 0;
  overflow: hidden;
}

body.reference-workstation .workspace {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-rows: 88px 145px minmax(430px, 1fr) 68px;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  padding-top: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

/* Brand and rail navigation */
body.reference-workstation .brand {
  grid-column: 1 / 3;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  height: 88px;
  padding: 0 24px;
  border-bottom: 1px solid var(--studio-line);
}

body.reference-workstation .brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid var(--studio-line);
  border-radius: 50%;
  overflow: hidden;
  background: var(--studio-surface-2);
}

body.reference-workstation .brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.reference-workstation .brand p {
  margin: 0 0 3px;
  color: var(--studio-muted);
  font-size: 12px;
}

body.reference-workstation .brand h1 {
  margin: 0;
  color: var(--studio-text);
  font-size: 21px;
  line-height: 1;
  font-weight: 700;
}

body.reference-workstation .app-tabs {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  padding: 18px 10px 14px;
  border-right: 1px solid var(--studio-line);
  overflow: hidden;
}

body.reference-workstation .app-tab,
body.reference-workstation .nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 74px;
  padding: 8px 5px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--studio-muted);
  box-shadow: none;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

body.reference-workstation .app-tab i,
body.reference-workstation .nav-tab i {
  font-size: 21px;
  line-height: 1;
}

body.reference-workstation .app-tab span,
body.reference-workstation .nav-tab span {
  font-size: 13px;
  line-height: 1.2;
}

body.reference-workstation .app-tab:hover,
body.reference-workstation .nav-tab:hover {
  color: var(--studio-text);
  background: var(--studio-surface-2);
}

body.reference-workstation .app-tab.active,
body.reference-workstation .nav-tab.active {
  color: #c9c0ff;
  border-color: var(--studio-accent-line);
  background: linear-gradient(180deg, rgba(122, 103, 232, 0.22), rgba(122, 103, 232, 0.1));
}

body:not(.dark).reference-workstation .app-tab.active,
body:not(.dark).reference-workstation .nav-tab.active {
  color: #5b47c5;
}

body.reference-workstation .nav-divider {
  display: block;
  height: 1px;
  margin: 10px 4px;
  background: var(--studio-line);
}

body.reference-workstation .library-tabs {
  display: contents;
}

body.reference-workstation .nav-settings {
  margin-top: auto;
}

/* Chord filter panel */
body.reference-workstation .sidebar-mode,
body.reference-workstation .fret-memory-sidebar,
body.reference-workstation .scale-sidebar,
body.reference-workstation .training-sidebar {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  padding: 28px 16px 18px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--studio-line) transparent;
}

body.reference-workstation .filter-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 15px;
}

body.reference-workstation .filter-panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

body.reference-workstation .search {
  display: block;
  margin: 0 0 18px;
}

body.reference-workstation .search > span {
  display: none;
}

body.reference-workstation .search-control {
  position: relative;
}

body.reference-workstation .search input,
body.reference-workstation .global-search input,
body.reference-workstation .custom-actions input,
body.reference-workstation .compact-input,
body.reference-workstation .compact-select,
body.reference-workstation .select-pill select {
  color: var(--studio-text);
  border: 1px solid var(--studio-line);
  background: var(--studio-bg-elevated);
  outline: none;
}

body.reference-workstation .search input {
  width: 100%;
  height: 40px;
  padding: 0 38px 0 13px;
  border-radius: 6px;
  font-size: 12px;
}

body.reference-workstation .search input:focus,
body.reference-workstation .global-search:focus-within,
body.reference-workstation select:focus {
  border-color: var(--studio-accent-line);
  box-shadow: 0 0 0 2px var(--studio-accent-soft);
}

body.reference-workstation .search-icon {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 16px;
  height: 16px;
  color: var(--studio-muted);
  transform: translateY(-50%);
}

body.reference-workstation .filter-board {
  display: grid;
  gap: 20px;
}

body.reference-workstation .filter-group {
  padding: 0;
  border: 0;
  background: transparent;
}

body.reference-workstation .filter-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--studio-text);
  font-size: 13px;
  font-weight: 700;
}

body.reference-workstation .filter-group-title small {
  color: var(--studio-muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
}

body.reference-workstation .filter-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

body.reference-workstation .filter-chip {
  min-width: 0;
  height: 36px;
  padding: 0 4px;
  border: 1px solid var(--studio-line);
  border-radius: 5px;
  background: transparent;
  color: var(--studio-text);
  box-shadow: none;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

body.reference-workstation .filter-chip:hover {
  border-color: var(--studio-subtle);
  background: var(--studio-surface-2);
}

body.reference-workstation .filter-chip.active {
  color: #fff;
  border-color: var(--studio-accent-strong);
  background: linear-gradient(180deg, #6354ba, #51449e);
}

body.reference-workstation .extension-group,
body.reference-workstation .alteration-group,
body.reference-workstation .mood-group {
  display: none;
}

body.reference-workstation .sidebar-mode.advanced-filters-open :is(.extension-group, .alteration-group, .mood-group) {
  display: block;
}

body.reference-workstation .advanced-filter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 36px;
  margin-top: 2px;
  padding: 0 10px;
  border: 1px solid var(--studio-line);
  border-radius: 5px;
  color: var(--studio-muted);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

body.reference-workstation .advanced-filter-toggle i {
  transition: transform 160ms ease;
}

body.reference-workstation .advanced-filter-toggle[aria-expanded="true"] i {
  transform: rotate(180deg);
}

body.reference-workstation .library-header {
  margin-top: 22px;
}

body.reference-workstation .quick-chord-launch {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 54px;
  padding: 0 14px;
  border: 1px solid var(--studio-accent-line);
  border-radius: 6px;
  color: #c9c0ff;
  background: linear-gradient(180deg, rgba(122, 103, 232, 0.22), rgba(122, 103, 232, 0.1));
  cursor: pointer;
}

body.reference-workstation .quick-chord-launch i {
  font-size: 18px;
}

body.reference-workstation .quick-chord-launch span {
  font-weight: 700;
}

body.reference-workstation .quick-chord-launch kbd {
  margin-left: auto;
  padding: 4px 7px;
  border: 1px solid var(--studio-accent-line);
  border-radius: 4px;
  color: inherit;
  background: rgba(0, 0, 0, 0.16);
  font-size: 11px;
}

/* Common controls */
body.reference-workstation :is(
  .ghost-btn,
  .secondary-btn,
  .primary-btn,
  .icon-btn,
  .instrument-tab,
  .fret-mode,
  .piano-key-mode,
  .guitar-string-mode,
  .bass-string-mode,
  .fret-count-mode,
  .handedness-mode,
  .overlay-mode,
  .rail-tab,
  .play-btn,
  .dashed-btn
) {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--studio-line);
  border-radius: 5px;
  color: var(--studio-text);
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease, transform 140ms ease;
}

body.reference-workstation :is(.ghost-btn, .secondary-btn, .icon-btn):hover {
  border-color: var(--studio-subtle);
  background: var(--studio-surface-2);
}

body.reference-workstation .primary-btn {
  border-color: var(--studio-accent-strong);
  background: linear-gradient(180deg, #7564d8, #5e4eb7);
  color: #fff;
  font-weight: 700;
}

body.reference-workstation button:active {
  transform: translateY(1px);
}

body.reference-workstation :is(
  .instrument-tab,
  .fret-mode,
  .piano-key-mode,
  .guitar-string-mode,
  .bass-string-mode,
  .fret-count-mode,
  .handedness-mode,
  .overlay-mode,
  .rail-tab,
  .play-btn
).active {
  border-color: var(--studio-accent-line);
  color: #d2cbff;
  background: var(--studio-accent-soft);
}

body:not(.dark).reference-workstation :is(
  .instrument-tab,
  .fret-mode,
  .piano-key-mode,
  .guitar-string-mode,
  .bass-string-mode,
  .fret-count-mode,
  .handedness-mode,
  .overlay-mode,
  .rail-tab,
  .play-btn
).active {
  color: #5946be;
}

/* Top command bar */
body.reference-workstation .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-width: 0;
  height: 88px;
  padding: 0 24px 0 8px;
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
}

body.reference-workstation .chord-title {
  min-width: 210px;
}

body.reference-workstation .eyebrow,
body.reference-workstation .section-label {
  margin: 0 0 6px;
  color: var(--studio-muted);
  font-size: 11px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

body.reference-workstation .chord-title > div {
  display: flex;
  align-items: center;
  gap: 13px;
}

body.reference-workstation .chord-title h2 {
  margin: 0;
  font-size: 36px;
  line-height: 1;
  font-weight: 700;
}

body.reference-workstation .star-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--studio-muted);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

body.reference-workstation .quality-badge {
  padding: 7px 10px;
  border: 1px solid var(--studio-accent-line);
  border-radius: 5px;
  color: #c6bdff;
  background: var(--studio-accent-soft);
  font-size: 12px;
  white-space: nowrap;
}

body.reference-workstation .top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

body.reference-workstation .select-pill {
  display: grid;
  gap: 5px;
  width: 126px;
  color: var(--studio-muted);
  font-size: 10px;
}

body.reference-workstation .select-pill select {
  height: 40px;
  padding: 0 11px;
  border-radius: 6px;
  font-size: 12px;
}

body.reference-workstation .global-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(260px, 23vw);
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--studio-line);
  border-radius: 6px;
  color: var(--studio-muted);
  background: var(--studio-bg-elevated);
}

body.reference-workstation .global-search input {
  min-width: 0;
  flex: 1;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 12px;
  box-shadow: none;
}

body.reference-workstation .global-search kbd {
  padding: 3px 5px;
  border: 1px solid var(--studio-line);
  border-radius: 4px;
  color: var(--studio-muted);
  background: var(--studio-surface-2);
  font-size: 10px;
}

body.reference-workstation .top-actions .icon-btn {
  height: 40px;
  min-height: 40px;
  white-space: nowrap;
}

body.reference-workstation .top-actions .help-icon {
  width: 40px;
  padding: 0;
  border-width: 0 0 0 1px;
  border-radius: 0;
  font-size: 21px;
}

/* Theory summary */
body.reference-workstation .detail-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 0.85fr 1.45fr;
  min-width: 0;
  min-height: 0;
  height: 145px;
  padding: 16px 20px;
  border-radius: var(--studio-radius);
  overflow: hidden;
}

body.reference-workstation .detail-strip > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 0 18px;
  border-right: 1px solid var(--studio-line);
}

body.reference-workstation .detail-strip > div:first-child {
  padding-left: 0;
}

body.reference-workstation .detail-strip > div:last-child {
  padding-right: 0;
  border-right: 0;
}

body.reference-workstation .note-row,
body.reference-workstation .degree-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 9px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}

body.reference-workstation .note-row::-webkit-scrollbar,
body.reference-workstation .degree-row::-webkit-scrollbar {
  display: none;
}

body.reference-workstation .note-chip,
body.reference-workstation .degree-chip,
body.reference-workstation .note-row button,
body.reference-workstation .degree-row button,
body.reference-workstation .degree-pill {
  display: grid;
  place-items: center;
  min-width: 50px;
  height: 58px;
  padding: 5px;
  border: 1px solid var(--studio-line);
  border-radius: 6px;
  background: transparent;
  color: var(--studio-text);
  box-shadow: none;
  font-size: 18px;
}

body.reference-workstation .note-pill.active-note,
body.reference-workstation .degree-pill:first-child {
  border-color: var(--studio-accent-line);
  background: var(--studio-accent-soft);
}

body.reference-workstation .note-pill.is-dimmed {
  opacity: 0.38;
}

body.reference-workstation .note-row small,
body.reference-workstation .degree-row small {
  color: var(--studio-muted);
  font-size: 11px;
}

body.reference-workstation .formula-text {
  color: var(--studio-text);
  font-size: 24px;
  line-height: 1.35;
  word-spacing: 18px;
}

body.reference-workstation .scale-type-button {
  min-height: 52px;
  align-content: center;
}

body.reference-workstation .scale-type-button small {
  line-height: 1.25;
}

body.reference-workstation .color-copy p:last-child {
  margin: 0;
  color: var(--studio-text);
  font-size: 14px;
  line-height: 1.65;
}

/* Instrument stage */
body.reference-workstation .instrument-panel {
  position: relative;
  display: grid;
  grid-template-rows: 66px auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 500px;
  padding: 0;
  border-radius: var(--studio-radius);
  overflow: hidden;
}

body.reference-workstation .instrument-panel > .panel-title {
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  height: 66px;
  padding: 0 14px;
  border-bottom: 1px solid var(--studio-line);
  background: var(--studio-surface);
  overflow: hidden;
}

body.reference-workstation .instrument-label {
  color: var(--studio-muted);
  font-size: 11px;
}

body.reference-workstation .segmented {
  display: flex;
  align-items: center;
  gap: 4px;
}

body.reference-workstation .instrument-tabs {
  padding: 3px;
  border: 1px solid var(--studio-line);
  border-radius: 6px;
  background: var(--studio-bg-elevated);
}

body.reference-workstation .instrument-tab {
  min-width: 60px;
  border-color: transparent;
}

body.reference-workstation .instrument-quick-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-left: auto;
  flex: 0 1 auto;
}

body.reference-workstation .quick-volume {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  color: var(--studio-muted);
  font-size: 12px;
}

body.reference-workstation input[type="range"] {
  accent-color: var(--studio-accent-strong);
}

body.reference-workstation .quick-volume input {
  width: 135px;
}

body.reference-workstation .instrument-settings {
  width: 38px;
  padding: 0;
}

body.reference-workstation .instrument-tools {
  grid-row: 2;
  position: static;
  z-index: auto;
  display: none;
  grid-template-columns: repeat(3, minmax(0, auto));
  align-items: center;
  gap: 9px;
  width: auto;
  max-height: 96px;
  margin: 8px 12px 0;
  padding: 10px;
  border: 1px solid var(--studio-line-soft);
  border-radius: 6px;
  background: var(--studio-bg-elevated);
  box-shadow: none;
  overflow: auto;
}

body.reference-workstation .instrument-panel.settings-open .instrument-tools {
  display: grid;
}

body.reference-workstation .instrument-panel.settings-open {
  min-height: 700px;
}

body.reference-workstation .instrument-panel:is([data-string-count="7"], [data-string-count="5"], [data-fret-count="24"]) {
  min-height: 540px;
}

body.reference-workstation .instrument-panel.settings-open:is([data-string-count="7"], [data-string-count="5"], [data-fret-count="24"]) {
  min-height: 740px;
}

body.reference-workstation .instrument-tools .small {
  flex-wrap: wrap;
}

body.reference-workstation .instrument-tools #instrumentHint {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--studio-muted);
  font-size: 11px;
}

body.reference-workstation .arpeggio-panel {
  grid-row: 3;
  position: static;
  z-index: auto;
  width: auto;
  max-width: none;
  min-height: 0;
  max-height: 64px;
  margin: 8px 12px 0;
  padding: 8px 10px;
  border-color: var(--studio-line-soft);
  border-radius: 6px;
  background: var(--studio-bg-elevated);
  overflow: hidden;
}

body.reference-workstation .instrument-view {
  grid-row: 4;
  position: relative;
  min-width: 0;
  min-height: 410px;
  width: 100%;
  height: 100%;
  margin-top: 0;
  padding: 0;
  background: #050608;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #4e5662 #0b0f14;
}

body.reference-workstation .instrument-view .piano {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 430px;
  min-width: 0;
  padding: 34px 14px 16px;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, #1a2028 0, #0b0f14 29px, transparent 30px),
    linear-gradient(180deg, #11161d, #07090c);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -20px 34px rgba(0, 0, 0, 0.46);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #3b424b #0b0f14;
}

body.reference-workstation .instrument-view .piano-keybed {
  position: relative;
  display: flex;
  width: 100%;
  min-width: var(--piano-min-width, 0);
  height: 100%;
  border: 1px solid #252b33;
  border-top-color: #3b424b;
  background: #07090c;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
  overflow: visible;
}

body.reference-workstation .instrument-view .white-key {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  border: 1px solid rgba(50, 55, 61, 0.62);
  border-top: 0;
  border-radius: 0 0 5px 5px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.14), transparent 13%, transparent 84%, rgba(0, 0, 0, 0.14)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(214, 211, 204, 0.42)),
    url("../assets/piano-ivory-key.png");
  background-size: auto, auto, 100% 100%;
  box-shadow:
    inset 0 -14px 22px rgba(55, 58, 62, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 2px 3px rgba(0, 0, 0, 0.28);
}

body.reference-workstation .instrument-view .black-key {
  position: absolute;
  z-index: 4;
  top: 0;
  width: calc(56% / var(--white-keys, 14));
  height: 62%;
  transform: translateX(-50%);
  border: 1px solid rgba(0, 0, 0, 0.9);
  border-radius: 0 0 5px 5px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14), transparent 30%, rgba(0, 0, 0, 0.56)),
    url("../assets/piano-ebony-key.png");
  background-size: auto, 100% 100%;
  box-shadow:
    0 9px 11px rgba(0, 0, 0, 0.48),
    inset 0 -12px 18px rgba(255, 255, 255, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

body.reference-workstation .instrument-view .key-label {
  position: absolute;
  left: 50%;
  bottom: 9px;
  display: block;
  color: #687586;
  font-size: 10px;
  transform: translateX(-50%);
}

body.reference-workstation .instrument-view :is(.white-key, .black-key).hit {
  cursor: pointer;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--note-glow) 72%, #fff), var(--note-color)) !important;
  box-shadow:
    inset 0 -14px 22px color-mix(in srgb, var(--note-color) 52%, #101217),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 1px var(--note-color),
    0 0 22px var(--note-glow);
}

body.reference-workstation .instrument-view .degree-dot {
  position: absolute;
  left: 50%;
  top: 57%;
  bottom: auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: color-mix(in srgb, var(--note-color) 76%, #101010);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 18px var(--note-glow);
  white-space: nowrap;
}

/* Guitar and bass retain the functional board, with a restrained studio frame. */
body.reference-workstation .instrument-view > .fretboard {
  position: absolute;
  inset: 16px 18px;
  width: auto;
  height: auto;
  margin: 0;
  border: 1px solid #4f443a;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -16px 30px rgba(0, 0, 0, 0.24), 0 22px 38px rgba(0, 0, 0, 0.34);
  overflow: hidden;
}

body.reference-workstation .instrument-view > .fretboard[data-fret-count="24"] {
  min-width: 1500px;
}

body.reference-workstation .instrument-view:is([data-string-count="7"], [data-string-count="5"], [data-fret-count="24"]) {
  min-height: 450px;
}

body.reference-workstation .instrument-view > .fretboard:not(.is-bass) {
  --string-top: rgba(255, 255, 255, 1);
  --string-core: rgba(215, 225, 235, 0.98);
  --string-shadow: rgba(0, 0, 0, 0.88);
  border-color: rgba(206, 176, 158, 0.34);
  background:
    linear-gradient(180deg, rgba(255, 246, 240, 0.3), transparent 24%, rgba(16, 7, 10, 0.12)),
    linear-gradient(90deg, rgba(255, 226, 204, 0.18), transparent 14%, transparent 86%, rgba(18, 8, 12, 0.16)),
    linear-gradient(rgba(112, 68, 66, 0.14), rgba(51, 28, 37, 0.05)),
    url("../assets/guitar-rosewood-fretboard.png") center / cover no-repeat;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 18px 28px rgba(255, 232, 220, 0.06),
    inset 0 -22px 30px rgba(0, 0, 0, 0.34),
    0 18px 34px rgba(0, 0, 0, 0.32);
}

body.reference-workstation .fretboard .string-name {
  min-width: 44px;
  min-height: 28px;
  padding-inline: 8px;
  border-color: rgba(255, 255, 255, 0.42);
  color: #ffffff;
  background: rgba(10, 14, 21, 0.88);
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  white-space: nowrap;
}

body.reference-workstation .fretboard:not(.is-bass) .string-row::before {
  filter: brightness(1.16);
  box-shadow:
    0 1px 2px var(--string-shadow),
    0 -1px 1px rgba(255, 255, 255, 0.5),
    0 0 calc(var(--string-size, 2px) * 1.3) rgba(255, 255, 255, 0.24);
}

body.reference-workstation .fretboard .string-row {
  min-height: 0;
}

/* Compact chord progression */
body.reference-workstation .progression {
  position: relative;
  display: grid;
  grid-template-columns: 154px minmax(0, 1fr) auto;
  align-items: stretch;
  min-width: 0;
  min-height: 68px;
  height: 68px;
  padding: 0;
  border-radius: var(--studio-radius);
  overflow: hidden;
}

body.reference-workstation .progression > .panel-title {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-right: 1px solid var(--studio-line);
}

body.reference-workstation .progression > .panel-title > div {
  min-width: 0;
}

body.reference-workstation .progression > .panel-title h3 {
  margin: 0;
  font-size: 14px;
}

body.reference-workstation .progression > .panel-title .section-label {
  display: none;
}

body.reference-workstation .progression .mini-actions {
  position: static;
  grid-column: 3;
  z-index: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0 12px 0 8px;
}

body.reference-workstation .progression-body {
  grid-column: 2;
  min-width: 0;
  min-height: 0;
  padding-right: 0;
  overflow: hidden;
}

body.reference-workstation .timeline,
body.reference-workstation .progression-chips {
  width: 100%;
  height: 100%;
  min-width: 0;
}

body.reference-workstation .bar-ruler {
  display: none;
}

body.reference-workstation .progression-chips {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}

body.reference-workstation .progression-chip {
  position: relative;
  flex: 0 0 98px;
  height: 54px;
  padding: 7px 10px;
  border: 1px solid var(--studio-line);
  border-radius: 5px;
  background: var(--studio-bg-elevated);
  color: var(--studio-text);
  box-shadow: none;
  overflow: hidden;
}

body.reference-workstation .progression-chip.selected,
body.reference-workstation .progression-chip.playing {
  border-color: var(--studio-accent-strong);
  background: var(--studio-accent-soft);
}

body.reference-workstation .progression-chip small {
  display: block;
  color: var(--studio-muted);
  font-size: 10px;
}

body.reference-workstation .progression-chip strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

body.reference-workstation .progression-chip .chip-actions {
  display: none;
}

body.reference-workstation .export-status {
  display: none;
}

body.reference-workstation.progression-collapsed .progression {
  height: 42px;
  min-height: 42px;
}

body.reference-workstation.progression-collapsed .progression .mini-actions > :not(#toggleProgression) {
  display: none;
}

/* Bottom transport */
body.reference-workstation .transport {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 0;
  height: 102px;
  padding: 0 20px;
  border-radius: var(--studio-radius);
  overflow: hidden;
}

body.reference-workstation .transport-collapse-toggle {
  position: absolute;
  right: 12px;
  top: 8px;
  z-index: 2;
  height: 30px;
  min-height: 30px;
  padding: 0 8px;
  font-size: 10px;
  opacity: 1;
  pointer-events: auto;
}

body.reference-workstation .transport:hover .transport-collapse-toggle {
  opacity: 1;
  pointer-events: auto;
}

body.reference-workstation .transport-body {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-width: 0;
  padding-right: 92px;
}

body.reference-workstation .transport-icon {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--studio-muted);
  background: transparent;
  font-size: 21px;
  cursor: pointer;
}

body.reference-workstation .transport-icon:hover {
  color: var(--studio-text);
  background: var(--studio-surface-2);
}

body.reference-workstation .big-play {
  display: grid;
  place-items: center;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  padding: 0 0 0 3px;
  border: 1px solid var(--studio-accent-strong);
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #8976ef, #604eb9);
  box-shadow: 0 10px 26px rgba(89, 73, 185, 0.28);
  font-size: 30px;
  cursor: pointer;
}

body.reference-workstation .play-modes {
  display: flex;
  gap: 5px;
  padding-right: 14px;
  border-right: 1px solid var(--studio-line);
}

body.reference-workstation .play-btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 11px;
}

body.reference-workstation .number-stepper,
body.reference-workstation .toggle-line,
body.reference-workstation .volume-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--studio-muted);
  font-size: 11px;
  white-space: nowrap;
}

body.reference-workstation .number-stepper button {
  width: 28px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--studio-line);
  border-radius: 5px;
  color: var(--studio-text);
  background: transparent;
}

body.reference-workstation .number-stepper strong {
  color: var(--studio-text);
  font-size: 13px;
}

body.reference-workstation .number-stepper input[type="range"] {
  width: 150px;
}

body.reference-workstation .volume-line {
  margin-left: auto;
}

body.reference-workstation .volume-line input {
  width: 120px;
}

body.reference-workstation.transport-collapsed .transport {
  height: 46px;
  align-self: end;
}

body.reference-workstation.transport-collapsed .transport-body {
  display: none;
}

/* Right detail drawer */
body.reference-workstation .right-rail-toggle {
  position: fixed;
  z-index: 42;
  top: 50%;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 38px;
  min-height: 136px;
  padding: 10px 6px;
  border: 1px solid var(--studio-line);
  border-right: 0;
  border-radius: 7px 0 0 7px;
  color: var(--studio-text);
  background: var(--studio-surface);
  box-shadow: var(--studio-shadow);
  cursor: pointer;
  transform: translateY(-50%);
}

body.reference-workstation .right-rail-toggle span {
  writing-mode: vertical-rl;
  font-size: 12px;
  letter-spacing: 2px;
}

/* Non-chord workspaces own the center canvas; keep the chord workstation out of their grid. */
body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) :is(
  .topbar,
  .detail-strip,
  .instrument-panel,
  .progression,
  .right-rail-toggle,
  .right-rail,
  .transport
) {
  display: none !important;
}

@media (min-width: 761px) {
  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .app-shell {
    grid-template-columns: 338px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .sidebar {
    grid-row: 1;
  }

  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .workspace {
    grid-column: 2;
    grid-row: 1;
    grid-template-rows: minmax(0, 1fr);
    overflow: auto;
  }

  /* Training contains article-length lessons. Constrain the workspace to the
     viewport so it becomes the one primary scroller instead of expanding
     behind the shell's clipped overflow. */
  body.reference-workstation.training-active .app-shell {
    height: 100dvh;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }

  body.reference-workstation.training-active .workspace {
    height: 100%;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-content: stretch;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  body.reference-workstation.training-active .training-page {
    grid-row: 1;
    align-self: start;
    overflow: visible;
  }
}

body.reference-workstation .right-rail {
  grid-column: 3;
  grid-row: 1 / 3;
  position: relative;
  z-index: 41;
  top: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 10px;
  border: 1px solid var(--studio-line);
  border-radius: 0;
  background: var(--studio-surface);
  box-shadow: var(--studio-shadow);
  overflow: auto;
  transform: none;
  transition: none;
}

body.reference-workstation.right-rail-collapsed .right-rail {
  display: none;
}

body.reference-workstation:not(.right-rail-collapsed) .right-rail-toggle {
  right: 328px;
}

body.reference-workstation .rail-card {
  padding: 14px;
  border: 0;
  border-bottom: 1px solid var(--studio-line);
  border-radius: 0;
  background: transparent;
}

body.reference-workstation .rail-card:last-child {
  border-bottom: 0;
}

body.reference-workstation .rail-card h3 {
  margin: 0;
  font-size: 17px;
}

body.reference-workstation .rail-tabs {
  display: flex;
  gap: 5px;
  margin: 12px 0;
}

body.reference-workstation .rail-tab {
  flex: 1;
}

body.reference-workstation .custom-recognition,
body.reference-workstation .custom-notes,
body.reference-workstation .fret-selection-chips,
body.reference-workstation .reverse-candidates,
body.reference-workstation .saved-chords {
  color: var(--studio-muted);
}

body.reference-workstation .custom-notes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0;
}

body.reference-workstation .custom-note {
  height: 34px;
  border: 1px solid var(--studio-line);
  border-radius: 5px;
  color: var(--studio-text);
  background: transparent;
}

body.reference-workstation .custom-actions,
body.reference-workstation .reverse-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

body.reference-workstation .custom-actions input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border-radius: 5px;
}

body.reference-workstation .dashed-btn {
  width: 100%;
  margin-top: 10px;
  border-style: dashed;
}

/* Floating quick chord browser */
body.reference-workstation .chord-picker-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
}

body.reference-workstation .chord-picker-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(5px);
}

body.reference-workstation .chord-picker-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(760px, calc(100vw - 40px));
  max-height: min(680px, calc(100dvh - 40px));
  min-height: 420px;
  padding: 0;
  border: 1px solid var(--studio-line);
  border-radius: 10px;
  background: var(--studio-surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

body.reference-workstation .chord-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--studio-line);
}

body.reference-workstation .chord-picker-header h2,
body.reference-workstation .chord-picker-header p {
  margin: 0;
}

body.reference-workstation .chord-picker-header h2 {
  margin: 3px 0;
  font-size: 22px;
}

body.reference-workstation .chord-picker-header p:last-child {
  color: var(--studio-muted);
  font-size: 12px;
}

body.reference-workstation .chord-picker-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--studio-line);
  border-radius: 50%;
  color: var(--studio-text);
  background: transparent;
  font-size: 24px;
  cursor: pointer;
}

body.reference-workstation .chord-picker-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 0;
  padding: 16px;
  overflow: auto;
}

body.reference-workstation .chord-picker-list .chord-item {
  min-height: 112px;
  padding: 11px;
  border: 1px solid var(--studio-line);
  border-radius: 6px;
  color: var(--studio-text);
  background: var(--studio-bg-elevated);
}

/* Alternate tools keep their existing behavior and become scroll-safe. */
body.reference-workstation :is(.fret-memory-page, .scale-page, .training-page) {
  grid-row: 2 / 5;
  min-width: 0;
  min-height: 0;
  padding: 20px;
  border-radius: var(--studio-radius);
  overflow: auto;
}

body.reference-workstation :is(.fret-memory-sidebar, .scale-sidebar, .training-sidebar) h3 {
  margin: 0 0 8px;
}

body.reference-workstation :is(.fret-memory-sidebar, .scale-sidebar, .training-sidebar) p {
  color: var(--studio-muted);
  line-height: 1.6;
}

body.reference-workstation :is(
  .fret-memory-header,
  .scale-header,
  .training-header,
  .fret-memory-controls,
  .scale-controls,
  .training-controls,
  .training-plan,
  .training-question-card,
  .scale-related-card,
  .scale-instrument-card,
  .scale-info-card,
  .training-record-card
) {
  border-color: var(--studio-line);
  background: var(--studio-surface-2);
}

/* Light theme keeps the application structure while preserving the dark instrument stage. */
body:not(.dark).reference-workstation .quality-badge {
  color: #5a47bd;
}

body:not(.dark).reference-workstation .quick-chord-launch {
  color: #5a47bd;
}

body:not(.dark).reference-workstation .instrument-view,
body:not(.dark).reference-workstation .instrument-view:has(.piano) {
  color-scheme: dark;
}

/* Responsive containment: no overlaps, no horizontal page scrollbar. */
@media (max-width: 1320px) {
  body.reference-workstation .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  body.reference-workstation:not(.right-rail-collapsed) .app-shell {
    grid-template-columns: 300px minmax(0, 1fr) minmax(270px, 300px);
  }

  body.reference-workstation:not(.right-rail-collapsed) .right-rail-toggle {
    right: 308px;
  }

  body.reference-workstation .sidebar {
    grid-template-columns: 86px 214px;
  }

  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  body.reference-workstation .app-tab,
  body.reference-workstation .nav-tab {
    min-height: 66px;
  }

  body.reference-workstation .app-tab[data-app-view="fret-memory"] {
    padding-block: 4px;
  }

  body.reference-workstation .detail-strip {
    grid-template-columns: 1fr 1fr 0.75fr 1.2fr;
  }

  body.reference-workstation .quick-volume {
    min-width: 175px;
  }

  body.reference-workstation .quick-volume input {
    width: 90px;
  }

  body.reference-workstation:not(.right-rail-collapsed) :is(.global-search, .quick-volume, #quickReplay, .play-modes) {
    display: none;
  }

  body.reference-workstation:not(.right-rail-collapsed) .detail-strip {
    grid-template-columns: 1fr 1fr 0.8fr;
  }

  body.reference-workstation:not(.right-rail-collapsed) .detail-strip .color-copy {
    display: none;
  }

  body.reference-workstation .play-modes .play-btn:nth-child(n + 3),
  body.reference-workstation .toggle-line:nth-of-type(2) {
    display: none;
  }
}

@media (max-width: 1080px) {
  body.reference-workstation .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  body.reference-workstation:not(.right-rail-collapsed) .app-shell {
    grid-template-columns: 84px minmax(0, 1fr) 280px;
  }

  body.reference-workstation:not(.right-rail-collapsed) .right-rail-toggle {
    right: 288px;
  }

  body.reference-workstation .sidebar {
    grid-template-columns: 84px;
  }

  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  body.reference-workstation .brand {
    grid-column: 1;
    padding: 0 20px;
  }

  body.reference-workstation .brand > div:last-child,
  body.reference-workstation .sidebar-mode,
  body.reference-workstation .fret-memory-sidebar,
  body.reference-workstation .scale-sidebar,
  body.reference-workstation .training-sidebar {
    display: none !important;
  }

  body.reference-workstation .app-tabs {
    grid-column: 1;
    border-right: 0;
  }

  body.reference-workstation .global-search {
    display: none;
  }

  body.reference-workstation :is(.quick-volume, #quickReplay) {
    display: none;
  }

  body.reference-workstation .detail-strip {
    grid-template-columns: 1fr 1fr 0.85fr;
  }

  body.reference-workstation .detail-strip .color-copy {
    display: none;
  }

  body.reference-workstation .play-modes,
  body.reference-workstation .toggle-line,
  body.reference-workstation .volume-line {
    display: none;
  }

  body.reference-workstation .number-stepper {
    margin-left: auto;
  }
}

@media (max-width: 900px) and (min-width: 761px) {
  body.reference-workstation .topbar {
    gap: 12px;
    padding-right: 12px;
  }

  body.reference-workstation .chord-title {
    min-width: 0;
  }

  body.reference-workstation .top-actions .select-pill,
  body.reference-workstation .top-actions .icon-btn span,
  body.reference-workstation .top-actions .icon-btn .bi-chevron-down {
    display: none;
  }

  body.reference-workstation .top-actions .icon-btn:not(.help-icon) {
    width: 40px;
    padding: 0;
  }

  body.reference-workstation .detail-strip {
    grid-template-columns: 1fr 1fr;
  }

  body.reference-workstation .detail-strip > div:nth-child(n + 3) {
    display: none;
  }

  body.reference-workstation .number-stepper input[type="range"] {
    display: none;
  }
}

@media (max-height: 760px) and (min-width: 761px) {
  body.reference-workstation .app-shell {
    min-height: 560px;
    grid-template-rows: minmax(0, 1fr) 72px;
  }

  body.reference-workstation .workspace {
    grid-template-rows: 70px 112px minmax(220px, 1fr) 50px;
    gap: 8px;
  }

  body.reference-workstation .topbar {
    height: 70px;
  }

  body.reference-workstation .detail-strip {
    height: 112px;
    padding-block: 10px;
  }

  body.reference-workstation .instrument-panel {
    min-height: 0;
    grid-template-rows: 58px auto auto minmax(0, 1fr);
  }

  body.reference-workstation .instrument-panel.settings-open,
  body.reference-workstation .instrument-panel:is([data-string-count="7"], [data-string-count="5"], [data-fret-count="24"]),
  body.reference-workstation .instrument-panel.settings-open:is([data-string-count="7"], [data-string-count="5"], [data-fret-count="24"]) {
    min-height: 360px;
  }

  body.reference-workstation .instrument-view,
  body.reference-workstation .instrument-view .piano,
  body.reference-workstation .instrument-view:is([data-string-count="7"], [data-string-count="5"], [data-fret-count="24"]) {
    min-height: 220px;
  }

  body.reference-workstation .instrument-panel > .panel-title {
    height: 58px;
  }

  body.reference-workstation .instrument-tools {
    max-height: 68px;
    margin-top: 6px;
    padding-block: 7px;
  }

  body.reference-workstation .arpeggio-panel {
    max-height: 50px;
    margin-top: 6px;
    padding-block: 6px;
  }

  body.reference-workstation .progression {
    min-height: 50px;
    height: 50px;
  }

  body.reference-workstation .transport {
    height: 72px;
  }

  body.reference-workstation .big-play {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }
}

@media (max-width: 760px) {
  html,
  body.reference-workstation {
    overflow: auto;
  }

  body.reference-workstation .app-shell {
    display: block;
    min-height: 100dvh;
    height: auto;
    padding: 0;
    overflow: visible;
  }

  body.reference-workstation .sidebar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: block;
    width: 100%;
    height: 64px;
    border: 0;
  }

  body.reference-workstation .brand {
    position: absolute;
    left: 0;
    top: 0;
    width: 64px;
    height: 64px;
    padding: 11px;
    border: 0;
  }

  body.reference-workstation .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  body.reference-workstation .app-tabs {
    display: flex;
    flex-direction: row;
    gap: 3px;
    width: calc(100% - 64px);
    height: 64px;
    margin-left: 64px;
    padding: 5px 6px;
    border: 0;
    overflow-x: auto;
  }

  body.reference-workstation .app-tab,
  body.reference-workstation .nav-tab {
    flex: 0 0 64px;
    min-height: 52px;
    gap: 3px;
  }

  body.reference-workstation .app-tab span,
  body.reference-workstation .nav-tab span {
    font-size: 9px;
  }

  body.reference-workstation .nav-divider,
  body.reference-workstation .nav-settings {
    display: none;
  }

  body.reference-workstation .workspace {
    display: grid;
    grid-template-rows: auto auto minmax(420px, 58vh) auto;
    gap: 8px;
    padding: 8px;
    overflow: visible;
  }

  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .workspace {
    grid-template-rows: minmax(0, auto);
  }

  body.reference-workstation .topbar {
    height: 74px;
    padding: 0 6px;
  }

  body.reference-workstation .chord-title h2 {
    font-size: 28px;
  }

  body.reference-workstation .quality-badge,
  body.reference-workstation .select-pill,
  body.reference-workstation .top-actions .icon-btn span,
  body.reference-workstation .top-actions .icon-btn .bi-chevron-down {
    display: none;
  }

  body.reference-workstation .detail-strip {
    grid-template-columns: 1fr 1fr;
    height: auto;
    min-height: 116px;
    padding: 12px;
  }

  body.reference-workstation .detail-strip > div {
    padding: 0 10px;
  }

  body.reference-workstation .detail-strip > div:nth-child(2) {
    border-right: 0;
  }

  body.reference-workstation .detail-strip > div:nth-child(n + 3) {
    display: none;
  }

  body.reference-workstation .instrument-panel {
    min-height: 520px;
    grid-template-rows: 56px auto auto minmax(0, 1fr);
  }

  body.reference-workstation .instrument-tools {
    grid-template-columns: 1fr;
    max-height: 150px;
  }

  body.reference-workstation .instrument-view .piano {
    padding: 24px 8px 10px;
  }

  body.reference-workstation .instrument-panel > .panel-title {
    height: 56px;
    padding: 0 8px;
  }

  body.reference-workstation .instrument-label,
  body.reference-workstation .quick-volume,
  body.reference-workstation #quickReplay {
    display: none;
  }

  body.reference-workstation .progression {
    grid-template-columns: 96px minmax(0, 1fr) auto;
  }

  body.reference-workstation .progression-body {
    grid-column: 2;
    padding-right: 0;
  }

  body.reference-workstation .progression .mini-actions {
    display: flex;
    grid-column: 3;
    padding: 0 6px;
  }

  body.reference-workstation .progression .mini-actions > :not(#toggleProgression) {
    display: none;
  }

  body.reference-workstation .progression .mini-actions #toggleProgression {
    min-height: 30px;
    padding-inline: 7px;
    font-size: 10px;
  }

  body.reference-workstation .transport {
    position: sticky;
    z-index: 29;
    bottom: 0;
    width: calc(100% - 16px);
    height: 78px;
    margin: 8px;
  }

  body.reference-workstation .number-stepper input,
  body.reference-workstation .play-modes {
    display: none;
  }

  body.reference-workstation .right-rail {
    position: fixed;
    grid-column: auto;
    grid-row: auto;
    top: 72px;
    right: 8px;
    bottom: 86px;
    width: calc(100vw - 16px);
    height: auto;
    border-radius: var(--studio-radius);
  }

  body.reference-workstation:not(.right-rail-collapsed) .right-rail-toggle {
    right: 0;
  }

  body.reference-workstation .chord-picker-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* The learning surface needs reading width sooner than the workstation tools.
   Keep this training-only so chord, fretboard, and scale layouts are unchanged. */
@media (min-width: 761px) and (max-width: 1499px) {
  body.reference-workstation.training-active .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  body.reference-workstation.training-active .sidebar {
    grid-template-columns: 84px;
  }

  body.reference-workstation.training-active .brand {
    grid-column: 1;
    padding-inline: 20px;
  }

  body.reference-workstation.training-active .brand > div:last-child,
  body.reference-workstation.training-active .sidebar-mode,
  body.reference-workstation.training-active .training-sidebar {
    display: none !important;
  }

  body.reference-workstation.training-active .app-tabs {
    grid-column: 1;
    border-right: 0;
  }
}

/* Full-site desktop containment.
   The app shell owns the viewport, the center workspace owns vertical scroll,
   and the footer is allowed to wrap to its natural height. This keeps every
   tool reachable at short desktop heights and browser zoom without changing
   any application state or hiding controls. */
@media (min-width: 761px) {
  body.reference-workstation:not(.right-rail-collapsed) .right-rail-toggle {
    transform: translate(16px, -50%);
  }

  body.reference-workstation .sidebar {
    padding: 0;
    gap: 0;
  }

  body.reference-workstation:not(.right-rail-collapsed) .right-rail {
    display: block;
  }

  body.reference-workstation:not(.fret-memory-active):not(.scale-active):not(.training-active) .app-shell {
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: stretch;
  }

  body.reference-workstation:not(.fret-memory-active):not(.scale-active):not(.training-active) .workspace {
    height: 100%;
    min-height: 0;
    grid-template-rows: auto auto auto minmax(min-content, 1fr) !important;
    align-self: stretch;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
  }

  body.reference-workstation:not(.fret-memory-active):not(.scale-active):not(.training-active) .detail-strip {
    height: auto;
    overflow: visible;
  }

  body.reference-workstation:not(.right-rail-collapsed) .detail-strip {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr);
  }

  body.reference-workstation .formula-text {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  body.reference-workstation:not(.fret-memory-active):not(.scale-active):not(.training-active) .transport {
    height: auto;
    min-height: 72px;
    align-self: end;
  }

  body.reference-workstation:not(.fret-memory-active):not(.scale-active):not(.training-active) .transport-body,
  body.reference-workstation:not(.fret-memory-active):not(.scale-active):not(.training-active) .play-modes {
    min-width: 0;
    flex-wrap: wrap;
  }

  body.reference-workstation:is(.fret-memory-active, .scale-active) .app-shell {
    height: 100dvh;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  body.reference-workstation:is(.fret-memory-active, .scale-active) .workspace {
    height: 100%;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-self: stretch;
    align-content: stretch;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
  }

  body.reference-workstation :is(.fret-memory-page, .scale-page, .training-page) {
    grid-template-columns: minmax(0, 1fr);
  }

  body.reference-workstation :is(.fret-memory-page, .scale-page, .training-page) > * {
    min-width: 0;
  }

  body.reference-workstation.fret-memory-active .fret-memory-page,
  body.reference-workstation.scale-active .scale-page {
    grid-row: 1;
    align-self: start;
    overflow: visible;
  }
}

/* Medium workspaces switch the dense scale/training grids to the same
   responsive templates used elsewhere in the app. No content is removed: the
   cards reflow vertically and remain inside the workspace scroller. */
@media (min-width: 761px) and (max-width: 1100px) {
  body.reference-workstation .workspace {
    scrollbar-gutter: auto;
  }

  body.reference-workstation :is(.scale-header, .training-header) {
    flex-wrap: wrap;
  }

  body.reference-workstation :is(.scale-summary, .training-summary) {
    width: 100%;
    min-width: 0;
  }

  body.reference-workstation .training-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.reference-workstation .scale-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.reference-workstation .scale-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.reference-workstation .scale-detail-grid > :last-child {
    grid-column: 1 / -1;
  }

  body.reference-workstation :is(.scale-related-chords, .training-plan-list) {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  }
}

@media (min-width: 761px) and (max-width: 900px) {
  body.reference-workstation .scale-controls,
  body.reference-workstation .scale-detail-grid,
  body.reference-workstation .training-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  body.reference-workstation .scale-detail-grid > :last-child {
    grid-column: auto;
  }

  body.reference-workstation .training-mode-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  body.reference-workstation *,
  body.reference-workstation *::before,
  body.reference-workstation *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
