:root {
  color-scheme: dark light;
  --soot: #0d0a09;
  --ebony: #171210;
  --ebony-raised: #221b17;
  --parchment: #e4d7be;
  --parchment-light: #f2e8d5;
  --parchment-deep: #cab692;
  --parchment-stain: #b89f74;
  --ink: #1b1512;
  --ink-muted: #57483e;
  --oxblood: #6b1f28;
  --oxblood-bright: #8a2a36;
  --oxblood-dark: #3d1016;
  --brass: #b89249;
  --brass-bright: #d9b86c;
  --brass-dim: rgba(184, 146, 73, 0.36);
  --verdigris: #395c52;
  --bone: #ede3ce;
  --serif-display: "Palatino Linotype", "Book Antiqua", Palatino, "Iowan Old Style", Baskerville, "Goudy Old Style", Garamond, Georgia, serif;
  --mono-ledger: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--soot);
}

body {
  min-height: 100vh;
  margin: 0;
  padding: clamp(0.75rem, 2.2vw, 1.85rem);
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 15%, rgba(184, 146, 73, 0.12), transparent 65%),
    radial-gradient(circle at 50% 85%, rgba(107, 31, 40, 0.18), transparent 60%),
    repeating-linear-gradient(
      90deg,
      rgba(228, 215, 190, 0.025) 0 1px,
      transparent 1px 28px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.25) 0 2px,
      transparent 2px 5px
    ),
    var(--soot);
  font-family: var(--serif-display);
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

select:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 3px;
}

/* The loop machine strip (D-039). The readout narrates the song, so it keeps
   one fixed line and never widens the row (the reflow lessons of D-034/P5-23). */
.looper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  margin-top: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(184, 146, 73, 0.4);
  background: rgba(10, 8, 7, 0.55);
  font-family: var(--mono-ledger);
}

.looper-label {
  color: var(--brass-bright);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.looper-button[aria-pressed="true"] {
  border-color: var(--brass-bright);
  color: #faf3e6;
  background: rgba(139, 46, 56, 0.55);
}

.looper-button.is-armed {
  border-color: #e0aa3e !important;
  color: #fff5db !important;
  background: rgba(130, 85, 15, 0.75) !important;
  box-shadow: 0 0 10px rgba(224, 170, 62, 0.5);
  animation: looper-pulse-amber 1s ease-in-out infinite;
}

.looper-button.is-recording {
  border-color: #e04444 !important;
  color: #ffffff !important;
  background: rgba(160, 25, 35, 0.85) !important;
  box-shadow: 0 0 12px rgba(224, 68, 68, 0.6);
  animation: looper-pulse-red 800ms ease-in-out infinite;
}

.looper-button.is-step-rec {
  border-color: #ffd875 !important;
  color: #fff8e6 !important;
  background: rgba(130, 85, 15, 0.85) !important;
  box-shadow: 0 0 10px rgba(255, 216, 117, 0.55);
}

.looper-section-button {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}

#looper-insert-intro:hover:not(:disabled) {
  border-color: rgba(255, 216, 117, 0.9);
  color: #fff;
}

#looper-insert-bridge:hover:not(:disabled) {
  border-color: rgba(190, 130, 240, 0.9);
  color: #fff;
}

#looper-insert-outro:hover:not(:disabled) {
  border-color: rgba(240, 90, 100, 0.9);
  color: #fff;
}

@keyframes looper-pulse-amber {
  0%, 100% { border-color: #e0aa3e; box-shadow: 0 0 6px rgba(224, 170, 62, 0.4); }
  50% { border-color: #ffd875; box-shadow: 0 0 14px rgba(255, 216, 117, 0.7); }
}

@keyframes looper-pulse-red {
  0%, 100% { border-color: #e04444; box-shadow: 0 0 8px rgba(224, 68, 68, 0.5); }
  50% { border-color: #ff6b6b; box-shadow: 0 0 16px rgba(255, 107, 107, 0.85); }
}

/* 12-step visual progress and sync tracker for the loop machine (D-045). */
.looper-steps {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.25rem;
  flex: 1 0 100%;
  margin: 0.2rem 0 0.35rem;
}

.looper-steps.is-16-steps {
  grid-template-columns: repeat(16, minmax(0, 1fr));
}

.looper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.22rem 0.1rem;
  border: 1px solid rgba(184, 146, 73, 0.28);
  background: rgba(20, 15, 12, 0.85);
  color: rgba(228, 215, 190, 0.65);
  border-radius: 2px;
  min-height: 1.85rem;
  font-family: var(--mono-ledger);
  cursor: pointer;
  outline: none;
  user-select: none;
  transition: border-color 90ms ease, background 90ms ease, box-shadow 90ms ease;
}

.looper-step:hover:not(:disabled) {
  border-color: rgba(212, 175, 101, 0.6);
  background: rgba(45, 32, 22, 0.9);
}

.looper-step:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 1px;
}

.looper-step-num {
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(212, 175, 101, 0.8);
}

.looper-step-val {
  font-size: 0.6rem;
  color: rgba(228, 215, 190, 0.9);
  min-height: 0.75rem;
  line-height: 0.75rem;
}

.looper-step.is-current {
  border-color: var(--brass-bright);
  background: rgba(60, 45, 25, 0.8);
  box-shadow: 0 0 6px rgba(212, 175, 101, 0.4);
}

.looper-step.is-count-in {
  border-color: #d4a035;
  background: rgba(140, 95, 20, 0.6);
  color: #fff2d0;
  box-shadow: 0 0 8px rgba(212, 160, 53, 0.55);
}

.looper-step.is-recording {
  border-color: #e04444;
  background: rgba(160, 30, 40, 0.9);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(224, 68, 68, 0.7);
}

.looper-step.has-note {
  border-color: rgba(184, 146, 73, 0.5);
  background: rgba(35, 25, 20, 0.92);
}

.looper-step.has-note .looper-step-val {
  color: var(--brass-bright);
  font-weight: 700;
}

.looper-step.is-selected-step {
  border-color: #ffd875 !important;
  background: rgba(85, 65, 25, 0.95) !important;
  box-shadow: 0 0 10px rgba(255, 216, 117, 0.7) !important;
}

.looper-step.is-selected-step .looper-step-num {
  color: #fff9e6;
}

/* Loop tiles scroll sideways at a fixed height, so adding or playing loops
   never moves the page. */
.looper-tiles {
  display: flex;
  flex: 1 0 100%;
  gap: 0.4rem;
  height: 3.4rem;
  margin: 0;
  padding: 0 0 0.3rem;
  overflow-x: auto;
  overflow-y: hidden;
  list-style: none;
  contain: inline-size;
}

.looper-tile {
  flex: 0 0 auto;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.15rem;
  width: 4.6rem;
  height: 100%;
  border: 1px solid rgba(184, 146, 73, 0.45);
  color: var(--parchment-light);
  background: rgba(23, 17, 14, 0.9);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.looper-tile b {
  font-size: 0.78rem;
}

.looper-tile[aria-pressed="true"] {
  border-color: var(--brass-bright);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 101, 0.55);
}

.looper-tile.is-playing {
  background: linear-gradient(180deg, rgba(107, 31, 40, 0.55) 0%, rgba(28, 20, 16, 0.95) 100%);
}

.looper-tile[data-role="intro"] {
  border-color: rgba(212, 175, 101, 0.7);
}

.looper-tile[data-role="main"] {
  border-color: rgba(57, 168, 130, 0.75);
}

.looper-tile[data-role="bridge"] {
  border-color: rgba(168, 104, 212, 0.7);
}

.looper-tile[data-role="outro"] {
  border-color: rgba(196, 52, 60, 0.7);
}

.looper-tile .looper-role-tag {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

.fun-casio-bar {
  margin-top: 0.25rem;
}

.fun-casio-buttons {
  display: flex;
  gap: 0.35rem;
}

.fun-casio-button {
  letter-spacing: 0.08em;
  font-size: 0.65rem;
  font-weight: 600;
  transition: all 0.15s ease-out;
}

#casio-intro:hover:not(:disabled),
#casio-intro.is-cued,
#casio-intro.is-active {
  border-color: rgba(255, 216, 117, 0.9);
  color: #fff;
}

#casio-intro.is-active {
  background: rgba(120, 90, 25, 0.95);
  box-shadow: 0 0 8px rgba(255, 216, 117, 0.5);
}

#casio-intro.is-cued {
  background: rgba(70, 55, 15, 0.95);
  box-shadow: 0 0 6px rgba(255, 216, 117, 0.35);
  animation: casio-pulse 1s infinite alternate;
}

#casio-bridge:hover:not(:disabled),
#casio-bridge.is-cued,
#casio-bridge.is-active {
  border-color: rgba(190, 130, 240, 0.9);
  color: #fff;
}

#casio-bridge.is-active {
  background: rgba(90, 35, 120, 0.95);
  box-shadow: 0 0 8px rgba(190, 130, 240, 0.5);
}

#casio-bridge.is-cued {
  background: rgba(55, 20, 75, 0.95);
  box-shadow: 0 0 6px rgba(190, 130, 240, 0.35);
  animation: casio-pulse 1s infinite alternate;
}

