/*
 * Mobile production reflow
 * ------------------------
 * This file is loaded after the frozen desktop styles. Rules are intentionally
 * limited to viewports below 1024px so the existing desktop workstation keeps
 * its current geometry and visual treatment.
 */

:root {
  --mobile-page-gutter: 16px;
  --mobile-section-gap: 12px;
  --mobile-control-height: 44px;
  --mobile-header-height: 64px;
}

.mobile-nav-toggle,
.mobile-nav-backdrop {
  display: none;
}

@media (max-width: 1023px) {
  html {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    scroll-padding-top: calc(var(--mobile-header-height) + env(safe-area-inset-top));
  }

  body {
    width: 100%;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  body.reference-workstation {
    min-width: 0;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow-x: clip;
    overflow-y: auto;
    overscroll-behavior-x: none;
  }

  body.reference-workstation.mobile-nav-open {
    position: fixed;
    inset-inline: 0;
    top: var(--mobile-scroll-lock-top, 0);
    width: 100%;
  }

  body.reference-workstation .ambient {
    max-width: 100vw;
  }

  body.reference-workstation .app-shell,
  body.reference-workstation.instrument-expanded .app-shell,
  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .app-shell {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 100dvh;
    padding: 0;
    overflow: visible;
  }

  /* Compact application header and accessible navigation drawer. */
  body.reference-workstation .sidebar,
  body.reference-workstation.instrument-expanded .sidebar,
  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .sidebar {
    position: sticky;
    inset: 0 0 auto;
    z-index: 110;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: var(--mobile-header-height);
    width: 100%;
    height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
    min-width: 0;
    min-height: 0;
    padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
    border-width: 0 0 1px;
    border-radius: 0;
    overflow: visible;
    background: var(--studio-bg, #0b0c10);
  }

  body.reference-workstation .brand {
    position: static;
    grid-column: 1;
    grid-row: 1;
    display: flex;
    justify-content: flex-start;
    width: auto;
    height: var(--mobile-header-height);
    min-width: 0;
    padding: 8px 4px;
    border: 0;
  }

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

  body.reference-workstation .brand > div:last-child {
    display: block !important;
    min-width: 0;
  }

  body.reference-workstation .brand h1,
  body.reference-workstation .brand p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.reference-workstation .brand h1 {
    font-size: 17px;
  }

  body.reference-workstation .mobile-nav-toggle {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    display: inline-flex;
    min-width: 64px;
    min-height: var(--mobile-control-height);
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    border: 1px solid var(--studio-line);
    border-radius: 8px;
    color: var(--studio-text);
    background: var(--studio-surface-2);
  }

  body.reference-workstation .mobile-nav-toggle .bi {
    font-size: 21px;
  }

  body.reference-workstation .app-tabs {
    position: fixed;
    z-index: 100;
    top: calc(var(--mobile-header-height) + env(safe-area-inset-top) + 8px);
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 8px;
    width: auto;
    height: auto;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--studio-line);
    border-radius: 12px;
    background: var(--studio-bg-elevated, #111318);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.reference-workstation.mobile-nav-open .app-tabs {
    display: grid;
  }

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

  body.reference-workstation .app-tabs .nav-divider {
    display: none;
  }

  body.reference-workstation .app-tabs .app-tab,
  body.reference-workstation .app-tabs .nav-tab,
  body.reference-workstation .app-tabs .nav-settings {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 52px;
    align-items: center;
    justify-content: flex-start;
    flex-direction: row;
    gap: 10px;
    padding: 0 12px;
  }

  body.reference-workstation .app-tabs .app-tab span,
  body.reference-workstation .app-tabs .nav-tab span {
    font-size: 13px;
    text-align: left;
  }

  body.reference-workstation .mobile-nav-backdrop {
    position: fixed;
    z-index: 90;
    inset: calc(var(--mobile-header-height) + env(safe-area-inset-top)) 0 0;
    width: 100%;
    height: auto;
    border: 0;
    background: rgba(0, 0, 0, 0.64);
    backdrop-filter: blur(4px);
  }

  body.reference-workstation.mobile-nav-open .mobile-nav-backdrop {
    display: block;
  }

  /* One document scroller on phones and tablets. */
  body.reference-workstation .workspace,
  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .workspace,
  body.reference-workstation.training-active .workspace {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    gap: var(--mobile-section-gap);
    width: 100%;
    height: auto;
    min-width: 0;
    min-height: 0;
    padding: var(--mobile-section-gap) var(--mobile-page-gutter);
    overflow: visible;
    scrollbar-gutter: auto;
  }

  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .workspace {
    display: block;
  }

  body.reference-workstation :is(.topbar, .detail-strip, .instrument-panel, .progression) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  body.reference-workstation .topbar {
    height: auto;
    min-height: 72px;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
  }

  body.reference-workstation .chord-title,
  body.reference-workstation .chord-title > div,
  body.reference-workstation .top-actions {
    min-width: 0;
  }

  body.reference-workstation .chord-title h2 {
    font-size: clamp(28px, 9vw, 36px);
  }

  body.reference-workstation .top-actions {
    margin-left: auto;
  }

  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 {
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: minmax(132px, 0.55fr) minmax(180px, 1fr) auto auto;
    width: 100%;
    gap: 8px;
  }

  body.reference-workstation .top-actions :is(.select-pill, .global-search) {
    display: flex;
    width: 100%;
    min-width: 0;
  }

  body.reference-workstation .top-actions .global-search input {
    width: 100%;
    min-width: 0;
  }

  body.reference-workstation .detail-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
    min-height: 0;
    padding: 10px;
    overflow: visible;
  }

  body.reference-workstation .detail-strip > div {
    display: block;
    min-width: 0;
    padding: 6px 8px;
  }

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

  body.reference-workstation :is(.note-row, .degree-row) {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  body.reference-workstation .instrument-panel {
    display: grid;
    grid-template-rows: auto auto auto minmax(360px, auto);
    min-height: 0;
    overflow: hidden;
  }

  body.reference-workstation .instrument-panel > .panel-title {
    height: auto;
    min-height: 56px;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
  }

  body.reference-workstation .instrument-tabs {
    flex: 1 1 auto;
    min-width: 0;
  }

  body.reference-workstation .instrument-tabs .instrument-tab {
    min-width: 56px;
    min-height: var(--mobile-control-height);
    padding-inline: 9px;
  }

  body.reference-workstation .instrument-quick-controls {
    margin-left: auto;
    flex-wrap: wrap;
    gap: 8px;
  }

  body.reference-workstation .instrument-label {
    display: none;
  }

  body.reference-workstation .quick-volume {
    display: flex;
    min-width: min(220px, 100%);
    flex: 1 1 180px;
  }

  body.reference-workstation #quickReplay {
    display: inline-flex;
  }

  body.reference-workstation .instrument-tools {
    grid-template-columns: minmax(0, 1fr);
    width: auto;
    max-height: min(42dvh, 320px);
    margin: 8px;
    overflow-y: auto;
  }

  body.reference-workstation .instrument-view {
    width: 100%;
    min-width: 0;
    min-height: 360px;
    height: clamp(360px, 58dvh, 520px);
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    touch-action: pan-x pinch-zoom;
    -webkit-overflow-scrolling: touch;
  }

  body.reference-workstation .instrument-view > .piano,
  body.reference-workstation .scale-instrument-view > .piano {
    width: 100%;
    min-width: 560px;
  }

  body.reference-workstation .instrument-view > .fretboard {
    position: relative;
    inset: auto;
    width: 720px;
    min-width: 720px;
    height: 300px;
    margin: 20px 12px;
  }

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

  body.reference-workstation .arpeggio-panel {
    grid-template-columns: minmax(0, 1fr);
    width: auto;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  body.reference-workstation .arpeggio-sequence {
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  body.reference-workstation .arpeggio-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
  }

  body.reference-workstation .arpeggio-actions button {
    width: 100%;
  }

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

  body.reference-workstation .progression > .panel-title {
    padding-inline: 10px;
  }

  body.reference-workstation .progression .mini-actions {
    padding-inline: 6px;
  }

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

  body.reference-workstation .progression-chips {
    grid-template-columns: repeat(8, minmax(104px, 1fr));
    overscroll-behavior-inline: contain;
    touch-action: pan-x pinch-zoom;
  }

  /* Bottom transport stays reachable and accounts for phone safe areas. */
  body.reference-workstation .transport {
    position: static;
    z-index: 50;
    display: flex;
    width: 100%;
    height: auto;
    min-height: calc(76px + env(safe-area-inset-bottom));
    margin: 0;
    padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    border-radius: 0;
  }

  body.reference-workstation .transport-body {
    min-width: 0;
    justify-content: center;
    gap: 10px;
  }

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

  body.reference-workstation .big-play,
  body.reference-workstation .transport-icon {
    min-width: var(--mobile-control-height);
    min-height: var(--mobile-control-height);
  }

  /* Alternate tools reflow; only their instrument canvases scroll sideways. */
  body.reference-workstation :is(.fret-memory-page, .scale-page, .training-page) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    gap: var(--mobile-section-gap);
    padding: var(--mobile-page-gutter);
    border-radius: 10px;
    overflow: visible;
  }

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

  body.reference-workstation :is(.fret-memory-header, .scale-header, .training-header) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    width: 100%;
    min-width: 0;
  }

  body.reference-workstation :is(.fret-memory-header, .scale-header, .training-header) > div:first-child {
    min-width: 0;
  }

  body.reference-workstation :is(.fret-memory-header, .scale-header, .training-header) h2 {
    margin-block: 2px 6px;
    font-size: clamp(30px, 9vw, 38px);
    line-height: 1.08;
    word-break: keep-all;
  }

  body.reference-workstation :is(.fret-memory-stats, .scale-summary, .training-summary) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 118px), 1fr));
    width: 100%;
    min-width: 0;
    gap: 8px;
  }

  body.reference-workstation :is(.fret-memory-controls, .scale-controls, .training-controls) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    width: 100%;
    min-width: 0;
    gap: 10px;
    padding: 12px;
  }

  body.reference-workstation :is(.fret-memory-controls, .scale-controls, .training-controls) .control-block.wide {
    grid-column: auto;
  }

  body.reference-workstation :is(.segmented, .training-instrument-options) {
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  body.reference-workstation .fret-note-picker {
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  }

  body.reference-workstation .fret-memory-board,
  body.reference-workstation .scale-instrument-view,
  body.reference-workstation .training-fretboard-wrap,
  #trainingPage .lesson-program {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    touch-action: pan-x pinch-zoom;
    -webkit-overflow-scrolling: touch;
  }

  body.reference-workstation .fret-memory-board {
    padding-bottom: 10px;
  }

  body.reference-workstation .fret-memory-board > .memory-fretboard {
    width: 640px;
    min-width: 640px;
  }

  body.reference-workstation .scale-root-grid {
    grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  }

  body.reference-workstation .scale-type-grid {
    grid-template-columns: minmax(0, 1fr);
    max-height: min(42dvh, 320px);
  }

  body.reference-workstation .scale-detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  }

  body.reference-workstation .scale-meta-list {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  }

  body.reference-workstation .scale-related-chords,
  body.reference-workstation .training-plan-list,
  body.reference-workstation .training-mode-list,
  body.reference-workstation .training-records-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 148px), 1fr));
  }

  body.reference-workstation :is(.scale-related-card, .scale-instrument-card, .training-plan, .training-question-card, .training-record-card) {
    min-width: 0;
    padding: 12px;
  }

  body.reference-workstation :is(.scale-related-card, .scale-instrument-card, .training-question-card) > .panel-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 10px;
  }

  body.reference-workstation .scale-instrument-card {
    min-height: 0;
  }

  body.reference-workstation .scale-instrument-view {
    min-height: 280px;
  }

  body.reference-workstation .scale-instrument-view .fretboard {
    min-width: 720px;
  }

  body.reference-workstation #trainingPage .learn-mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    overflow: visible;
  }

  body.reference-workstation #trainingPage .learn-mode-tab {
    min-width: 0;
    min-height: var(--mobile-control-height);
    padding-inline: 6px;
    white-space: normal;
  }

  body.reference-workstation #trainingPage .learn-layout,
  body.reference-workstation #trainingPage .review-layout,
  body.reference-workstation #trainingPage .learn-goals,
  body.reference-workstation #trainingPage .learn-options,
  body.reference-workstation #trainingPage .lesson-instrument-grid,
  body.reference-workstation #trainingPage .lesson-triad-grid,
  body.reference-workstation .progression-analysis-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  body.reference-workstation #trainingPage .learn-catalog {
    position: static;
    max-height: none;
    padding: 0;
    overflow: visible;
  }

  body.reference-workstation #trainingPage .learn-catalog-body {
    max-height: min(52dvh, 460px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.reference-workstation .progression-setting-grid,
  body.reference-workstation .training-note-grid,
  body.reference-workstation .training-choice-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 132px), 1fr));
  }

  body.reference-workstation :is(.training-question-card, .training-actions, .training-instrument-options) {
    min-width: 0;
    max-width: 100%;
  }

  body.reference-workstation .training-actions {
    align-items: stretch;
    flex-wrap: wrap;
  }

  body.reference-workstation .training-actions > button {
    flex: 1 1 132px;
  }

  body.reference-workstation .training-actions > span {
    flex: 1 0 100%;
  }

  body.reference-workstation #trainingPage :is(.lesson-keyboard, .lesson-fretboard, .lesson-diatonic) {
    max-width: none;
  }

  /* Mobile side drawer for custom chords, MIDI and export. */
  body.reference-workstation .right-rail {
    position: fixed;
    z-index: 75;
    top: auto;
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    display: block;
    width: auto;
    max-width: none;
    height: auto;
    max-height: min(74dvh, calc(100dvh - var(--mobile-header-height) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    padding: 0;
    border-radius: 14px 14px 8px 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.reference-workstation.right-rail-collapsed .right-rail,
  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .right-rail {
    display: none;
  }

  body.reference-workstation .right-rail-toggle {
    position: fixed;
    z-index: 74;
    top: auto;
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: var(--mobile-control-height);
    height: var(--mobile-control-height);
    min-height: var(--mobile-control-height);
    padding: 0;
    border-radius: 50%;
    transform: none;
  }

  body.reference-workstation .right-rail-toggle span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  body.reference-workstation:is(.fret-memory-active, .scale-active, .training-active) .right-rail-toggle {
    display: none;
  }

  body.reference-workstation .right-rail .rail-tabs {
    position: sticky;
    z-index: 2;
    top: 0;
    padding-block: 8px;
    background: var(--studio-surface);
  }

  /* Dialogs fit the dynamic viewport and keep close/actions reachable. */
  body.reference-workstation .chord-picker-overlay,
  body.reference-workstation .account-overlay {
    z-index: 200;
    align-items: end;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  body.reference-workstation .chord-picker-dialog,
  body.reference-workstation .account-dialog {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    max-height: calc(100dvh - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
    border-radius: 14px 14px 8px 8px;
    overscroll-behavior: contain;
  }

  body.reference-workstation .chord-picker-header,
  body.reference-workstation .account-dialog > header {
    position: sticky;
    z-index: 4;
    top: 0;
    padding: 14px;
    background: var(--account-surface, #111318);
  }

  body.reference-workstation .chord-picker-list {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 138px), 1fr));
    padding: 12px;
  }

  body.reference-workstation .account-dialog-body {
    padding: 14px;
  }

  body.reference-workstation .account-auth-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  body.reference-workstation :is(input, select, textarea) {
    max-width: 100%;
    min-height: var(--mobile-control-height);
    font-size: 16px;
  }

  body.reference-workstation :is(
    button,
    .primary-btn,
    .secondary-btn,
    .ghost-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,
    .transport-btn
  ) {
    min-height: var(--mobile-control-height);
    touch-action: manipulation;
  }

  body.reference-workstation :is(.fret, .memory-fret, .training-fret, .white-key, .black-key) {
    touch-action: manipulation;
  }

  /* Admin and legal pages share the same phone-safe container rules. */
  body.admin-page {
    min-width: 0;
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  }

  .admin-shell,
  .legal-shell {
    width: min(calc(100% - 24px), 1240px);
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(48px, env(safe-area-inset-bottom));
  }

  .admin-topbar,
  .legal-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-summary {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 136px), 1fr));
  }

  .admin-grid,
  .admin-form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-search {
    flex-wrap: wrap;
  }

  .admin-search input {
    flex: 1 1 180px;
  }

  .admin-page :is(button, a.ghost-btn, input, select) {
    min-height: var(--mobile-control-height);
  }

  .legal-head,
  .legal-card {
    padding: 18px;
  }
}

