/* Edition frontispiece and reading desk */
:root {
  --desk: #102523;
  --panel: #1b302d;
  --edge: #3e514a;
  --paper: #f4ead4;
  --muted: #bec9bd;
  --gold: #ecc27f;
  --ui: "Inter", "Segoe UI", system-ui, sans-serif;
}
.welcome-screen {
  overflow: auto;
  place-items: safe center;
  background: #eae5d8;
  background-image: repeating-linear-gradient(0deg, transparent 0 5px, #6b5e4510 6px);
}
.welcome-card {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr);
  width: min(1040px, 96%);
  padding: 0;
  overflow: hidden;
  border: 1px solid #9c998a;
  border-radius: 5px;
  background: #f8f5eb;
  color: #18352f;
  text-align: start;
  box-shadow: 0 18px 48px #37342528;
  backdrop-filter: none;
}
.edition-intro { grid-area: 1 / 1; padding: clamp(26px, 4vw, 60px); }
.edition-plate {
  grid-area: 1 / 2;
  display: grid;
  place-items: center;
  border: 13px solid #183c35;
  outline: 1px solid #b79f64;
  outline-offset: -19px;
  background-color: #21463e;
  background-image: linear-gradient(#bdbd9210 1px, transparent 1px), linear-gradient(90deg,#bdbd9210 1px, transparent 1px);
  background-size: 20px 20px;
}
.edition-plate svg { width: 95%; fill: #efc888; direction: ltr; }
.edition-plate .rule { fill: none; stroke: #88a69a; stroke-width: .7; stroke-dasharray: 2 4; }
.edition-plate .string { stroke: #ebcd93; }
.edition-plate .vibration { stroke: #e0b677; fill: #bbc69c13; }
.edition-plate text { font: 13px var(--mono); fill: #f9e2b8; }
.welcome-brandline, .welcome-actions, .welcome-links { justify-content: flex-start; }
.welcome-brandline { flex-direction: row; color: #4c625a; font: 650 11px/1.5 var(--ui); letter-spacing: .06em; }
.welcome-brandline img { width: 34px; height: 34px; border-radius: 6px; box-shadow: none; }
.welcome-eyebrow { margin: 48px 0 12px; color: #805525; font: 600 12px/1.4 var(--ui); letter-spacing: .07em; }
.welcome-card h1 { color: #183b33; font: 500 clamp(42px, 5.5vw, 78px)/1.02 var(--body); letter-spacing: -.045em; }
.welcome-card h1::after { display: none; }
.welcome-card > p#welcomeLead, .edition-intro #welcomeLead { color: #43584f; margin: 16px 0 28px; font: 400 17px/1.55 var(--ui); }
.welcome-actions button { font: 650 14px/1.25 var(--ui); border-radius: 5px; box-shadow: none; }
.welcome-primary { color: #fff8e7; background: #20493d; border-color: #20493d; }
.welcome-secondary { color: #254438; background: transparent; border-color: #85968b; }
.welcome-links { flex-wrap: wrap; gap: 8px 20px; align-items: flex-start; }
.welcome-links button { color: #4e6259; font: 500 12px/1.4 var(--ui); padding: 4px 0; }
.welcome-actions button:hover { filter: brightness(.94); }
.welcome-card button:focus-visible { outline: 3px solid #9c641f; outline-offset: 3px; }
#app { background: var(--desk); }
.topbar, .tabs, .mobile-nav { background: #142825; }
.brand-mark, .card, .theory-hud, body.view-theory .theory-hud {
  border-color: var(--edge); background: var(--panel); box-shadow: none;
}
.mono-panel, body.view-theory .mono-panel { background: linear-gradient(170deg,#142d2b,#0d201e); }
.mono-panel::before { border-color: #77988647; box-shadow: none; }
.view-state-label, .stage-legend span { background: #122622; color: var(--muted); }
.card-head { background: #243a34; border-bottom-color: var(--edge); }
.card-title, .lesson-title { color: var(--paper); }
.card-kicker, .hud-metric span { color: var(--muted); }
.hud-metric b { font-variant-numeric: tabular-nums; color: var(--paper); }
.tab, .btn, .icon-btn, .view-choice, .language-select { font-family: var(--ui); letter-spacing: .01em; }
.tab.active { color: var(--gold); background: #2c4037; box-shadow: inset 0 -3px var(--gold); }
.lesson-btn, .step-tile, .species-btn, .quiz-option { background: #20332f; border-color: var(--edge); }
.lesson-btn.active, .species-btn.active, .step-tile.current { background: #344338; border-color: #b79c6c; border-inline-start: 3px solid var(--gold); }
.card .btn.primary { background: #edcc90; color: #21352b; border-color: #edcc90; }
.view-choice.active { background: #445a4e; color: #fff3d6; }
.fret:focus-visible .dot { stroke: white; stroke-width: 3; }
@media (max-width: 640px) {
  .welcome-card { grid-template-columns: 1fr; width: min(460px,100%); }
  .edition-plate { grid-area: 1 / 1; height: 142px; border-width: 6px; outline-offset: -10px; }
  .edition-plate svg { width: 160px; height: 140px; }
  .edition-intro { grid-area: 2 / 1; padding: 22px; }
  .welcome-eyebrow { margin-top: 20px; }
  .welcome-actions { display: flex; }
  .welcome-actions button { width: auto; flex: 1 1 120px; padding: 8px; }
  .welcome-links { flex-direction: row; }
}
@media (max-height: 520px) and (min-width: 641px) {
  .edition-intro { padding: 18px 26px; }
  .welcome-eyebrow { margin-top: 14px; }
  .welcome-card h1 { font-size: 40px; }
  .edition-intro #welcomeLead { margin: 9px 0 15px; font-size: 15px; }
  .edition-plate svg { max-height: 280px; }
}
/* Keep the opening actions above the pinned phone navigation. */
.welcome-screen { z-index: 11000; }
body.welcome-visible #viewport, body.welcome-visible .mobile-nav { visibility: hidden; }
@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .mobile-nav button b { font: 600 10px/1.12 var(--ui) !important; }
  .mobile-nav button.active { box-shadow: inset 0 2px var(--gold); }
}

/* Keep both scales on the same horizontal axis. Give the soundboard its full height. */
.instrument-wrap, body.view-practical .instrument-wrap, body.stage-focus .instrument-wrap {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}
.instrument-wrap #instrumentSvg, body.view-practical #instrumentSvg,
body.stage-focus #instrumentSvg, body.stage-focus.view-practical #instrumentSvg {
  width: 100%;
  height: auto;
  overflow: visible;
}
#instrumentOverlayLayer > :not(.instrument-hotzone) { pointer-events: none; }
.instrument-fretline { stroke: #b9d2c4; opacity: .35; stroke-dasharray: 2 3; }
.instrument-guide { stroke: #c6d6be; opacity: .45; }
.instrument-focus-line { stroke-width: 1.4; }
.instrument-focus-label { font-size: 14px; }
.instrument-note { max-width: 60%; }
@media (min-width: 1101px) {
  body:not(.stage-focus) #app { height: 856px; grid-template-rows: 72px 386px 44px 354px 0; }
  body:not(.stage-focus):not(.view-theory):not(.view-practical) .mono-panel {
    grid-template-rows: 16px 116px 1fr;
  }
  body:not(.stage-focus):not(.view-theory):not(.view-practical) #monoSvg { height: 116px; }
  body.view-theory:not(.stage-focus) #monoSvg { height: 330px; }
  body.view-practical:not(.stage-focus) .instrument-wrap,
  body.stage-focus .instrument-wrap { align-self: center; }
}
@media (max-width: 1100px) and (min-width: 701px) {
  #monoSvg { width: 100%; }
}
@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  body:not(.view-theory) .instrument-wrap { display: block !important; }
  body:not(.view-theory) #monoSvg { height: auto !important; }
  .instrument-note { font-size: 7px; bottom: 0; }
}

/* Reading and comparing values across the six learning panels. */
.lesson-content, .builder-body, .modal-body, .table-wrap, .step-grid, .quiz-body {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #647b6d transparent;
}
.lesson-copy, .step-copy, .pattern-copy, .caution-box {
  line-height: 1.48;
  color: #d5d9c9;
}
.data-card th { position: sticky; top: 0; background: #253b34; z-index: 1; }
.data-card tbody tr:nth-child(even):not(.selected-row) { background: #ffffff05; }
.data-card tbody tr:hover { background: #344a40; }
.data-card td, .formula-box, .guide-summary, .tone-box { font-variant-numeric: tabular-nums; }
#comparisonRatio, #comparisonCents, #lengthRatio, #frequencyRatio, #guideLength,
#guideFrequency, #guideCents, #speciesResult, .data-card td { unicode-bidi: isolate; }
#comparisonCents, #comparisonRatio { direction: ltr; display: inline-block; }
.interval-limma.current { fill: #9ee4cb; stroke: #e3f5e9; }
.interval-comma.current { fill: #f4a997; stroke: #ffe9d4; }
.fret:focus-visible .label { text-decoration: underline; }
#playSpecies:disabled { opacity: .48; cursor: default; }
.dialog-section a { text-underline-offset: 3px; }
.pitch-table-note {
  font: inherit;
  color: var(--paper);
  background: transparent;
  border: 0;
  padding: 0 5px;
}
.pitch-table-note:hover, .pitch-table-note:focus-visible { color: var(--gold); text-decoration: underline; }
.data-card td, .data-card th { font-variant-numeric: tabular-nums; }
@media (min-width: 1101px) {
  .workspace { padding-top: 16px; }
  .workspace-context { top: 3px; color: #b3c1b3; font-size: 8px; }
}

/* Center the scaled desk in the actual browser viewport, including short windows. */
@media (min-width: 1101px) {
  #viewport { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
}
.lesson-main { grid-template-rows: auto auto minmax(0, 1fr); }
.lesson-actions { border-top: 0; border-bottom: 1px solid var(--line-soft); }
.lesson-actions .btn { min-height: 36px; height: auto; cursor: pointer; }
.lesson-actions .btn:disabled { cursor: default; }
@media (max-width: 1100px) {
  .panel { scroll-margin-top: 80px; }
  .learn-grid > .lesson-main { order: -1; }
  .lesson-actions .btn { min-height: 44px; }
  .welcome-screen { overflow-y: auto; align-items: safe center; }
}

.creator-line { font: 600 11px/1.35 var(--ui); color: var(--muted); }
.creator-line a,.creator-line button { color: inherit; text-underline-offset: 2px; }
.creator-line button { background: none; border: 0; padding: 0 2px; font: inherit; cursor: pointer; text-decoration: underline; }
.pitch-controls,#rotateHint { display: none; }
@media (max-width:700px), (pointer:coarse) and (max-height:600px) {
  .mono-panel { display: flex !important; flex-direction: column; gap: 8px; }
  .mono-panel .instrument-wrap { order: -4; display: block !important; width: 100%; overflow-x: auto; direction: ltr; }
  .instrument-wrap #instrumentSvg { display: block; width: 100% !important; height: auto !important; min-width: 0; }
  body.fret-zoom .instrument-wrap #instrumentSvg { min-width: 1040px; }
  .mono-panel .instrument-note { position: static; display: block; max-width: none; text-align: center; font-size: 10px; }
  .pitch-controls { order: -3; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; color: #f5e8c7; font: 600 13px/1.35 var(--ui); }
  .pitch-controls select,.pitch-controls button { border-radius: 6px; border: 1px solid #718779; padding: 6px 10px; min-height: 44px; background: #223e37; color: #f6eddb; font: inherit; }
  .pitch-controls select { max-width: 145px; margin-inline-start: 4px; }
  .pitch-controls #mobilePitchPlay { background: #eac58a; color: #15332c; }
  .pitch-controls #mobileInstrumentToggle { display: inline-block !important; width: auto; }
  .mono-panel::before { pointer-events: none; }
  .creator-line { font-size: 11px; }
  .brand-copy { min-width: 0; }
  .mobile-nav button { border: 1px solid #577264 !important; }
  .mobile-nav button.active { background: #3d5545 !important; color: #ffdfa2 !important; }
  .mobile-nav button b { white-space: normal; overflow: visible; font: 650 12px/1.15 var(--ui) !important; }
}
@media (max-width:700px) and (orientation:portrait) {
  #rotateHint:not([hidden]) { order: -2; display: flex; align-items: center; justify-content: center; gap: 8px; color: #d5e4d9; font: 12px/1.4 var(--ui); }
  #dismissRotate { min-width: 44px; min-height: 44px; background: transparent; border: 0; color: inherit; font-size: 20px; }
  .mobile-nav { height: auto; grid-template-columns: repeat(3,minmax(0,1fr)); padding: 5px 6px calc(5px + var(--safe-bottom)); }
  .mobile-nav button { display:flex; align-items:center; justify-content:center; min-height:44px; gap:5px; }
  .workspace { padding-bottom: calc(110px + var(--safe-bottom)); }
}
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
  .mono-panel { display:grid !important; grid-template-columns:minmax(0,1fr) minmax(180px,25%); align-items:center; }
  .mono-panel > * { grid-column:1/-1; }
  .mono-panel .instrument-wrap { grid-column:1; grid-row:1; }
  .pitch-controls { grid-column:2; grid-row:1; }
  .pitch-controls label,.pitch-controls output { width:100%; text-align:center; }
  .mobile-nav { z-index:8000 !important; }
}
@media (prefers-color-scheme:dark) {
  :root { color-scheme:dark; }
  .welcome-screen { background:#102523; }
  .welcome-card { background:#1b302d; border-color:#50685a; }
  .welcome-card h1,.welcome-brandline,.edition-intro #welcomeLead,.welcome-links button { color:#efe8d5; }
  .welcome-eyebrow { color:#edcb8f; }
  .welcome-secondary { color:#eee4c9; }
}
@media (prefers-color-scheme:light) {
  :root { color-scheme:light; --desk:#f4efdf; --panel:#fffaf0; --edge:#b2b5a4; --paper:#20392f; --muted:#435e52; --gold:#80551c; }
  html,body,#viewport { background:#e5e2d5; }
  #app,.workspace { background:var(--desk); }
  .topbar,.tabs,.card-head { background:#e4e6d8; }
  .title-ar,.title-en,.creator-line,.tab,.tab.active,.card-kicker,.workspace-context,.family-link { color:#234637; }
  .topbar .subtitle,.topbar .eyebrow,.brand-facts span { color:#4a6052; }
  .tab.active { background:#cfdac9; }
  .workspace .card { color:#233e33; background:var(--panel); }
  .workspace :is(h2,h3,p,strong,label,small,td,th,.lesson-copy,.lesson-objective,.step-copy,.pattern-copy,.caution-box,.source-row span,.card-title,.lesson-status,.lesson-formula,.concept-copy) { color:#294535; }
  .workspace :is(.lesson-btn,.step-tile,.species-btn,.quiz-option,.source-row,.formula-box,.tone-box,.data-card th,.lesson-formula) { background:#ececdd; color:#254736; }
  .workspace :is(.lesson-btn.active,.species-btn.active,.step-tile.current,.selected-row,.data-card tbody tr:hover) { background:#d3dfc9; }
  .workspace :is(.btn,select,input,.pitch-table-note) { color:#203d31; background-color:#e2e8da; }
  .workspace .btn { background-image:none; border-color:#91a28f; }
  .workspace .btn.primary { background:#265642; color:white; }
  .workspace .lesson-btn *,.workspace .step-tile *,.workspace .species-btn * { color:inherit; }
  .mono-panel,.dialog-backdrop,.app-sheet,.mobile-nav { --paper:#f4ead4; --panel:#1b302d; --muted:#bec9bd; --gold:#ecc27f; color-scheme:dark; }
}
@media (prefers-color-scheme:light) {
  .workspace {
    --parchment:#203d31; --parchment-dim:#495d51; --teal:#246657;
    --brass-bright:#75501b; --brass:#845c23; --atlas-gold:#77531d;
    --atlas-teal:#286353; --line:#a3ae9d; --line-soft:#c8cdbc;
  }
  .workspace .interval-badge.comma,.workspace .quiz-option.wrong { color:#913e3b; }
  .workspace .quiz-option.correct { color:#215b41; }
  .workspace .field select,.workspace .field input,.workspace .audio-mini select { background:#fffaf0; color:#203d31; }
}

/* A scrolling reading desk: all type is measured in CSS pixels at normal zoom. */
@font-face {
  font-family: Vazirmatn;
  src: url("../assets/fonts/vazirmatn-arabic-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}
body { --reading-font: system-ui, sans-serif; }
body.rtl-ui { --reading-font: Vazirmatn, Tahoma, sans-serif; --ui:var(--reading-font); }
html,body { height:auto; min-height:100%; overflow-x:clip; overflow-y:visible; }
#viewport { position:relative; display:block; overflow:visible; }
body #app,body:not(.stage-focus) #app {
  width:min(100%, 94rem); height:auto; margin:auto; overflow:visible;
  display:flex; flex-direction:column;
}
.topbar { height:auto; padding-block:12px; }
.brand-facts,.brand-meta,.tab-number,.workspace-context,.view-state-label { display:none; }
.creator-line { margin-top:4px; font:500 14px/1.55 var(--reading-font); }
.header-actions :is(.icon-btn,.view-choice,.language-select),.tab {
  font:600 14px/1.4 var(--reading-font); min-height:44px;
}
#viewport .workspace { padding:16px clamp(10px,2vw,28px) 28px; overflow:visible; }
.workspace .panel,.panel > :is(.learn-grid,.explore-grid,.listen-grid,.construct-grid,.modes-grid,.train-grid) { height:auto; min-height:0; align-items:start; }
.workspace .card { display:flex; flex-direction:column; height:auto; min-width:0; }
.workspace .card-head { height:auto; min-height:46px; gap:8px; flex-wrap:wrap; padding:8px 14px; }
.workspace .card-title,.workspace .builder-title { font:650 19px/1.55 var(--reading-font); }
.workspace :is(.card-kicker,.lesson-status,.data-key,.summary-k,.lesson-num,.micro,.field label,.step-code,.quiz-mode,.source-row span) {
  font:500 14px/1.6 var(--reading-font); letter-spacing:normal;
}
.workspace :is(.lesson-btn,.btn,.step-tile,.species-btn,.quiz-option,select,input,th,td,.source-row strong,.data-val,.summary-v,.feedback,.note-sub,.interval-text,.tone-latin,.tone-cents) {
  font:550 15px/1.55 var(--reading-font); letter-spacing:normal;
}
.workspace :is(.btn,.lesson-btn,.quiz-option,.species-btn,.field select) { min-height:44px; height:auto; white-space:normal; }
.workspace :is(.lesson-content,.builder-body,.step-main,.quiz-body) { overflow:visible; height:auto; padding:16px; }
.workspace :is(.lesson-copy,.step-copy,.lesson-objective,.concept-copy p,.pattern-copy,.quiz-question,.caution-box,.modal-body p) {
  font:400 17px/1.75 var(--reading-font); max-width:70ch;
}
.workspace .lesson-title { font:700 clamp(24px,2vw,34px)/1.5 var(--reading-font); margin:0 0 8px; }
.workspace .lesson-formula { font-size:18px; direction:ltr; text-align:center; }
.workspace .lesson-actions { padding:10px 14px; }
.workspace .learn-grid { grid-template-columns:minmax(210px,1fr) minmax(0,2.5fr); }
.workspace .learn-grid > .source-card { grid-column:2; }
.workspace .table-wrap { max-height:32rem; overflow:auto; }
#theoryToggle { display:none; }
body.view-practical .mono-panel .mono-scroll-shell,body.view-practical .mono-caption,body.view-theory .mono-panel .instrument-wrap { display:none!important; }
body.view-practical .mono-panel .theory-hud { opacity:1; transform:none; }
.instrument-note { font:500 12px/1.5 var(--reading-font); color:#e7e7d9; }
@media(min-width:1101px) {
  .tabs { min-height:52px; }
  body:not(.stage-focus) .mono-panel { display:flex; flex-direction:column; padding:12px 20px; }
  body:not(.stage-focus) .instrument-wrap { width:min(100%,72rem); align-self:center; }
  body:not(.stage-focus) .mono-panel .theory-hud { position:static; display:flex; align-items:center; justify-content:center; gap:18px; width:fit-content; max-width:100%; margin:auto; padding:6px 14px; }
  .theory-hud .hud-metric span,.theory-hud .hud-primary small,.mono-caption { font:500 12px/1.4 var(--reading-font); }
  .theory-hud .hud-metric b,.theory-hud .hud-primary b { font-size:15px; }
  .hud-model { display:none; }
}
@media(max-width:1100px) {
  .workspace .learn-grid { display:flex; flex-direction:column; }
  .workspace .learn-grid > * { width:100%; }
  .workspace .learn-grid > .lesson-main { order:-1; }
}
@media(max-width:700px), (pointer:coarse) and (max-height:600px) {
  .topbar { position:relative!important; top:auto; padding-block:8px; }
  .creator-line { font-size:12px; }
  .mono-panel .theory-hud,.mono-panel .stage-legend,.mono-panel .mono-caption { display:none; }
  #theoryToggle { display:block; align-self:center; order:-1; color:#f3e7c9; background:#213e36; border:1px solid #83988a; border-radius:7px; padding:8px 16px; min-height:44px; font:600 15px/1.5 var(--reading-font); }
  #theoryToggle::after { content:" ▾"; }
  #theoryToggle[aria-expanded=true]::after { content:" ▴"; }
  body:not(.view-theory) .mono-panel:not(.diagram-open) :is(.mono-scroll-shell,.mobile-stage-tools),body.view-theory #theoryToggle,body.view-practical #theoryToggle { display:none!important; }
  .pitch-controls,.pitch-controls select,.pitch-controls button { font:550 15px/1.5 var(--reading-font); }
  #app .mobile-nav { position:sticky!important; top:0; bottom:auto!important; z-index:70!important; padding:5px!important; }
  #app .mobile-nav button b { font:600 14px/1.4 var(--reading-font)!important; }
  #app .mobile-nav button span { display:none!important; }
  .panel { scroll-margin-top:110px; }
  #app .workspace { padding-bottom:calc(18px + var(--safe-bottom))!important; }
  .workspace .concept-body { grid-template-columns:1fr; }
}
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
  .panel { scroll-margin-top:70px; }
}
@media(prefers-color-scheme:light) {
  .header-actions :is(button,select),.header-actions .view-switch { background:#edf0e6; color:#234435!important; border-color:#819285!important; }
  .header-actions .view-choice.active { background:#294a3c; color:#fff7e8!important; }
  .workspace .card-kicker,.workspace .source-row span { color:#43584d; }
}
@media(min-width:1101px) {
  body:not(.stage-focus) .mono-scroll-shell { width:min(100%,72rem); align-self:center; }
  .mono-scroll-shell #monoSvg { width:100%; }
}

#orientationGate { display:none; }
@media (orientation:portrait) and (pointer:coarse) and (max-width:700px) {
  body > :not(#orientationGate) { display:none!important; }
  #orientationGate { display:grid; font:500 18px/1.65 var(--reading-font); }
  #orientationGate h2 { font:650 25px/1.45 var(--reading-font); }
}
#viewport #app { width:100%; max-width:none; }
.header-actions #viewSwitch { width:auto; display:inline-flex; }
#viewSwitch .view-choice { width:auto; padding-inline:12px; }
body.view-theory #monoPanel #monoSvg { height:auto!important; width:100%!important; min-width:0!important; aspect-ratio:860/182; }
body.view-theory #monoPanel #monoScrollShell { width:min(100%,92rem); height:auto; min-height:0; align-self:center; }
#monoPanel .hud-metric { display:flex; align-items:baseline; gap:.5em; flex-wrap:wrap; }
#monoSvg text { font-family:Vazirmatn,system-ui,sans-serif; }
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
  .header-actions #viewSwitch { display:flex!important; flex-shrink:0; }
  #app .topbar { flex-wrap:wrap; height:auto!important; }
  #viewSwitch .view-choice { padding-inline:8px; }
  #monoPanel #theoryToggle,#monoPanel #mobileStageTools { display:none!important; }
  body:not(.view-theory) #monoPanel #monoScrollShell { display:block!important; grid-column:1; grid-row:1; }
  #monoPanel .instrument-wrap { grid-column:1; grid-row:2; }
  #monoPanel .pitch-controls { grid-column:2; grid-row:1 / span 2; }
  body.view-theory #monoPanel #monoScrollShell { grid-column:1; grid-row:1 / span 2; }
  body.view-theory #mobileInstrumentToggle { display:none!important; }
  #monoPanel { padding-inline:max(8px,env(safe-area-inset-left),env(safe-area-inset-right))!important; }
}
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
  body.view-theory #monoPanel #monoScrollShell { grid-column:1/-1; grid-row:1; }
  body.view-theory #monoPanel .pitch-controls { grid-column:1/-1; grid-row:2; }
  body.view-theory #monoPanel .pitch-controls :is(label,output) { width:auto; }
}

/* Shared control, annotation and measurement styles across the six workspaces. */
.workspace {
  --surface-inset:#223a34; --text-main:#f1eee2; --text-secondary:#c0cec4;
  --rule:#52685b; --limma-ink:#a5e3d4; --limma-bg:#244a40;
  --comma-ink:#ffc1b7; --comma-bg:#533633;
  font-family:var(--reading-font);
}
@media(prefers-color-scheme:light) {
  .workspace {
    --surface-inset:#f0f1e8; --text-main:#213d32; --text-secondary:#465d50;
    --rule:#b1bcac; --limma-ink:#185442; --limma-bg:#dfede4;
    --comma-ink:#823e31; --comma-bg:#f4e4df;
  }
}
#app button,.welcome-screen button,.app-sheet button { font-variant-emoji:text; }
.workspace .card { border:1px solid var(--rule); border-radius:12px; }
.workspace .card-head { min-height:52px; padding:8px 16px; border-bottom:1px solid var(--rule); align-items:center; }
.workspace :is(.card-kicker,.step-count,.interval-badge,.lesson-status,.tile-num,.species-code,.score,.audio-mini label,.range-line label) {
  font:600 13px/1.45 var(--reading-font); letter-spacing:normal; text-transform:none; color:var(--text-secondary);
}
.workspace :is(.step-heading,.note-name,.concept-copy h3) { font:650 20px/1.4 var(--reading-font); color:var(--text-main); }
.workspace :is(.builder-copy,.interval-text,.pattern-copy) { font:400 16px/1.65 var(--reading-font); color:var(--text-main); }
.workspace :is(.formula-box,.step-equation,.species-result,.pattern-equation,.tone-hz,.summary-v,.range-value,.interval-block span) {
  font:600 15px/1.55 var(--reading-font); font-variant-numeric:tabular-nums; color:var(--text-main);
}
.workspace :is(.lesson-actions,.note-audio,.explore-footer,.step-controls,.sound-buttons,.compare-actions,.pattern-actions,.interval-actions,.quiz-footer) { gap:8px; padding:10px 14px; }
.workspace .btn,.workspace .quiz-mode { padding:7px 10px; min-height:44px; border-radius:7px; font:600 15px/1.45 var(--reading-font); }
.workspace .btn:disabled { opacity:.55; }
.workspace :is(.field,.audio-mini) { gap:5px; }
.workspace :is(.field select,.field input,.audio-mini select) { min-height:44px; height:auto; padding:6px 9px; border-radius:6px; min-width:0; }
.workspace .lesson-btn { grid-template-columns:28px 1fr auto; text-align:start; align-items:center; padding:8px 10px; }
.workspace .lesson-btn.completed::after { grid-column:3; grid-row:1; margin:0; }
.workspace :is(.lesson-items,.species-list,.step-grid) { gap:6px; padding:10px; }
.workspace .species-btn { display:flex; align-items:center; justify-content:space-between; gap:12px; text-align:start; padding:8px 12px; }
.workspace .species-code { flex:none; direction:ltr; }
.workspace .guide-visual { padding:140px 16px 14px; }
.workspace .guide-note { position:static; color:var(--text-secondary); font:500 14px/1.5 var(--reading-font); }
.workspace .guide-division { background:var(--rule); }
.workspace .guide-summary,.workspace .summary-box { border-color:var(--rule); }
.workspace .summary-box,.workspace .interval-block { border-radius:6px; background:var(--surface-inset); }
.workspace .step-grid { grid-template-columns:repeat(auto-fit,minmax(min(125px,100%),1fr)); grid-template-rows:none; }
.workspace .step-tile { min-height:44px; grid-template-columns:auto auto 1fr; gap:6px; }
.workspace .tile-name { font:500 13px/1.4 var(--reading-font); }
.workspace .sound-buttons { grid-template-columns:repeat(auto-fit,minmax(min(100px,100%),1fr)); }
.workspace .interval-chain { grid-template-columns:repeat(auto-fit,minmax(min(102px,100%),1fr)); }
.workspace .interval-block { padding:10px 6px; }
.workspace .interval-block span { font-size:13px; }
.workspace .step-chip { width:auto; min-width:27px; height:26px; border-radius:5px; font:650 13px/1 var(--reading-font); }
.workspace .step-chip.L { background:var(--limma-bg); color:var(--limma-ink); }
.workspace .step-chip.C { background:var(--comma-bg); color:var(--comma-ink); }
.workspace :is(.data-val,.summary-v,.tone-hz,td) { font-variant-numeric:tabular-nums; }
#app .stage-legend span { padding:5px 8px; gap:6px; font:600 12px/1.35 var(--reading-font); color:#f1ebdc; background:#172d28; border-color:#61766a; }
#app .stage-legend i { width:15px; height:5px; }
#monoPanel .hud-metric span,#monoPanel .hud-primary small { color:#c2d1c6; }
#app .stage-legend { position:static; order:5; align-self:end; margin:4px 8px; transform:none; }
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
  #app .stage-legend { display:flex; grid-column:1; justify-self:center; }
  #app .stage-legend span { font-size:12px; }
}
.scholar-dialog .dialog-content,.sheet-panel { font-family:var(--reading-font); }
.scholar-dialog .dialog-content :is(p,li),.sheet-panel .sheet-grid b { font:500 15px/1.6 var(--reading-font); }
.workspace .tile-name { white-space:normal; overflow-wrap:anywhere; text-align:start; }
.workspace .table-wrap table { table-layout:auto; min-width:46rem; height:auto; }
.workspace .table-wrap :is(th,td) { white-space:nowrap; padding:7px 10px; }
.workspace .table-wrap { max-width:100%; }
#monoPanel { --limma-mark:#74b3a4; --comma-mark:#d48d86; }
#monoSvg .interval-limma:not(.current) { fill:var(--limma-mark); }
#monoSvg .interval-comma:not(.current) { fill:var(--comma-mark); }
#app .stage-legend i.legend-limma { background:var(--limma-mark); }
#app .stage-legend i.legend-comma { background:var(--comma-mark); }
#app .mobile-nav button:not(.active) { color:#dbe4dc!important; }
@media(prefers-color-scheme:dark) {
  .workspace :is(.btn:not(.primary):not(.danger),.field select,.field input:not([type=range]),.audio-mini select) { background:#243d35; color:var(--text-main); border-color:var(--rule); }
  .workspace .btn.danger { background:var(--comma-bg); color:var(--comma-ink); }
}

/* The ruler, ratio bracket and interval band have dedicated SVG lanes. */
body:not(.view-theory) #monoPanel #monoSvg {
  width:100%; height:auto!important; aspect-ratio:1244/182;
}
#monoPanel #monoSvg .ruler-label,
#monoPanel #monoSvg .small-label,
#monoPanel #monoSvg .length-bracket-text {
  fill:#d8e6da; font:600 10px Vazirmatn,system-ui,sans-serif;
}
#monoPanel .hud-metric b { direction:ltr; unicode-bidi:isolate; }
.workspace .step-equation { direction:ltr; unicode-bidi:isolate; text-align:start; }
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
  /* Normal document flow lets the browser chrome change height independently. */
  #app #monoPanel {
    display:flex!important; flex-direction:column; align-items:stretch;
    height:auto!important; max-height:none; gap:4px;
  }
  #monoPanel #monoScrollShell { order:0; align-self:stretch; width:100%; }
  #monoPanel .instrument-wrap { order:1; width:100%; margin:0; }
  #monoPanel #stageLegend { order:2; align-self:center; margin:0; }
  #monoPanel .pitch-controls {
    order:3; align-items:center; justify-content:center; gap:6px 12px;
    padding:6px 0; border-top:1px solid #4d685e;
  }
  #monoPanel .pitch-controls :is(label,output) { width:auto; }
  #app .topbar { position:relative!important; top:auto!important; }
}
#app .header-actions #viewSwitch { height:auto; align-items:center; }
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
  #monoPanel #stageLegend { display:flex!important; }
  #monoPanel #monoSvg .small-label,#monoPanel #monoSvg .ruler-label { font-size:12px; }
}
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
  /* The fret picker carries the index; keep close neighbours distinct on the string. */
  #monoPanel #monoSvg .small-label { display:none; }
}

/* Accessible scholarly navigation and small-screen legibility. */
.welcome-links [data-reference-link],.orientation-reference { display:inline-block; padding:8px 0; color:inherit; font:600 14px/1.5 var(--reading-font); text-decoration:underline; text-underline-offset:3px; }
.orientation-card nav a,.orientation-reference { color:#f1db9e; }
.orientation-card nav { font-size:14px; line-height:1.9; }
#orientationGate .orientation-card { max-height:90dvh; overflow:auto; }
[data-reference-link]:focus-visible,.orientation-card a:focus-visible { outline:3px solid currentColor; outline-offset:3px; }
.sheet-reference { min-height:44px; display:flex; align-items:center; justify-content:center; text-align:center; }
.statusbar [data-reference-link] { color:inherit; margin-inline-start:auto; }
#monoPanel .hud-primary small,#monoPanel .hud-metric span { font-size:12px; line-height:1.35; }
#monoPanel .hud-metric b,#monoPanel .hud-primary b { font-size:14px; }
#app .workspace-context { font-size:12px; line-height:1.4; }
@media (max-width:1100px) { #app .language-select { font-size:14px!important; min-width:90px; } }
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
 #app .mobile-nav button b { font:600 12px/1.2 var(--reading-font)!important; }
 #app .mobile-nav button { min-height:44px; }
 #monoPanel .hud-metric { min-width:0; }
}
@media (forced-colors:active) { .tab.active,.mobile-nav button.active { outline:2px solid Highlight; } }

/* Official application icon and accessible home link. */
#atlasHomeLogo { cursor:pointer; text-decoration:none; }
#atlasHomeLogo:hover { border-color:var(--gold); }
#atlasHomeLogo:focus-visible { outline:3px solid var(--gold); outline-offset:3px; }
#atlasHomeLogo img { border-radius:9px; }

/* Always reachable Previous / Play / Next controls in landscape phone workspaces.
   Primary section navigation remains sticky at the top; only the active step
   navigator is fixed at the bottom, with document clearance for the last card. */
#mobileStepNav { display:none; }
#mobileStepNav[hidden] { display:none!important; }
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) {
 body:not(.embed-mode):not(.welcome-visible) #mobileStepNav:not([hidden]) {
  position:fixed; z-index:75; inset-inline:0; bottom:0;
  display:grid; grid-template-columns:minmax(76px,auto) minmax(0,1fr) minmax(76px,auto) minmax(76px,auto);
  align-items:center; gap:5px;
  padding:4px max(8px,env(safe-area-inset-right,0px)) calc(4px + env(safe-area-inset-bottom,0px)) max(8px,env(safe-area-inset-left,0px));
  background:#142825; border-top:1px solid #718a7a;
  box-shadow:0 -4px 14px #0003; color:#f6ebd0;
 }
 #mobileStepNav button {
  min-height:44px; min-width:0; padding:4px 10px; border:1px solid #708a7e; border-radius:7px;
  background:#223e35; color:#f6ebd0; font:600 13px/1.2 var(--reading-font);
  touch-action:manipulation; white-space:normal;
 }
 #mobileStepNav .step-nav-next { background:#e9c47d; color:#17251e; border-color:#e9c47d; }
 #mobileStepNav .step-nav-play { background:#31564a; }
 #mobileStepNav .step-nav-position { display:flex; flex-direction:column; justify-content:center; align-items:center; padding-inline:5px; background:transparent; border-color:transparent; }
 #mobileStepNav .step-nav-position span { max-width:100%; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
 #mobileStepCount { font-size:12px; color:#d5c6a5; font-variant-numeric:tabular-nums; }
 #mobileStepTitle { font-size:13px; }
 #mobileStepNav button:disabled { opacity:.45; cursor:default; }
 #mobileStepNav button:focus-visible { outline:2px solid #f7d797; outline-offset:1px; }
 body.has-mobile-step-nav:not(.embed-mode) #app .workspace { padding-bottom:calc(84px + env(safe-area-inset-bottom,0px))!important; }
 body.has-mobile-step-nav:not(.embed-mode) .lesson-main,body.has-mobile-step-nav:not(.embed-mode) .step-info { scroll-margin-top:78px; }
 body.has-mobile-step-nav:not(.embed-mode) { scroll-padding-bottom:calc(60px + env(safe-area-inset-bottom,0px)); }
}
@media (orientation:landscape) and (max-height:600px) and (pointer:coarse) and (max-width:570px) {
 #mobileStepNav button { font-size:12px; padding-inline:5px; }
 body:not(.embed-mode):not(.welcome-visible) #mobileStepNav:not([hidden]) { grid-template-columns:minmax(60px,auto) minmax(0,1fr) minmax(60px,auto) minmax(60px,auto); }
}