#casio-outro:hover:not(:disabled),
#casio-outro.is-cued,
#casio-outro.is-active {
  border-color: rgba(240, 90, 100, 0.9);
  color: #fff;
}

#casio-outro.is-active {
  background: rgba(130, 30, 40, 0.95);
  box-shadow: 0 0 8px rgba(240, 90, 100, 0.5);
}

#casio-outro.is-cued {
  background: rgba(80, 20, 25, 0.95);
  box-shadow: 0 0 6px rgba(240, 90, 100, 0.35);
  animation: casio-pulse 1s infinite alternate;
}

@keyframes casio-pulse {
  0% { opacity: 0.75; }
  100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #casio-intro.is-cued,
  #casio-bridge.is-cued,
  #casio-outro.is-cued {
    animation: none;
  }
}

.looper-edit {
  display: flex;
  flex: 1 0 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
}

.looper-edit-label,
.looper-repeats {
  color: rgba(228, 215, 190, 0.86);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
}

.looper-edit-label {
  min-width: 9.5rem;
}

.looper-repeats {
  min-width: 2.2rem;
  text-align: center;
}

.looper-readout {
  display: block;
  flex: 1 0 100%;
  contain: inline-size;
  height: 1.5em;
  overflow: hidden;
  color: rgba(228, 215, 190, 0.82);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  line-height: 1.5em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Accessibility floor (P4-02): no text below 0.6rem (9.6px), and dimmed bone
   text on the dark panels keeps at least 4.5:1 contrast (alpha 0.55 and up). */

/* Discovery and the whole cabinet (D-037). */
.cabinet-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1.2rem;
  padding: 0.75rem clamp(1.1rem, 3vw, 2.8rem);
  border-bottom: 1px solid var(--brass-dim);
  color: var(--bone);
  background: linear-gradient(180deg, var(--ebony-raised) 0%, var(--ebony) 100%);
  font-family: var(--mono-ledger);
}

.cabinet-switch[hidden] {
  display: none;
}

.cabinet-switch-text {
  margin: 0;
  color: rgba(228, 215, 190, 0.86);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.cabinet-switch-button,
.drawer-toggle {
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--brass);
  color: var(--parchment-light);
  background: rgba(10, 8, 7, 0.55);
  font-family: var(--mono-ledger);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  cursor: pointer;
}

.cabinet-switch-button:hover,
.drawer-toggle:hover {
  border-color: var(--brass-bright);
}

/* A drawer's bar: its name, its one-line invitation, and the toggle. Shown
   only in discovery; the whole cabinet hides the bars and opens everything. */
.drawer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.7rem clamp(1.1rem, 3vw, 2.8rem);
  border-top: 1px solid rgba(184, 146, 73, 0.32);
  color: var(--bone);
  background: rgba(10, 8, 7, 0.6);
  font-family: var(--mono-ledger);
}

.drawer-bar[hidden] {
  display: none;
}

.drawer-invite {
  margin: 0;
  color: rgba(228, 215, 190, 0.82);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
}

.drawer-invite b {
  color: var(--brass-bright);
}

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

/* A sealed wing keeps a slim nameplate instead of its full parchment band. */
.workstation-wing.is-sealed .wing-header {
  padding-block: 0.45rem 0.4rem;
}

.workstation-wing.is-sealed .wing-dek {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .drawer-body.is-newly-open {
    animation: drawer-open 520ms ease-out;
  }
}

@keyframes drawer-open {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 60;
  padding: 0.7rem 1rem;
  border: 2px solid var(--brass);
  color: var(--bone);
  background: var(--ebony);
  font-family: var(--mono-ledger);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.22;
  background:
    repeating-radial-gradient(circle at 22% 31%, transparent 0 2px, rgba(27, 21, 18, 0.09) 3px 4px),
    repeating-linear-gradient(115deg, transparent 0 5px, rgba(255, 244, 214, 0.04) 6px 7px);
  mix-blend-mode: multiply;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 39;
  pointer-events: none;
  box-shadow: inset 0 0 120px rgba(8, 5, 4, 0.78);
}

.oracle-cabinet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(86rem, 100%);
  min-height: calc(100vh - clamp(1.5rem, 4.4vw, 3.7rem));
  margin: 0 auto;
  overflow: hidden;
  border: 3px solid var(--brass);
  outline: 1px solid rgba(27, 21, 18, 0.55);
  outline-offset: -10px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 248, 231, 0.55), transparent 60%),
    radial-gradient(ellipse at 12% 88%, rgba(184, 159, 116, 0.35), transparent 45%),
    radial-gradient(ellipse at 88% 12%, rgba(184, 159, 116, 0.28), transparent 42%),
    repeating-linear-gradient(
      0deg,
      rgba(27, 21, 18, 0.018) 0 1px,
      transparent 1px 4px
    ),
    var(--parchment);
  box-shadow:
    0 0 0 5px var(--ebony),
    0 0 0 7px rgba(184, 146, 73, 0.42),
    0 26px 70px rgba(0, 0, 0, 0.85);
}

.cabinet-corner {
  position: absolute;
  z-index: 5;
  width: 1.85rem;
  height: 1.85rem;
  border-color: var(--oxblood);
  border-style: solid;
  pointer-events: none;
}

.cabinet-corner::after {
  position: absolute;
  color: var(--oxblood);
  font-size: 0.72rem;
  line-height: 1;
  content: "✦";
}

.cabinet-corner-tl {
  top: 0.85rem;
  left: 0.85rem;
  border-width: 2px 0 0 2px;
}

.cabinet-corner-tl::after {
  top: 0.2rem;
  left: 0.25rem;
}

.cabinet-corner-tr {
  top: 0.85rem;
  right: 0.85rem;
  border-width: 2px 2px 0 0;
}

.cabinet-corner-tr::after {
  top: 0.2rem;
  right: 0.25rem;
}

.cabinet-corner-bl {
  bottom: 0.85rem;
  left: 0.85rem;
  border-width: 0 0 2px 2px;
}

.cabinet-corner-bl::after {
  bottom: 0.2rem;
  left: 0.25rem;
}

.cabinet-corner-br {
  bottom: 0.85rem;
  right: 0.85rem;
  border-width: 0 2px 2px 0;
}

.cabinet-corner-br::after {
  bottom: 0.2rem;
  right: 0.25rem;
}