@media (max-width: 479px) {
  :root {
    --mobile-page-gutter: 10px;
    --mobile-section-gap: 10px;
  }

  body.reference-workstation .app-tabs {
    grid-template-columns: minmax(0, 1fr);
  }

  body.reference-workstation .top-actions {
    grid-template-columns: minmax(0, 1fr) var(--mobile-control-height) var(--mobile-control-height);
  }

  body.reference-workstation .top-actions .select-pill {
    grid-column: 1;
    grid-row: 1;
  }

  body.reference-workstation .top-actions .global-search {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  body.reference-workstation .top-actions #themeToggle {
    grid-column: 2;
    grid-row: 1;
  }

  body.reference-workstation .top-actions #helpToggle {
    grid-column: 3;
    grid-row: 1;
  }

  body.reference-workstation .brand p {
    display: none;
  }

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

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

  body.reference-workstation .instrument-tabs {
    order: 1;
    flex: 1 1 100%;
  }

  body.reference-workstation .instrument-tabs .instrument-tab {
    flex: 1 1 0;
  }

  body.reference-workstation .instrument-quick-controls {
    order: 2;
    width: 100%;
    justify-content: space-between;
  }

  body.reference-workstation .quick-volume {
    flex-basis: 100%;
  }

  body.reference-workstation :is(#quickPlayCurrent, #quickReplay) {
    flex: 1 1 112px;
  }

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

  body.reference-workstation .progression-body {
    grid-column: 1 / -1;
  }

  body.reference-workstation .progression .mini-actions {
    grid-column: 2;
    grid-row: 1;
  }

  body.reference-workstation :is(.fret-memory-page, .scale-page, .training-page) {
    padding: 12px;
  }

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

  body.reference-workstation #trainingPage .learn-mode-tab {
    font-size: 12px;
  }

  body.reference-workstation .scale-note-pill {
    min-width: 44px;
  }

  .admin-shell,
  .legal-shell {
    width: min(calc(100% - 16px), 1240px);
  }

  .admin-card,
  .admin-topbar,
  .legal-head,
  .legal-card {
    padding: 14px;
  }
}

@media (max-width: 359px) {
  :root {
    --mobile-page-gutter: 8px;
    --mobile-section-gap: 8px;
  }

  body.reference-workstation .brand {
    gap: 8px;
  }

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

  body.reference-workstation .brand h1 {
    font-size: 15px;
  }

  body.reference-workstation .mobile-nav-toggle {
    min-width: 58px;
    padding-inline: 8px;
  }

  body.reference-workstation :is(.fret-memory-header, .scale-header, .training-header) h2 {
    font-size: 28px;
  }

  body.reference-workstation .account-dialog h2 {
    font-size: 1.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.reference-workstation .app-tabs,
  body.reference-workstation .mobile-nav-backdrop,
  body.reference-workstation .right-rail {
    scroll-behavior: auto;
  }
}