.masthead {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  min-height: 4.25rem;
  padding: 0.75rem clamp(1.1rem, 3vw, 2.8rem);
  border-bottom: 3px double var(--brass);
  background:
    linear-gradient(180deg, #211915 0%, var(--ebony) 100%);
  color: var(--bone);
}

.folio,
.icon-button,
.eyebrow,
.stage-marker,
.stage-caption,
.summon-form > label,
.form-foot,
.reading-label,
.score-card,
.volume-heading,
footer {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.folio {
  justify-self: start;
  color: var(--brass-bright);
  font-family: var(--mono-ledger);
  font-size: 0.64rem;
}

.wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  color: var(--parchment-light);
  font-size: clamp(0.82rem, 1.55vw, 1.15rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
}

.prompt-mark {
  color: var(--brass-bright);
  font-size: 0.92em;
  font-weight: 400;
}

.icon-button,
.text-button {
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  justify-self: end;
  min-width: 9.5rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--brass);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
  color: var(--parchment-light);
  background: linear-gradient(180deg, rgba(184, 146, 73, 0.18), rgba(23, 18, 16, 0.85));
  font-family: var(--mono-ledger);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.icon-button:hover {
  border-color: var(--brass-bright);
  color: #fff;
  background: rgba(184, 146, 73, 0.28);
}

.icon-button .sound-off,
.icon-button[aria-pressed="true"] .sound-on {
  display: none;
}

.icon-button[aria-pressed="true"] {
  border-color: var(--oxblood-bright);
  background: rgba(107, 31, 40, 0.42);
}

.icon-button[aria-pressed="true"] .sound-off {
  display: inline;
  color: #f3c6cb;
}

.oracle-shell {
  position: relative;
  flex: 1;
  padding: clamp(1.2rem, 2.2vw, 1.85rem) clamp(1rem, 2.8vw, 2.5rem);
}

.introduction {
  position: relative;
  z-index: 1;
  max-width: 58rem;
  margin: 0 auto clamp(0.75rem, 1.5vw, 1.25rem);
  text-align: center;
}

.esoteric-crest {
  width: min(8.5rem, 55%);
  margin: 0 auto 0.45rem;
  color: var(--oxblood);
}

.esoteric-crest svg {
  display: block;
  width: 100%;
  height: auto;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--oxblood);
  font-size: clamp(0.62rem, 0.9vw, 0.7rem);
  letter-spacing: 0.2em;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif-display);
  font-size: clamp(1.65rem, 3.2vw, 2.45rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.05;
  text-transform: uppercase;
  text-shadow:
    1px 1px 0 var(--parchment-light),
    2px 2px 0 rgba(107, 31, 40, 0.22);
  text-wrap: balance;
}

h1 em {
  display: inline-block;
  margin-top: 0.22em;
  padding: 0.14em 0.85em 0.16em;
  border-top: 1px solid var(--oxblood);
  border-bottom: 1px solid var(--oxblood);
  color: var(--oxblood);
  font-size: 0.44em;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-shadow: none;
}

.dek {
  max-width: 44rem;
  margin: 1.25rem auto 0;
  color: var(--ink-muted);
  font-size: clamp(0.88rem, 1.35vw, 1.06rem);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.58;
  text-wrap: balance;
}

.vision-cabinet {
  width: min(58rem, 100%);
  margin: 0 auto;
  padding: clamp(0.65rem, 1.6vw, 1.15rem);
  border: 2px solid var(--ebony);
  border-radius: 42% 42% 1.1rem 1.1rem / 11% 11% 1.1rem 1.1rem;
  background:
    radial-gradient(circle at 50% 10%, rgba(184, 146, 73, 0.22), transparent 55%),
    linear-gradient(180deg, #251d18 0%, #120e0c 100%);
  box-shadow:
    0 0 0 2px var(--brass),
    0 0 0 6px var(--parchment-deep),
    0 0 0 7px rgba(27, 21, 18, 0.45),
    0 18px 38px rgba(17, 11, 8, 0.45);
}

.vision-stage {
  position: relative;
  width: 100%;
  height: clamp(19rem, 34vw, 28rem);
  overflow: hidden;
  border: 2px solid var(--brass);
  border-radius: 41% 41% 0.7rem 0.7rem / 10% 10% 0.7rem 0.7rem;
  background: #090708;
  box-shadow:
    inset 0 0 55px rgba(0, 0, 0, 0.92),
    inset 0 0 0 1px rgba(217, 184, 108, 0.25);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.vision-stage.is-interacting {
  border-color: var(--brass-bright);
  box-shadow:
    inset 0 0 42px rgba(107, 31, 40, 0.42),
    inset 0 0 0 1px rgba(242, 232, 213, 0.45),
    0 0 24px rgba(217, 184, 108, 0.28);
}

.vision-stage.is-agitated {
  border-color: #d46b38;
  box-shadow:
    inset 0 0 50px rgba(180, 60, 30, 0.52),
    inset 0 0 0 1px rgba(245, 160, 80, 0.55),
    0 0 28px rgba(212, 107, 56, 0.42);
}

.vision-stage.is-retaliating {
  border-color: #e63926;
  box-shadow:
    inset 0 0 75px rgba(230, 57, 38, 0.75),
    inset 0 0 0 2px rgba(255, 230, 180, 0.85),
    0 0 45px rgba(230, 57, 38, 0.65);
}

.vision-stage.is-sulking {
  border-color: rgba(140, 120, 100, 0.4);
  box-shadow:
    inset 0 0 65px rgba(0, 0, 0, 0.95),
    inset 0 0 0 1px rgba(140, 120, 100, 0.2);
}

@keyframes vitrine-shudder {
  0% { transform: translate(0, 0) rotate(0deg); }
  12% { transform: translate(-5px, 3px) rotate(-0.6deg); }
  24% { transform: translate(6px, -4px) rotate(0.7deg); }
  36% { transform: translate(-4px, -3px) rotate(-0.5deg); }
  48% { transform: translate(5px, 2px) rotate(0.4deg); }
  60% { transform: translate(-3px, 2px) rotate(-0.3deg); }
  75% { transform: translate(2px, -1px) rotate(0.2deg); }
  90% { transform: translate(-1px, 1px) rotate(-0.1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@media (prefers-reduced-motion: no-preference) {
  .vision-stage.is-retaliating {
    animation: vitrine-shudder 600ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  }
}

.vision-stage::before {
  position: absolute;
  inset: 0.75rem;
  z-index: 2;
  border: 1px dashed rgba(217, 184, 108, 0.42);
  border-radius: inherit;
  pointer-events: none;
  content: "";
}

.vision-stage::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(ellipse at 32% 18%, rgba(255, 245, 220, 0.07) 0%, transparent 42%),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(7, 5, 6, 0.72) 100%);
  pointer-events: none;
  content: "";
}

.stage-spandrels {
  position: absolute;
  inset: 1.25rem;
  z-index: 2;
  width: calc(100% - 2.5rem);
  height: calc(100% - 2.5rem);
  color: rgba(217, 184, 108, 0.55);
  pointer-events: none;
}

#vision {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.vision-stage.is-interacting #vision {
  cursor: grabbing;
}

.stage-marker,
.stage-caption {
  position: absolute;
  z-index: 3;
  color: var(--bone);
  font-family: var(--mono-ledger);
  pointer-events: none;
}

.stage-marker {
  top: 13.5%;
  padding: 0.38rem 0.65rem;
  border: 1px solid rgba(184, 146, 73, 0.65);
  background: rgba(18, 13, 11, 0.84);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  color: var(--brass-bright);
  font-size: 0.6rem;
  letter-spacing: 0.15em;
}

.stage-marker-left {
  left: 1.65rem;
}

.stage-marker-right {
  right: 1.65rem;
}

.stage-caption {
  right: 1.5rem;
  bottom: 1.15rem;
  left: 1.5rem;
  width: fit-content;
  max-width: calc(100% - 3rem);
  margin: 0 auto;
  padding: 0.35rem 0.9rem;
  border: 1px solid rgba(184, 146, 73, 0.45);
  background: rgba(15, 11, 10, 0.82);
  color: rgba(237, 227, 206, 0.88);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.vision-stage.is-agitated .stage-caption {
  border-color: rgba(212, 107, 56, 0.75);
  background: rgba(35, 14, 10, 0.9);
  color: #fed7aa;
}

.vision-stage.is-retaliating .stage-caption {
  border-color: rgba(230, 57, 38, 0.95);
  background: rgba(45, 10, 8, 0.96);
  color: #ffedd5;
  box-shadow: 0 0 16px rgba(230, 57, 38, 0.6);
}

.vision-stage.is-sulking .stage-caption {
  border-color: rgba(120, 110, 100, 0.4);
  background: rgba(14, 12, 12, 0.88);
  color: rgba(180, 170, 160, 0.65);
}

/* Aetheric Bone Theremin Pedestal Controller (P10-01, D-089) */
.theremin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(184, 146, 73, 0.45);
  border-radius: 4px;
  background: linear-gradient(180deg, #1c1511 0%, #100b09 100%);
  box-shadow: inset 0 1px 0 rgba(184, 146, 73, 0.18), 0 2px 8px rgba(0, 0, 0, 0.5);
  font-family: var(--mono-ledger);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
}

.theremin-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.65rem;
  border: 1px solid var(--brass-dim);
  border-radius: 3px;
  background: rgba(33, 24, 20, 0.85);
  color: var(--brass-bright);
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: all 140ms ease;
}

.theremin-button:hover {
  border-color: var(--brass-bright);
  background: rgba(50, 36, 28, 0.95);
  color: #fff2d6;
  box-shadow: 0 0 6px rgba(184, 146, 73, 0.35);
}

.theremin-button[aria-pressed="false"] {
  border-color: rgba(120, 110, 100, 0.3);
  background: rgba(20, 16, 14, 0.7);
  color: rgba(180, 170, 160, 0.55);
}

.theremin-glyph {
  color: #ffb84d;
}

.theremin-readout {
  margin-left: auto;
  color: var(--brass);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.theremin-readout.is-stuck {
  color: #f59e0b;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.55);
  animation: theremin-amber-pulse 1.4s ease-in-out infinite alternate;
}

.theremin-readout.is-calcifying {
  color: #fbbf24;
}

@keyframes theremin-amber-pulse {
  from { opacity: 0.75; }
  to { opacity: 1; }
}

/* The BioParasite Spore Harp (P10-03, D-091) */
.spore-harp-bar {
  margin-top: 0.45rem;
  border-color: rgba(124, 226, 132, 0.35);
  background: linear-gradient(180deg, #121913 0%, #0a110b 100%);
  box-shadow: inset 0 1px 0 rgba(124, 226, 132, 0.15), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.harp-glyph {
  color: #86efac;
}

.harp-telemetry {
  color: #bef264;
}

.harp-button:hover {
  border-color: #86efac;
  box-shadow: 0 0 6px rgba(134, 239, 172, 0.35);
}

/* PlantWave Amanita Muscaria Transducer & Hallucination Matrix (P10-04, D-095) */
.muscaria-bar {
  margin-top: 0.45rem;
  border-color: rgba(239, 68, 68, 0.4);
  background: linear-gradient(180deg, #1c0e13 0%, #0d060a 100%);
  box-shadow: inset 0 1px 0 rgba(239, 68, 68, 0.2), 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.muscaria-bar.is-pulse {
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: inset 0 1px 0 rgba(245, 158, 11, 0.3), 0 0 12px rgba(245, 158, 11, 0.25);
}

.muscaria-bar.is-hallucinating {
  border-color: rgba(217, 70, 239, 0.65);
  box-shadow: inset 0 1px 0 rgba(217, 70, 239, 0.4), 0 0 16px rgba(217, 70, 239, 0.35);
  animation: muscaria-trip-pulse 2.2s ease-in-out infinite alternate;
}

.muscaria-glyph {
  color: #f87171;
  text-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.muscaria-telemetry {
  color: #f472b6;
  text-shadow: 0 0 6px rgba(244, 114, 182, 0.45);
}

.muscaria-button:hover {
  border-color: #f43f5e;
  box-shadow: 0 0 6px rgba(244, 63, 94, 0.4);
}

@keyframes muscaria-trip-pulse {
  0% {
    border-color: rgba(239, 68, 68, 0.65);
    box-shadow: inset 0 1px 0 rgba(239, 68, 68, 0.4), 0 0 14px rgba(239, 68, 68, 0.3);
  }
  50% {
    border-color: rgba(168, 85, 247, 0.7);
    box-shadow: inset 0 1px 0 rgba(168, 85, 247, 0.45), 0 0 18px rgba(168, 85, 247, 0.38);
  }
  100% {
    border-color: rgba(245, 158, 11, 0.65);
    box-shadow: inset 0 1px 0 rgba(245, 158, 11, 0.4), 0 0 14px rgba(245, 158, 11, 0.3);
  }
}

.summon-form {
  position: relative;
  width: min(56rem, 100%);
  margin: clamp(1rem, 2vw, 1.5rem) auto 0;
  padding: clamp(0.9rem, 1.8vw, 1.35rem);
  border: 1px solid rgba(27, 21, 18, 0.45);
  outline: 1px solid rgba(107, 31, 40, 0.28);
  outline-offset: -5px;
  background:
    linear-gradient(180deg, rgba(242, 232, 213, 0.72), rgba(216, 198, 165, 0.52));
  box-shadow: 0 6px 20px rgba(27, 21, 18, 0.12);
  text-align: center;
}

.summon-form > label {
  display: block;
  margin: 0 0 0.65rem;
  color: var(--oxblood-dark);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
}

.manicule {
  display: inline-block;
  margin-right: 0.35rem;
  color: var(--oxblood);
  font-size: 1.25em;
  vertical-align: -0.08em;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  border: 2px solid var(--ebony);
  background: var(--parchment-light);
  box-shadow:
    inset 0 2px 6px rgba(27, 21, 18, 0.12),
    5px 5px 0 var(--ebony);
}

#phrase {
  min-width: 0;
  padding: 0.85rem 1.25rem;
  border: 0;
  color: var(--ink);
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0 2.15rem,
      rgba(107, 31, 40, 0.1) 2.15rem 2.2rem
    );
  font-family: var(--serif-display);
  font-size: clamp(1.05rem, 1.9vw, 1.4rem);
  font-style: italic;
  font-weight: 600;
  text-align: center;
}

#phrase::placeholder {
  color: rgba(87, 72, 62, 0.52);
  font-style: italic;
  font-weight: 400;
}

#phrase:focus {
  outline: 0;
  background-color: #faf3e6;
}

.summon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-width: 12.5rem;
  padding: 0.75rem 1.25rem;
  border: 0;
  border-left: 2px solid var(--ebony);
  color: var(--parchment-light);
  background:
    linear-gradient(180deg, var(--oxblood-bright) 0%, var(--oxblood) 55%, var(--oxblood-dark) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 230, 200, 0.28);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, filter 150ms ease;
}

.summon-button .sigil {
  color: var(--brass-bright);
  font-size: 1.05em;
}

.summon-button:hover {
  color: #fff;
  background:
    linear-gradient(180deg, #2a201b 0%, var(--ebony) 100%);
}

.form-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  color: var(--ink-muted);
  font-family: var(--mono-ledger);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
}

.text-button {
  padding: 0.15rem 0.25rem;
  border-bottom: 1px dashed var(--oxblood);
  color: var(--oxblood);
  font-family: var(--serif-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: color 150ms ease, border-color 150ms ease;
}

.text-button:hover {
  border-bottom-style: solid;
  color: var(--ink);
}

.reading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(1.2rem, 2.5vw, 2.5rem);
  min-height: auto;
  padding: 1.1rem clamp(1.1rem, 3vw, 2.8rem);
  border-top: 3px double var(--brass);
  border-bottom: 2px solid var(--brass);
  color: var(--bone);
  background:
    radial-gradient(ellipse at 20% 50%, rgba(107, 31, 40, 0.24), transparent 55%),
    linear-gradient(180deg, var(--ebony-raised) 0%, var(--ebony) 100%);
}

.reading-label {
  margin: 0 0 0.25rem;
  color: var(--brass-bright);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
}

.reading-meta {
  margin: 0 0 0.45rem;
  color: var(--gold-pale);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.reading h2 {
  max-width: 26ch;
  margin: 0;
  color: var(--parchment-light);
  font-family: var(--serif-display);
  font-size: clamp(1.15rem, 2.2vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.12;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
}

.score-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(6.5rem, auto));
  gap: 0.65rem 1.4rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--brass-dim);
  background: rgba(10, 8, 7, 0.48);
  font-family: var(--mono-ledger);
}

.score-card span {
  display: grid;
  gap: 0.2rem;
  color: rgba(228, 215, 190, 0.65);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
}

.score-card b {
  color: var(--brass-bright);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

/* Volume and tempo sit side by side: each heading stacks over its slider. */
.volume-control {
  display: grid;
  grid-template-rows: auto auto;
  grid-auto-flow: column;
  grid-auto-columns: minmax(8.5rem, 11.5rem);
  align-items: center;
  gap: 0.38rem 1.4rem;
}

.volume-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: rgba(228, 215, 190, 0.78);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
}

.volume-heading output {
  color: var(--brass-bright);
}

#master-volume,
#tempo-bpm,
#kapellmeister-strictness,
#parlor-acoustics-level {
  width: 100%;
  height: 1rem;
  margin: 0;
  padding: 0;
  accent-color: var(--brass-bright);
  cursor: pointer;
}

/* Master transport (P5-18, D-027): the rail that opens Wing I. */
.transport-deck {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.9rem 1.6rem;
  padding: 1.1rem clamp(1.1rem, 3vw, 2.8rem);
  border-bottom: 2px solid var(--brass);
  color: var(--bone);
  background:
    radial-gradient(ellipse at 20% 50%, rgba(107, 31, 40, 0.2), transparent 55%),
    linear-gradient(180deg, var(--ebony-raised) 0%, var(--ebony) 100%);
  font-family: var(--mono-ledger);
}

.transport-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.transport-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.72rem 1.05rem;
  border: 1px solid var(--brass);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6);
  color: var(--parchment-light);
  background: linear-gradient(180deg, rgba(184, 146, 73, 0.16), rgba(15, 11, 10, 0.8));
  font-family: var(--mono-ledger);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.transport-glyph {
  color: var(--brass-bright);
  font-size: 0.72rem;
  letter-spacing: 0;
}

.transport-button:not(:disabled):hover {
  border-color: var(--brass-bright);
  color: var(--ink);
  background: var(--brass-bright);
}

.transport-button:not(:disabled):hover .transport-glyph {
  color: var(--oxblood-dark);
}

.transport-button[aria-pressed="true"] {
  border-color: var(--brass-bright);
  color: var(--parchment-light);
  background: linear-gradient(180deg, var(--oxblood-bright), var(--oxblood-dark));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 12px rgba(217, 184, 108, 0.28);
}

.transport-button:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 2px;
}

.transport-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.transport-position {
  min-width: 9ch;
  padding: 0.72rem 0.75rem;
  border: 1px solid var(--brass-dim);
  color: var(--brass-bright);
  background: rgba(10, 8, 7, 0.48);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
}

/* Its own full-width line of fixed height: section names differ in length,
   and the readout must never re-wrap the transport row as they change.
   `contain: inline-size` stops the text from widening the row it sits in,
   which pushed the volume controls onto a new line once per loop. */
.transport-section {
  display: block;
  flex: 1 0 100%;
  min-width: 0;
  contain: inline-size;
  height: 1.5em;
  line-height: 1.5em;
  color: rgba(228, 215, 190, 0.72);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transport-rec-led {
  color: #8b3a3a;
  font-size: 0.82rem;
  line-height: 1;
  transition: color 150ms ease, text-shadow 150ms ease;
}

.transport-live-rec.is-armed {
  border-color: #d4a340;
}

.transport-live-rec.is-armed .transport-rec-led {
  color: #d4a340;
  text-shadow: 0 0 8px rgba(212, 163, 64, 0.8);
  animation: live-rec-pulse 800ms infinite alternate ease-in-out;
}

.transport-live-rec.is-recording {
  border-color: #d33c3c;
  background: linear-gradient(180deg, rgba(211, 60, 60, 0.28), rgba(40, 10, 10, 0.85));
}

.transport-live-rec.is-recording .transport-rec-led {
  color: #ff3333;
  text-shadow: 0 0 10px #ff3333;
}

.transport-live-rec.is-stopping .transport-rec-led {
  color: #ff5555;
  animation: live-rec-blink 400ms infinite ease-in-out;
}

@keyframes live-rec-pulse {
  0% { opacity: 0.45; }
  100% { opacity: 1; }
}

@keyframes live-rec-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  .transport-live-rec.is-armed .transport-rec-led,
  .transport-live-rec.is-stopping .transport-rec-led {
    animation: none;
  }
}

.transport-rec-status {
  padding: 0.72rem 0.75rem;
  border: 1px solid var(--brass-dim);
  color: var(--brass);
  background: rgba(10, 8, 7, 0.48);
  font-family: var(--mono-ledger);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

/* Workstation wings (D-027): parchment drawer labels between the ebony consoles. */
.workstation-wing {
  display: flex;
  flex-direction: column;
}

.wing-header {
  display: grid;
  grid-template-columns: minmax(1.5rem, 1fr) auto minmax(1.5rem, 1fr);
  align-items: center;
  gap: clamp(0.75rem, 2.5vw, 2rem);
  padding: 0.9rem clamp(1.1rem, 3vw, 2.8rem) 0.8rem;
  border-bottom: 3px double var(--brass);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 248, 231, 0.55), transparent 70%),
    var(--parchment);
  text-align: center;
}

.wing-rule {
  height: 5px;
  border-top: 1px solid var(--oxblood);
  border-bottom: 1px solid var(--oxblood);
  opacity: 0.55;
}

.wing-title {
  display: grid;
  gap: 0.15rem;
}

.wing-numeral,
.wing-dek {
  margin: 0;
  font-family: var(--mono-ledger);
  font-weight: 700;
  text-transform: uppercase;
}

.wing-numeral {
  color: var(--oxblood);
  font-size: 0.6rem;
  letter-spacing: 0.32em;
}

.wing-header h2 {
  margin: 0;
  font-family: var(--serif-display);
  font-size: clamp(1.15rem, 2.2vw, 1.6rem);
  font-weight: 700;
  letter-spacing: 0.22em;
  line-height: 1.1;
}

.wing-dek {
  color: var(--ink-muted);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
}

.beat-engine {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.95rem;
  padding: 1.15rem clamp(1.1rem, 3vw, 2.8rem) 1.35rem;
  border-bottom: 2px solid var(--brass);
  color: var(--bone);
  background:
    radial-gradient(ellipse at 80% 35%, rgba(184, 146, 73, 0.09), transparent 60%),
    linear-gradient(180deg, #16110e 0%, #100c0a 100%);
}

.beat-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}

.beat-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.65rem;
}

.beat-engine h3 {
  margin: 0;
  color: var(--parchment-light);
  font-family: var(--serif-display);
  font-size: clamp(0.95rem, 1.5vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.beat-telemetry {
  padding: 0.16rem 0.5rem;
  border: 1px solid rgba(184, 146, 73, 0.32);
  color: rgba(228, 215, 190, 0.72);
  background: rgba(8, 6, 5, 0.55);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
}

.beat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.beat-button {
  padding: 0.58rem 0.88rem;
  border: 1px solid var(--brass-dim);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55);
  color: var(--parchment-light);
  background: linear-gradient(180deg, rgba(184, 146, 73, 0.13), rgba(14, 10, 9, 0.85));
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.beat-button[aria-pressed="false"] {
  border-color: rgba(184, 146, 73, 0.28);
  color: rgba(228, 215, 190, 0.62);
  background: rgba(12, 9, 8, 0.7);
}

.beat-button[aria-pressed="true"],
.beat-button.is-active {
  border-color: var(--brass-bright);
  color: var(--ebony);
  background: var(--brass-bright);
  box-shadow: 0 0 10px rgba(229, 184, 91, 0.45);
}

.beat-button:not(:disabled):hover {
  border-color: var(--brass-bright);
  color: var(--ink);
  background: var(--brass-bright);
}

.beat-button:disabled {
  cursor: default;
  opacity: 0.38;
}

/* The Bone Forge & Crucible Beat Machine (P10-02, D-090) */
.bone-forge-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin: 0.6rem 0 0.8rem 0;
  padding: 0.45rem 0.8rem;
  border: 1px solid rgba(184, 146, 73, 0.4);
  border-radius: 3px;
  background: linear-gradient(180deg, #18120f 0%, #0e0a08 100%);
  box-shadow: inset 0 1px 0 rgba(184, 146, 73, 0.15), 0 2px 6px rgba(0, 0, 0, 0.45);
  font-family: var(--mono-ledger);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
}

.bone-button {
  padding: 0.4rem 0.7rem;
  font-size: 0.62rem;
}

.bone-telemetry {
  margin-left: auto;
  font-family: var(--mono-ledger);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--brass-bright);
}

/* Parlor mixing console (P5-19): ten strips, VU column beside each fader. */
.mixer-strips {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.35rem;
}

.mixer-strip {
  --level: 0;
  --peak: 0;
  display: grid;
  justify-items: center;
  gap: 0.42rem;
  min-width: 0;
  padding: 0.6rem 0.35rem 0.55rem;
  border: 1px solid rgba(184, 146, 73, 0.34);
  color: rgba(228, 215, 190, 0.82);
  background: linear-gradient(180deg, rgba(31, 23, 19, 0.92) 0%, rgba(14, 10, 9, 0.95) 100%);
  font-family: var(--mono-ledger);
  transition: opacity 150ms ease, border-color 150ms ease;
}

.mixer-strip.is-silent {
  opacity: 0.5;
}

.mixer-strip-label {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  margin: 0;
  color: var(--brass-bright);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-align: center;
}

.mixer-tacet {
  visibility: hidden;
  padding: 0 0.3rem;
  border: 1px solid var(--brass-dim);
  color: var(--brass-bright);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
}

.mixer-strip.is-tacet .mixer-tacet {
  visibility: visible;
}

.mixer-strip.is-tacet .mixer-meter {
  opacity: 0.45;
}

.mixer-strip-source {
  max-width: 100%;
  overflow: hidden;
  color: rgba(228, 215, 190, 0.55);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mixer-fader-bay {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 0.45rem;
  height: 9.5rem;
}

.mixer-meter {
  position: relative;
  width: 0.5rem;
  overflow: hidden;
  border: 1px solid rgba(184, 146, 73, 0.4);
  background: rgba(5, 4, 3, 0.9);
}

/* Verdigris through brass into oxblood, revealed from the bottom by --level. */
.mixer-meter-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--verdigris) 0%, #6f8f5a 55%, var(--brass-bright) 80%, var(--oxblood-bright) 100%);
  clip-path: inset(calc((1 - var(--level)) * 100%) 0 0 0);
}

.mixer-meter-peak {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--parchment-light);
  opacity: calc(var(--peak) * 4);
  transform: translateY(calc(var(--peak) * -9.5rem));
}

.mixer-strip.is-clipping .mixer-meter {
  border-color: var(--oxblood-bright);
  box-shadow: 0 0 6px rgba(138, 42, 54, 0.8);
}

.mixer-fader {
  width: 1.15rem;
  height: 100%;
  margin: 0;
  padding: 0;
  accent-color: var(--brass-bright);
  cursor: pointer;
  writing-mode: vertical-lr;
  direction: rtl;
}

.mixer-db,
.mixer-pan-value {
  color: var(--parchment-light);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.mixer-pan {
  width: 100%;
  max-width: 5rem;
  height: 0.9rem;
  margin: 0;
  accent-color: var(--brass);
  cursor: pointer;
}

.mixer-switches {
  display: flex;
  gap: 0.3rem;
}

.mixer-switch {
  min-width: 1.6rem;
  padding: 0.38rem 0.4rem;
  border: 1px solid var(--brass-dim);
  color: rgba(228, 215, 190, 0.7);
  background: rgba(12, 9, 8, 0.7);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  cursor: pointer;
}

.mixer-switch:hover {
  border-color: var(--brass-bright);
}

.mixer-mute[aria-pressed="true"] {
  border-color: var(--oxblood-bright);
  color: var(--parchment-light);
  background: var(--oxblood);
}

.mixer-solo[aria-pressed="true"] {
  border-color: var(--brass-bright);
  color: var(--ink);
  background: var(--brass-bright);
}

.mixer-fader:focus-visible,
.mixer-pan:focus-visible,
.mixer-switch:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 2px;
}

.mixer-legend {
  margin: 0;
  color: rgba(228, 215, 190, 0.62);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
}

/* Session ledger (P5-20): preset name, preset list, and portable files. */
.session-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.85rem 1.4rem;
  align-items: end;
}

.session-field {
  display: grid;
  gap: 0.38rem;
  min-width: 0;
}

.session-field label,
.session-files-label {
  color: rgba(228, 215, 190, 0.7);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.session-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}

/* Export desk (D-027): groups sit at their natural width and wrap as units. */
.export-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 2.2rem;
}

#session-preset-name,
#session-preset-list {
  flex: 1 1 10rem;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--brass-dim);
  color: var(--parchment-light);
  background: rgba(10, 8, 7, 0.7);
  font-family: var(--mono-ledger);
  font-size: 0.62rem;
}

#session-preset-name::placeholder {
  color: rgba(228, 215, 190, 0.62);
}

#session-preset-name:focus-visible,
#session-preset-list:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 1px;
}

.beat-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.42rem;
}

.beat-grid.is-16-steps {
  grid-template-columns: repeat(16, minmax(0, 1fr));
}

.beat-step {
  display: grid;
  justify-items: center;
  gap: 0.34rem;
  padding: 0.48rem 0.25rem 0.42rem;
  border: 1px solid rgba(184, 146, 73, 0.34);
  color: rgba(228, 215, 190, 0.82);
  background:
    linear-gradient(180deg, rgba(31, 23, 19, 0.92) 0%, rgba(14, 10, 9, 0.95) 100%);
  font-family: var(--mono-ledger);
  transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.beat-step:hover {
  border-color: var(--brass-bright);
}

.beat-step.is-current {
  border-color: var(--brass-bright);
  box-shadow:
    0 0 12px rgba(212, 175, 101, 0.32),
    inset 0 0 0 1px rgba(212, 175, 101, 0.42);
  background:
    linear-gradient(180deg, rgba(107, 31, 40, 0.45) 0%, rgba(28, 20, 16, 0.96) 100%);
  transform: translateY(-1px);
}

.step-index {
  color: rgba(228, 215, 190, 0.62);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
}

.step-pips {
  display: flex;
  gap: 0.22rem;
  align-items: center;
}

.voice-pip {
  width: 0.42rem;
  height: 0.42rem;
  border: 1px solid rgba(184, 146, 73, 0.35);
  border-radius: 50%;
  background: rgba(10, 8, 7, 0.65);
}

.voice-pip[data-level="1"] {
  border-color: var(--brass-bright);
  background: rgba(184, 146, 73, 0.58);
}

.voice-pip[data-level="2"] {
  border-color: #f3dfb6;
  box-shadow: 0 0 5px rgba(212, 175, 101, 0.65);
  background: var(--oxblood);
}

.voice-pip.pip-hat[data-level="2"] {
  background: var(--brass-bright);
}

/* Plate labels change while the band follows the conductor and the
   Fun Machine, so each keeps one fixed line box: ♭ and ♯ fall back to a taller
   font, and a long label truncates instead of wrapping and growing the plate. */
.step-trits,
.beat-step .cell-byte {
  height: 1.3em;
  max-width: 100%;
  overflow: hidden;
  line-height: 1.3em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-trits {
  color: var(--brass-bright);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}

.bass-engine {
  background:
    radial-gradient(ellipse at 22% 40%, rgba(107, 31, 40, 0.18), transparent 62%),
    linear-gradient(180deg, #14100d 0%, #0e0a09 100%);
}

.bass-step .cell-byte {
  color: rgba(228, 215, 190, 0.56);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
}

.bass-step .step-trits {
  font-size: 0.6rem;
}

.bass-step[data-gate="0"] {
  opacity: 0.58;
}

.bass-step[data-accent="1"] .step-trits {
  color: #f4dfba;
  text-shadow: 0 0 6px rgba(212, 175, 101, 0.45);
}

.harmony-engine {
  background:
    radial-gradient(ellipse at 72% 42%, rgba(212, 175, 101, 0.12), transparent 62%),
    linear-gradient(180deg, #17120e 0%, #100b09 100%);
}

.harmony-step .cell-byte {
  color: rgba(228, 215, 190, 0.58);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
}

.harmony-step .step-trits {
  font-size: 0.6rem;
}

.harmony-step[data-gate="0"] {
  opacity: 0.56;
}

.harmony-step[data-gate="2"] .step-trits {
  color: #f4dfba;
  text-shadow: 0 0 6px rgba(212, 175, 101, 0.45);
}

.chime-engine {
  background:
    radial-gradient(ellipse at 32% 45%, rgba(124, 152, 198, 0.14), transparent 62%),
    radial-gradient(ellipse at 78% 45%, rgba(212, 175, 101, 0.11), transparent 58%),
    linear-gradient(180deg, #151214 0%, #0e0b0d 100%);
}

.chime-step {
  position: relative;
  overflow: hidden;
}

.chime-step::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--codel-color, rgba(212, 175, 101, 0.45));
  opacity: 0.88;
}

.chime-step .cell-byte {
  color: rgba(228, 215, 190, 0.62);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
}

.chime-step .step-trits {
  font-size: 0.6rem;
}

.chime-step[data-gate="0"] {
  opacity: 0.55;
}

.chime-step[data-gate="2"] .step-trits {
  color: #f4dfba;
  text-shadow: 0 0 6px rgba(212, 175, 101, 0.48);
}

.chant-engine {
  background:
    radial-gradient(ellipse at 25% 45%, rgba(148, 52, 66, 0.18), transparent 62%),
    radial-gradient(ellipse at 82% 45%, rgba(184, 146, 73, 0.12), transparent 58%),
    linear-gradient(180deg, #171012 0%, #0f0a0b 100%);
}

.chant-step .cell-byte {
  color: rgba(228, 215, 190, 0.6);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
}

.chant-step .step-trits {
  font-size: 0.6rem;
}

.chant-step[data-gate="0"] {
  opacity: 0.55;
}

.chant-step[data-gate="2"] .step-trits {
  color: #f4dfba;
  text-shadow: 0 0 6px rgba(212, 175, 101, 0.48);
}

.bandstand-engine {
  padding-bottom: 0.9rem;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(212, 175, 101, 0.14), transparent 70%),
    linear-gradient(180deg, #1b1410 0%, #120d0b 100%);
}

.kapellmeister-engine {
  padding-bottom: 1.1rem;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(184, 146, 73, 0.12), transparent 70%),
    linear-gradient(180deg, #1d1511 0%, #130e0b 100%);
  border-top: 1px solid #4a3822;
}

.kapellmeister-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem 0.75rem;
  width: 100%;
  min-width: 0;
}

.kapellmeister-group {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(184, 146, 73, 0.25);
  background: rgba(14, 10, 8, 0.55);
}

.kapellmeister-group-rulebook {
  border-color: rgba(184, 146, 73, 0.35);
}

.kapellmeister-group-tuning {
  border-color: rgba(184, 146, 73, 0.25);
  background: rgba(10, 8, 6, 0.75);
}

/* The Fun Machine's telemetry narrates every held key and progression, so
   it takes its own line, never widens the row, and always reserves two lines. */
#fun-machine-telemetry {
  box-sizing: content-box;
  display: -webkit-box;
  flex: 1 0 100%;
  height: 3.2em;
  overflow: hidden;
  contain: inline-size;
  line-height: 1.6em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

@media (max-width: 480px) {
  #fun-machine-telemetry {
    height: 4.8em;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }
}

/* Genre titles and telemetry change length with the rulebook, so the
   Kapellmeister header reserves fixed line boxes: the title always reserves two lines,
   the telemetry stays on one, and switching genres never shifts the controls. */
.kapellmeister-engine .beat-header {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.kapellmeister-engine .beat-identity {
  width: 100%;
  min-width: 0;
}

.kapellmeister-engine .beat-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.45rem 1rem;
}

#kapellmeister-heading {
  display: -webkit-box;
  height: 2.5em;
  overflow: hidden;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

#fun-machine-heading {
  height: 1.25em;
  overflow: hidden;
  line-height: 1.25;
}

/* Fixed line box: ♭ and ♯ fall back to a font with a taller one. */
#kapellmeister-telemetry {
  box-sizing: content-box;
  height: 1.6em;
  line-height: 1.6em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A genre's motto from src/rulebooks.ni. Mottos differ in length, so the
   line always reserves three lines and switching genres never shifts the page. */
.kapellmeister-motto {
  display: -webkit-box;
  height: 4.2em;
  margin: 0.45rem 0 0;
  overflow: hidden;
  color: rgba(228, 215, 190, 0.78);
  font-family: var(--serif-display);
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

/* One fixed line, so naming more moves never moves the layout. */
.kapellmeister-variation {
  height: 1.4em;
  margin: 0.2rem 0 0;
  overflow: hidden;
  color: var(--brass-bright);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kapellmeister-as-written {
  flex: none;
}

.kapellmeister-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
}

.kapellmeister-label {
  font-family: var(--mono-ledger);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--brass-bright);
}

.kapellmeister-select {
  min-width: 0;
  max-width: 100%;
  padding: 0.45rem 0.85rem;
  border: 1.5px solid var(--brass);
  background: #17110e;
  color: var(--parchment-light);
  font-family: var(--serif-display);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 2px;
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.kapellmeister-select:focus {
  outline: 0;
  border-color: var(--brass-bright);
  box-shadow: 0 0 6px rgba(218, 181, 107, 0.45);
}

.kapellmeister-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  padding: 0.35rem 0 0.5rem;
}

.kapellmeister-readout {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  padding: 0.65rem 0.95rem;
  border: 1.5px solid #5a4325;
  background: #15100d;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55);
}

.readout-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.readout-label {
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--brass-bright);
  text-transform: uppercase;
}

/* Values change every step and some wrap on narrow screens ("G = 9
   (Dissonant)"), so each always reserves two lines and the readout never
   changes height mid-loop. */
.readout-value {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.5em;
  overflow: hidden;
  margin-top: 0.2rem;
  font-family: var(--serif-display);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  color: #faf3e6;
  letter-spacing: 0.04em;
}

.kapellmeister-controls {
  display: grid;
  gap: 0.45rem;
}

.kapellmeister-compass {
  border: 1.5px solid #4a3822;
  background: #110d0b;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
  padding: 0.25rem 0.5rem;
}

/* The compass's four regions are equal columns. A region's chord label
   (from the genre's changes, as long as "Phrygian Inflection") wraps within
   its column and always reserves two lines, so labels never collide and the
   compass never changes height. */
.tonnetz-compass {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0.35rem 0 0.2rem;
  list-style: none;
}

.tonnetz-compass::before {
  content: "";
  position: absolute;
  top: calc(0.35rem + 21px);
  left: 12.5%;
  right: 12.5%;
  border-top: 1.5px dashed #8d6b32;
}

.compass-region {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.2rem;
  min-width: 0;
}

.tonnetz-glyph {
  display: block;
  width: 42px;
  height: 42px;
  overflow: visible;
}

.tonnetz-tri {
  fill: #1d1611;
  stroke: #72552a;
  stroke-width: 1.5;
  transition: fill 140ms ease, stroke 140ms ease;
}

.tonnetz-node-circle {
  fill: #17110e;
  stroke: #8d6b32;
  stroke-width: 1.5;
  transition: fill 140ms ease, stroke 140ms ease;
}

.tonnetz-node-numeral {
  fill: #cbb490;
  font-family: var(--serif-display);
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.tonnetz-node-text {
  display: -webkit-box;
  max-width: 100%;
  height: 2.6em;
  overflow: hidden;
  color: #cbb490;
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.3em;
  text-align: center;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

@media (max-width: 400px) {
  .tonnetz-compass {
    gap: 0.25rem;
  }

  .tonnetz-node-text {
    font-size: 0.6rem;
    letter-spacing: -0.02em;
  }
}

.compass-region.is-active .tonnetz-tri {
  fill: rgba(184, 146, 73, 0.28);
  stroke: var(--brass-bright);
  filter: drop-shadow(0 0 4px rgba(218, 181, 107, 0.45));
}

.compass-region.is-active .tonnetz-node-circle {
  fill: var(--oxblood-bright);
  stroke: var(--brass-bright);
}

.compass-region.is-active .tonnetz-node-numeral,
.compass-region.is-active .tonnetz-node-text {
  fill: #faf3e6;
  color: #faf3e6;
}

.parlor-acoustics-engine {
  padding-bottom: 1.1rem;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(139, 46, 56, 0.12), transparent 70%),
    linear-gradient(180deg, #18120f 0%, #110d0b 100%);
  border-top: 1px solid #4a3822;
}

.acoustics-body {
  display: grid;
  gap: 0.5rem;
  padding: 0.35rem 0 0.5rem;
}

.acoustics-indicators {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}

.acoustics-chip {
  cursor: pointer;
  user-select: none;
  padding: 0.35rem 0.75rem;
  border: 1px solid #523e25;
  background: #16110e;
  color: #a89478;
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 2px;
  transition: all 150ms ease;
  line-height: normal;
}

.acoustics-chip:hover {
  border-color: #8c6a3e;
  color: #d8c2a4;
  background: #1f1813;
}

.acoustics-chip.is-active {
  border-color: var(--brass-bright);
  color: var(--brass-bright);
  background: rgba(184, 146, 73, 0.15);
  box-shadow: 0 0 6px rgba(184, 146, 73, 0.28);
}

/* ==========================================================================
   The Whimsy Machine One-Finger Accompanist (Baldwin Real-Time Chord Organ)
   ========================================================================== */

.fun-machine-engine {
  gap: 0.5rem;
  padding-bottom: 1.25rem;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(212, 175, 101, 0.12), transparent 70%),
    linear-gradient(180deg, #1c1410 0%, #110d0a 100%);
  border-top: 1px solid #4a3822;
}

.fun-machine-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.25rem 0 0.5rem;
}

.fun-quality-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.45rem 0.8rem;
  background: #15100d;
  border: 1.5px solid #4a3822;
  border-radius: 2px;
}

.fun-quality-label {
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--brass-bright);
  letter-spacing: 0.12em;
}

.fun-style-hint {
  margin-left: auto;
  color: rgba(228, 215, 190, 0.55);
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
}

.fun-quality-chips {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.fun-chip {
  cursor: pointer;
  user-select: none;
  padding: 0.28rem 0.65rem;
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: #211812;
  color: #c9b493;
  border: 1px solid #543f25;
  border-radius: 2px;
  transition: all 120ms ease;
  line-height: normal;
}

.fun-chip:hover {
  background: #2f2115;
  border-color: #8f6a39;
  color: #f1dfc4;
}

.fun-chip.is-active {
  background: #3d2b17;
  color: #fff1d6;
  border-color: var(--brass-bright);
  box-shadow: 0 0 6px rgba(218, 181, 107, 0.4);
}

.fun-octave-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.fun-octave-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.fun-octave-button {
  padding: 0.2rem 0.5rem;
  font-family: var(--mono-ledger);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.fun-octave-display {
  display: inline-block;
  font-family: var(--mono-ledger);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--brass-bright);
  padding: 0.2rem 0.5rem;
  background: #150f0b;
  border: 1px solid #543f25;
  border-radius: 2px;
  min-width: 145px;
  text-align: center;
}

.fun-keyboard-wrap {
  padding: 0.75rem 0.85rem 0.95rem;
  background: #0d0907;
  border: 1.5px solid #5a4325;
  border-radius: 4px;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.45);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.fun-keyboard {
  display: flex;
  position: relative;
  height: 145px;
  width: 100%;
  max-width: 940px;
  min-width: 620px;
  margin: 0 auto;
  user-select: none;
}

.fun-key {
  cursor: pointer;
  outline: none;
  box-sizing: border-box;
  touch-action: manipulation;
  transition: transform 60ms ease, background 80ms ease, box-shadow 60ms ease;
}

.fun-key-white {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  height: 100%;
  background: linear-gradient(180deg, #efe6d7 0%, #dcceaf 72%, #c9b78e 100%);
  border: 1px solid #755f38;
  border-bottom: 5px solid #4a3820;
  border-radius: 0 0 4px 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 1px 2px 4px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 0.45rem;
  gap: 0.1rem;
}

.fun-key-white.is-pressed,
.fun-key-white:active {
  transform: translateY(2px);
  background: linear-gradient(180deg, #d8c49e 0%, #c4af82 100%);
  border-bottom-width: 3px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
}

.fun-key-black {
  position: absolute;
  top: 0;
  width: 4.2%;
  height: 60%;
  z-index: 2;
  background: linear-gradient(180deg, #2a211b 0%, #17120f 65%, #080605 100%);
  border: 1px solid #453422;
  border-bottom: 4px solid #241b12;
  border-radius: 0 0 3px 3px;
  box-shadow: 2px 3px 6px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 0.3rem;
  gap: 0.05rem;
}

.fun-key-black[data-semitone="1"]  { left: 4.57%; }
.fun-key-black[data-semitone="3"]  { left: 11.23%; }
.fun-key-black[data-semitone="6"]  { left: 24.57%; }
.fun-key-black[data-semitone="8"]  { left: 31.23%; }
.fun-key-black[data-semitone="10"] { left: 37.90%; }
.fun-key-black[data-semitone="13"] { left: 51.23%; }
.fun-key-black[data-semitone="15"] { left: 57.90%; }
.fun-key-black[data-semitone="18"] { left: 71.23%; }
.fun-key-black[data-semitone="20"] { left: 77.90%; }
.fun-key-black[data-semitone="22"] { left: 84.57%; }

.fun-key-black.is-pressed,
.fun-key-black:active {
  transform: translateY(2px);
  background: linear-gradient(180deg, #3d2f23 0%, #1e150f 100%);
  border-bottom-width: 2px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.fun-key-white .fun-key-note {
  font-family: var(--serif-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: #1a120c;
  line-height: 1;
}

.fun-key-white .fun-key-shortcut {
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  color: #72562b;
}

.fun-key-white .fun-key-chord {
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  color: #8c6832;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 95%;
}

.fun-key-black .fun-key-note {
  font-family: var(--serif-display);
  font-size: 0.65rem;
  font-weight: 700;
  color: #f7eedf;
  line-height: 1;
}

.fun-key-black .fun-key-shortcut {
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  color: #d4af65;
}

.fun-key-black .fun-key-chord {
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
  font-weight: 700;
  color: #ffd875;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 95%;
}
  max-width: 95%;
}

footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  min-height: 3.75rem;
  padding: 0.8rem clamp(1.1rem, 3vw, 2.8rem);
  color: rgba(228, 215, 190, 0.82);
  background: #110d0b;
  font-family: var(--mono-ledger);
  font-size: 0.6rem;
}

footer > span:first-child {
  justify-self: start;
}

.footer-links {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.55rem;
  justify-self: end;
}

footer a {
  color: var(--brass-bright);
  text-underline-offset: 0.25em;
}

footer a:hover {
  color: var(--parchment-light);
}

#status {
  padding: 0.25rem 0.65rem;
  border: 1px solid rgba(184, 146, 73, 0.32);
  color: var(--brass-bright);
  background: rgba(25, 19, 16, 0.9);
}

noscript {
  position: fixed;
  inset: auto 1rem 1rem;
  z-index: 70;
  padding: 1rem;
  border: 2px solid var(--brass);
  color: var(--bone);
  background: var(--ebony);
}

@media (max-width: 900px) {
  .reading {
    grid-template-columns: minmax(0, 1fr);
  }

  .score-card {
    grid-template-columns: repeat(5, auto);
    justify-content: start;
  }

  footer {
    grid-template-columns: 1fr auto;
  }

  footer > span:first-child {
    grid-column: 1 / -1;
  }

  .footer-links {
    justify-content: flex-end;
  }
}

@media (max-width: 620px) {
  body {
    padding: 0;
    background: var(--parchment);
  }

  .oracle-cabinet {
    min-height: 100vh;
    border-width: 0;
    outline: 0;
    box-shadow: none;
  }

  .cabinet-corner,
  .folio,
  .form-foot span,
  footer span:first-child {
    display: none;
  }

  .masthead {
    grid-template-columns: 1fr auto;
  }

  .wordmark {
    justify-self: start;
    font-size: 0.78rem;
    letter-spacing: 0.09em;
  }

  .wordmark .prompt-mark:last-child {
    display: none;
  }

  .oracle-shell {
    padding-top: 2.2rem;
  }

  h1 {
    font-size: clamp(2.2rem, 11vw, 3.8rem);
  }

  .dek br {
    display: none;
  }

  .vision-stage {
    height: 24rem;
    border-radius: 40% 40% 0.65rem 0.65rem / 10% 10% 0.65rem 0.65rem;
  }

  .stage-marker {
    top: 13%;
    font-size: 0.6rem;
  }

  .stage-marker-left {
    left: 1.15rem;
  }

  .stage-marker-right {
    right: 1.15rem;
  }

  .stage-caption {
    right: 0.85rem;
    left: 0.85rem;
    max-width: calc(100% - 1.7rem);
    padding: 0.3rem 0.55rem;
    font-size: 0.6rem;
    line-height: 1.4;
  }

  .theremin-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .bone-forge-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .bone-telemetry {
    margin-left: 0;
    text-align: center;
    padding-top: 0.2rem;
  }

  .theremin-readout {
    margin-left: 0;
    text-align: center;
    padding-top: 0.2rem;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  #phrase {
    min-height: 3.8rem;
  }

  .summon-button {
    min-height: 3.4rem;
    border-top: 2px solid var(--ebony);
    border-left: 0;
  }

  .form-foot {
    justify-content: center;
  }

  .score-card {
    grid-template-columns: repeat(2, 1fr);
  }

  .volume-control {
    width: 100%;
    grid-auto-columns: minmax(0, 1fr);
  }

  .kapellmeister-readout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fun-machine-body,
  .kapellmeister-body {
    padding-inline: 0;
  }

  .wing-dek {
    letter-spacing: 0.1em;
  }

  .beat-grid,
  .looper-steps {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .beat-grid.is-16-steps,
  .looper-steps.is-16-steps {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .mixer-strips {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  footer {
    grid-template-columns: 1fr auto;
  }
}

/* After the 620px block so the rail wins on the narrowest phones. */
@media (max-width: 480px) {
  /* A scrolling rail of fixed-width strips, like a hardware console. */
  .mixer-strips {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 5.4rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    scroll-snap-type: x proximity;
  }

  .mixer-strip {
    scroll-snap-align: start;
  }
  /* Transport keys pair up so the rail stays one thumb-reach tall. */
  .transport-keys {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .transport-button {
    justify-content: center;
    height: 100%;
    padding-inline: 0.6rem;
    white-space: normal;
  }

  .transport-position,
  .transport-section {
    grid-column: 1 / -1;
    text-align: center;
  }
}

/* Korg R3-inspired unified hardware performance console (D-056).
   Every tier spans horizontally across the instrument chassis with unhurried
   breathing room, tactile hardware framing, and immediate playability. */
@media (min-width: 1180px) {
  .oracle-cabinet {
    width: min(94rem, 100%);
    box-shadow:
      0 0 0 6px var(--ebony),
      0 0 0 9px rgba(184, 146, 73, 0.45),
      0 30px 80px rgba(0, 0, 0, 0.92);
  }

  /* In keep drawer, display active segmented deck panel cleanly */
  .wing-keep:not([hidden]) {
    display: block;
    padding: 1.2rem clamp(1.1rem, 3vw, 2.8rem);
  }

  .wing-keep .beat-engine[hidden] {
    display: none !important;
  }

  #session-engine,
  #export-engine,
  #studio-engine,
  #herbarium-engine {
    border: 1.5px solid var(--brass-dim);
    margin-top: 0.65rem;
  }
}

/* Keep Wing Segmented Decks & Export Format Grid (P8-16, D-082) */
.keep-deck-nav {
  margin: 0.5rem 0 0.85rem;
  padding: 0;
}

.keep-deck-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  border-bottom: 2px solid var(--brass-dim);
  padding-bottom: 0.5rem;
}

.keep-deck-tab {
  background: rgba(22, 17, 13, 0.85);
  border: 1px solid var(--brass-dim);
  color: var(--parchment-deep);
  font-family: var(--mono-ledger);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.keep-deck-tab:hover {
  color: var(--parchment-light);
  border-color: var(--brass);
}

.keep-deck-tab.is-active,
.keep-deck-tab[aria-selected="true"] {
  background: var(--brass-dim);
  color: #120e0a;
  border-color: var(--brass-bright);
}

.export-format-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  width: 100%;
}

.export-format-cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.export-sublabel {
  font-family: var(--mono-ledger);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--brass-bright);
  text-transform: uppercase;
}

@media (max-width: 600px) {
  .export-format-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Under the Parlor Glass: Interactive Esoteric VM Step Inspector (P5-34, D-069) */
.vm-inspector {
  margin-top: 0.65rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--brass-dim);
  background: rgba(10, 8, 6, 0.76);
  display: grid;
  gap: 0.25rem;
  font-family: var(--mono-ledger);
  font-variant-numeric: tabular-nums;
}

.vm-inspector[hidden] {
  display: none !important;
}

.vm-inspector-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.vm-inspector-label {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--brass);
}

.vm-inspector-headline {
  font-size: 0.68rem;
  color: var(--parchment-deep);
}

.vm-inspector-registers,
.vm-inspector-detail {
  display: block;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--parchment);
  white-space: nowrap;
  overflow-x: auto;
}

.inspector-toggle[aria-expanded="true"] {
  border-color: var(--brass-bright);
  background: rgba(184, 146, 73, 0.2);
}

/* The Naturalist's Herbarium: Cabinet Curio Gallery (P5-35, D-070) */
.herbarium-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
  max-height: 15rem;
  overflow-y: auto;
}

.herbarium-empty {
  font-family: var(--mono-ledger);
  font-size: 0.7rem;
  color: var(--parchment-deep);
  padding: 0.4rem 0;
}

.herbarium-card {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.55rem;
  align-items: center;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--brass-dim);
  background: rgba(12, 9, 7, 0.78);
}

.herbarium-miniature {
  width: 3.2rem;
  height: 3.2rem;
  border: 1px solid var(--brass-dim);
  background: radial-gradient(circle, rgba(28, 22, 16, 0.9), rgba(8, 6, 4, 0.98));
  display: block;
}

.herbarium-card-meta {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.herbarium-card-name {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--parchment);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.herbarium-card-phrase {
  font-family: var(--mono-ledger);
  font-size: 0.65rem;
  color: var(--parchment-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.herbarium-card-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.herbarium-comparison {
  margin-top: 0.4rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--brass-dim);
  background: rgba(10, 8, 6, 0.82);
  font-family: var(--mono-ledger);
  font-size: 0.68rem;
  color: var(--parchment-deep);
  display: grid;
  gap: 0.25rem;
}

.herbarium-comparison[hidden] {
  display: none !important;
}

.herbarium-compare-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 1fr;
  gap: 0.5rem;
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(184, 146, 73, 0.16);
}

.herbarium-compare-label {
  color: var(--brass);
}

.herbarium-compare-row.is-match {
  color: var(--parchment-light);
  font-weight: 600;
}

/* Custom Rulebook Sandbox ("The Kapellmeister's Manuscript", P5-36, D-071) */
.kapellmeister-manuscript {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--brass-dim);
  background: rgba(10, 8, 6, 0.85);
  display: grid;
  gap: 0.45rem;
}

.kapellmeister-manuscript[hidden] {
  display: none !important;
}

.manuscript-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.manuscript-title {
  font-family: var(--mono-ledger);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--brass-bright);
}

.manuscript-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.manuscript-textarea {
  width: 100%;
  min-height: 10.5rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--brass);
  background: rgba(14, 11, 9, 0.96);
  color: var(--parchment-light);
  caret-color: var(--brass-bright);
  font-family: var(--mono-ledger);
  font-size: 0.78rem;
  line-height: 1.5;
  resize: vertical;
}

.manuscript-textarea:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 2px;
  border-color: var(--brass-bright);
}

.manuscript-diagnostic {
  font-family: var(--mono-ledger);
  font-size: 0.7rem;
  color: var(--parchment-light);
  padding: 0.25rem 0.4rem;
  border-left: 2px solid var(--brass);
  background: rgba(184, 146, 73, 0.12);
}

.manuscript-diagnostic.is-error {
  border-left-color: #d96b52;
  color: #f3b5a4;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
