:root {
  --deep: #101c29;
  --deep-2: #0b151f;
  --ink: #16232d;
  --ink-soft: #43545c;
  --muted: #7d8b8e;
  --paper: #f3eee4;
  --paper-2: #e8e0d2;
  --cyan: #5ee0cb;
  --amber: #ffba66;
  --coral: #ff8371;
  --line-dark: rgba(244, 239, 228, 0.13);
  --line-dark-soft: rgba(244, 239, 228, 0.07);
  --line-paper: rgba(22, 35, 45, 0.15);
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", Georgia, serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--deep-2);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(1100px 760px at 86% -12%, rgba(94, 224, 203, 0.12), transparent 63%),
    radial-gradient(900px 700px at -8% 110%, rgba(255, 186, 102, 0.075), transparent 58%),
    linear-gradient(135deg, #0b151f 0%, #0d1923 48%, #0a141d 100%);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    linear-gradient(rgba(94, 224, 203, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94, 224, 203, 0.028) 1px, transparent 1px);
  background-size: 54px 54px;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 72%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 72%);
}

::selection {
  color: var(--ink);
  background: var(--cyan);
}

button,
input {
  font: inherit;
}

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

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

button:focus-visible,
input:focus-visible {
  outline-color: var(--ink);
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 22px clamp(20px, 3.8vw, 58px) 18px;
}

/* Masthead */
.masthead {
  position: relative;
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line-dark);
}

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

.brand-mark {
  position: relative;
  display: block;
  width: 35px;
  height: 35px;
  flex: 0 0 35px;
  border: 1px solid rgba(94, 224, 203, 0.55);
  background:
    radial-gradient(circle at 50% 50%, var(--cyan) 0 1.5px, transparent 2px),
    linear-gradient(135deg, rgba(94, 224, 203, 0.09), rgba(255, 186, 102, 0.02));
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 8px 5px;
  border: 1px solid rgba(94, 224, 203, 0.68);
  border-radius: 50%;
  transform: rotate(-34deg);
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: -9px 20px 0 -1px rgba(255, 131, 113, 0.9);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-copy b {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.2em;
}

.topline-note {
  display: flex;
  align-items: center;
  gap: 18px;
  color: rgba(244, 239, 228, 0.5);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.topline-note span + span {
  position: relative;
  padding-left: 18px;
}

.topline-note span + span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 10px;
  background: var(--line-dark);
  transform: translateY(-50%);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  align-items: end;
  gap: clamp(26px, 5vw, 82px);
  padding: clamp(18px, 2.5vw, 29px) 0 clamp(20px, 2.6vw, 30px);
}

.hero-title {
  min-width: 0;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.17em;
}

.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  flex: 0 0 28px;
  background: var(--cyan);
}

h1 {
  margin: 10px 0 0;
  color: var(--paper);
  font-family: var(--serif);
  font-size: clamp(43px, 4.55vw, 78px);
  font-weight: 600;
  line-height: 1.01;
  letter-spacing: 0.015em;
  text-wrap: balance;
}

h1 span,
h1 em {
  display: block;
}

h1 em {
  position: relative;
  color: var(--cyan);
  font-style: normal;
}

h1 em::after {
  content: "";
  position: absolute;
  right: 0.04em;
  bottom: 0.13em;
  width: 0.13em;
  height: 0.13em;
  border-radius: 50%;
  background: var(--coral);
}

.hero-aside {
  max-width: 402px;
  padding: 2px 0 7px clamp(17px, 2vw, 27px);
  border-left: 1px solid var(--line-dark);
}

.hero-quote {
  margin: 0 0 12px;
  color: rgba(244, 239, 228, 0.82);
  font-family: var(--serif);
  font-size: clamp(15px, 1.25vw, 18px);
  line-height: 1.72;
  letter-spacing: 0.01em;
}

.deck {
  margin: 0;
  color: rgba(244, 239, 228, 0.5);
  font-size: 11.5px;
  line-height: 1.86;
}

/* Chapter navigation */
.chapter-nav {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 18px;
  border-top: 1px solid var(--line-dark);
  border-bottom: 1px solid var(--line-dark);
}

.chapter-tab {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
  padding: 11px 14px 10px;
  color: rgba(244, 239, 228, 0.5);
  text-decoration: none;
  border-right: 1px solid var(--line-dark);
  transition: color 160ms ease, background-color 160ms ease;
}

.chapter-tab:last-child {
  border-right: 0;
}

.chapter-tab:hover {
  color: var(--paper);
  background: rgba(244, 239, 228, 0.035);
}

.chapter-tab.is-active {
  color: var(--paper);
  background: rgba(94, 224, 203, 0.072);
}

.chapter-tab.is-active::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  background: var(--cyan);
}

.tab-num {
  color: rgba(244, 239, 228, 0.34);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.15em;
  transition: color 160ms ease;
}

.chapter-tab.is-active .tab-num {
  color: var(--amber);
}

.tab-name {
  overflow: hidden;
  font-family: var(--serif);
  font-size: clamp(13px, 1.02vw, 16px);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main stage */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(308px, 364px);
  align-items: stretch;
  gap: 18px;
}

.visual-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--deep);
  border: 1px solid rgba(94, 224, 203, 0.16);
  border-radius: 2px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.27);
}

.visual-head {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 20px;
  background: linear-gradient(90deg, rgba(94, 224, 203, 0.04), transparent 45%);
  border-bottom: 1px solid var(--line-dark-soft);
}

.visual-heading {
  min-width: 0;
}

.chapter-kicker {
  display: block;
  overflow: hidden;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visual-head h2 {
  overflow: hidden;
  margin: 3px 0 0;
  color: var(--paper);
  font-family: var(--serif);
  font-size: clamp(18px, 1.5vw, 23px);
  font-weight: 600;
  letter-spacing: 0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visual-meta {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 15px;
}

.page-meta {
  color: rgba(244, 239, 228, 0.44);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.folio {
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding-left: 14px;
  border-left: 1px solid var(--line-dark);
  font-family: var(--serif);
  line-height: 1;
  white-space: nowrap;
}

.folio-current {
  color: var(--cyan);
  font-size: 25px;
  font-variant-numeric: tabular-nums;
}

.folio-slash,
.folio-total {
  color: rgba(244, 239, 228, 0.38);
  font-family: var(--mono);
  font-size: 9px;
}

.folio-unit {
  margin-left: 3px;
  color: rgba(244, 239, 228, 0.32);
  font-family: var(--sans);
  font-size: 8.5px;
  letter-spacing: 0.08em;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: clamp(360px, 44vh, 510px);
  min-height: 360px;
  flex: 0 0 auto;
  overflow: hidden;
  background: var(--deep);
}

#stageCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: 2;
  pointer-events: none;
  border: 1px solid rgba(244, 239, 228, 0.052);
}

/* Readout */
.readout {
  min-height: 102px;
  padding: 13px clamp(16px, 1.8vw, 22px) 14px;
  color: var(--ink);
  background: var(--paper);
  border-top: 1px solid rgba(16, 28, 41, 0.1);
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 7px 28px;
}

.metric {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  color: #788387;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.35;
}

.metric-value {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
  white-space: nowrap;
}

.metric-value .mono,
.mono {
  font-family: var(--mono);
}

.accent-cyan {
  color: #0b7e71 !important;
}

.accent-amber {
  color: #9b5e0d !important;
}

.accent-coral {
  color: #bd4d41 !important;
}

.formula {
  margin-top: 8px;
  padding: 6px 9px;
  overflow-wrap: anywhere;
  color: #304148;
  background: rgba(16, 28, 41, 0.045);
  border-left: 2px solid var(--amber);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.62;
  white-space: normal;
}

.formula strong {
  color: var(--ink);
  font-weight: 700;
}

.note {
  margin: 6px 0 0;
  color: #667479;
  font-size: 11px;
  line-height: 1.62;
}

.note strong {
  color: var(--ink);
  font-weight: 700;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 3px;
  padding: 1px 5px;
  color: #805211;
  background: rgba(255, 186, 102, 0.22);
  border-radius: 2px;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  vertical-align: 1px;
}

.tag.cyan {
  color: #0c7267;
  background: rgba(94, 224, 203, 0.2);
}

.tag.coral {
  color: #a94338;
  background: rgba(255, 131, 113, 0.16);
}

/* Control desk */
.control-card {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 17px 12px;
  color: var(--ink);
  background: var(--paper);
  border-radius: 2px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.control-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--amber), rgba(255, 186, 102, 0.18) 62%, transparent);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-paper);
}

.panel-kicker {
  display: block;
  color: #7a8588;
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.15em;
}

.panel-head h3 {
  margin: 3px 0 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.015em;
}

.panel-index {
  color: rgba(16, 28, 41, 0.16);
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 600;
  line-height: 0.85;
  font-variant-numeric: tabular-nums;
}

.hint-block {
  margin-top: 11px;
  padding-left: 11px;
  border-left: 2px solid var(--amber);
}

.hint-label {
  display: block;
  color: #7a8589;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

#chapterHint {
  margin: 4px 0 0;
  color: #384950;
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.55;
}

.transport {
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr) auto;
  gap: 7px;
  margin-top: 12px;
}

.transport-btn {
  display: flex;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-paper);
  border-radius: 2px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.transport-btn:hover:not(:disabled) {
  background: #eae3d6;
  border-color: rgba(22, 35, 45, 0.31);
}

.transport-btn:disabled {
  cursor: default;
  opacity: 0.3;
}

.transport-btn .arrow {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1;
}

.play-btn {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
}

.play-btn:hover:not(:disabled) {
  background: #263945;
  border-color: #263945;
}

.play-btn.is-playing {
  color: var(--ink);
  background: var(--amber);
  border-color: var(--amber);
}

.play-btn.is-playing:hover:not(:disabled) {
  background: #ffc77d;
  border-color: #ffc77d;
}

.transport-icon {
  color: var(--amber);
  font-size: 9px;
}

.play-btn.is-playing .transport-icon {
  color: var(--ink);
}

.utility-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 7px;
}

.utility-btn {
  height: 30px;
  padding: 0 8px;
  color: #5a696f;
  background: transparent;
  border: 1px solid rgba(22, 35, 45, 0.13);
  border-radius: 2px;
  font-size: 10px;
  letter-spacing: 0.015em;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.utility-btn:hover {
  color: var(--ink);
  background: #eee7da;
  border-color: rgba(22, 35, 45, 0.28);
}

.preset-section {
  margin-top: 13px;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: #7d878a;
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.preset-btn {
  padding: 4px 9px;
  color: #526269;
  background: transparent;
  border: 1px solid rgba(22, 35, 45, 0.16);
  border-radius: 999px;
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.preset-btn:hover {
  color: var(--ink);
  border-color: rgba(22, 35, 45, 0.42);
}

.preset-btn.is-active {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

.controls {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.control-row {
  min-width: 0;
}

.control-top {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}

.control-row label {
  overflow: hidden;
  color: #46565d;
  font-size: 10.5px;
  letter-spacing: 0.01em;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.control-row output {
  min-width: 43px;
  padding: 2px 6px;
  color: var(--ink);
  background: #e8e0d2;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-align: center;
}

.control-row input[type="range"] {
  display: block;
  width: 100%;
  height: 16px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.control-row input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    #273842 0%,
    #273842 var(--pct, 50%),
    rgba(22, 35, 45, 0.16) var(--pct, 50%),
    rgba(22, 35, 45, 0.16) 100%
  );
}

.control-row input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -5px;
  background: var(--amber);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
  -webkit-appearance: none;
  appearance: none;
  transition: transform 120ms ease;
}

.control-row input[type="range"]:hover::-webkit-slider-thumb,
.control-row input[type="range"]:focus-visible::-webkit-slider-thumb {
  transform: scale(1.12);
}

.control-row input[type="range"]::-moz-range-track {
  height: 3px;
  border: 0;
  border-radius: 99px;
  background: rgba(22, 35, 45, 0.16);
}

.control-row input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 99px;
  background: #273842;
}

.control-row input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  background: var(--amber);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
}

.control-row input[type="range"]:focus-visible {
  outline: 2px solid rgba(22, 35, 45, 0.55);
  outline-offset: 4px;
}

.shortcut-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 12px;
  padding-top: 9px;
  color: #839094;
  border-top: 1px solid var(--line-paper);
  font-size: 8.5px;
  letter-spacing: 0.015em;
}

.shortcut-row span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 15px;
  padding: 1px 3px;
  color: #516168;
  background: #ede7db;
  border: 1px solid rgba(22, 35, 45, 0.17);
  border-bottom-width: 2px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.35;
  text-align: center;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 13px;
  padding-top: 10px;
  color: rgba(244, 239, 228, 0.31);
  border-top: 1px solid var(--line-dark-soft);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Medium desktop */
@media (max-width: 1120px) and (min-width: 901px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) minmax(292px, 322px);
    gap: 13px;
  }

  .control-card {
    padding-right: 14px;
    padding-left: 14px;
  }

  .transport {
    grid-template-columns: auto minmax(96px, 1fr) auto;
  }

  .transport-btn {
    padding: 0 8px;
  }

  .topline-note span:first-child {
    display: none;
  }
}

/* Short desktop: keep the board and controls in one screen */
@media (min-width: 901px) and (max-height: 850px) {
  .page {
    padding-top: 12px;
  }

  .topline {
    padding-bottom: 8px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
    flex-basis: 31px;
  }

  .brand-copy b {
    font-size: 17px;
  }

  .hero {
    padding: 12px 0 14px;
  }

  h1 {
    margin-top: 7px;
    font-size: clamp(38px, 3.8vw, 58px);
  }

  .hero-quote {
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.58;
  }

  .deck {
    font-size: 10.5px;
    line-height: 1.62;
  }

  .chapter-nav {
    margin-bottom: 12px;
  }

  .chapter-tab {
    padding: 8px 12px 7px;
  }

  .visual-head {
    min-height: 48px;
    padding: 8px 16px;
  }

  .canvas-wrap {
    height: clamp(360px, 42vh, 400px);
  }

  .readout {
    min-height: 0;
    padding: 10px 16px 11px;
  }

  .control-card {
    padding: 12px 14px 9px;
  }

  .panel-head {
    padding-bottom: 8px;
  }

  .panel-head h3 {
    font-size: 18px;
  }

  .panel-index {
    font-size: 29px;
  }

  .hint-block {
    margin-top: 8px;
  }

  #chapterHint {
    font-size: 12px;
    line-height: 1.44;
  }

  .transport {
    margin-top: 9px;
  }

  .transport-btn {
    height: 38px;
  }

  .preset-section {
    margin-top: 9px;
  }

  .preset-btn {
    padding: 3px 8px;
    font-size: 9.5px;
  }

  .controls {
    gap: 7px;
    margin-top: 9px;
  }

  .readout .formula {
    margin-top: 6px;
    padding: 5px 8px;
    font-size: 11px;
  }

  .readout .note {
    margin-top: 4px;
    font-size: 10.5px;
    line-height: 1.5;
  }

  .shortcut-row {
    margin-top: 8px;
    padding-top: 6px;
  }

  .site-footer {
    margin-top: 9px;
    padding-top: 7px;
  }
}

/* Tablet and phone */
@media (max-width: 900px) {
  .page {
    padding: 16px clamp(14px, 4vw, 28px) 22px;
  }

  .topline {
    gap: 14px;
    padding-bottom: 11px;
  }

  .brand-copy b {
    font-size: 18px;
  }

  .topline-note {
    gap: 10px;
    font-size: 8px;
    text-align: right;
  }

  .topline-note span:first-child {
    display: none;
  }

  .topline-note span + span {
    padding-left: 0;
  }

  .topline-note span + span::before {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 17px 0 18px;
  }

  .eyebrow {
    font-size: 8.5px;
    letter-spacing: 0.13em;
  }

  h1 {
    margin-top: 8px;
    font-size: clamp(38px, 8.6vw, 61px);
    line-height: 1.03;
  }

  .hero-aside {
    max-width: 560px;
    padding: 0;
    border-left: 0;
  }

  .hero-quote {
    display: none;
  }

  .deck {
    max-width: 600px;
    font-size: 11px;
    line-height: 1.7;
  }

  .chapter-nav {
    display: flex;
    margin-bottom: 13px;
    overflow-x: auto;
    border-top: 1px solid var(--line-dark);
    border-bottom: 1px solid var(--line-dark);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .chapter-nav::-webkit-scrollbar {
    display: none;
  }

  .chapter-tab {
    flex: 0 0 92px;
    padding: 9px 11px 8px;
  }

  .tab-name {
    font-size: 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .visual-card,
  .control-card {
    width: 100%;
  }

  .visual-head {
    min-height: 52px;
    padding: 9px 13px;
  }

  .visual-head h2 {
    font-size: clamp(17px, 4.4vw, 22px);
  }

  .chapter-kicker {
    font-size: 8px;
  }

  .visual-meta {
    gap: 0;
  }

  .page-meta {
    display: none;
  }

  .folio {
    padding-left: 10px;
  }

  .folio-current {
    font-size: 22px;
  }

  .canvas-wrap {
    height: clamp(360px, 56vh, 460px);
    min-height: 360px;
  }

  .readout {
    min-height: 0;
    padding: 12px 14px 13px;
  }

  .metric-value {
    font-size: 13px;
    white-space: normal;
  }

  .formula {
    font-size: 11px;
  }

  .note {
    font-size: 10.5px;
  }

  .control-card {
    padding: 15px 15px 12px;
  }

  .transport {
    grid-template-columns: auto minmax(104px, 1fr) auto;
  }

  .transport-btn {
    height: 45px;
    font-size: 11px;
  }

  .play-btn {
    font-size: 13.5px;
  }

  .utility-btn {
    height: 35px;
    font-size: 10.5px;
  }

  .control-row label {
    font-size: 11.5px;
  }

  .control-row output {
    min-width: 48px;
    font-size: 11.5px;
  }

  .control-row input[type="range"] {
    height: 22px;
  }

  .control-row input[type="range"]::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    margin-top: -6.5px;
  }

  .control-row input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
  }

  .preset-btn {
    padding: 5px 10px;
    font-size: 10.5px;
  }

  .shortcut-row {
    margin-top: 14px;
    font-size: 9px;
  }

  .site-footer {
    display: none;
  }
}

@media (max-width: 460px) {
  .page {
    padding-right: 12px;
    padding-left: 12px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
    flex-basis: 31px;
  }

  .brand-copy b {
    font-size: 17px;
  }

  .brand-copy small {
    font-size: 7.5px;
  }

  .topline-note {
    max-width: 104px;
    font-size: 7.5px;
    line-height: 1.5;
  }

  h1 {
    font-size: clamp(35px, 9.6vw, 43px);
  }

  .eyebrow {
    font-size: 8px;
  }

  .deck {
    font-size: 10.5px;
  }

  .visual-head {
    align-items: flex-end;
  }

  .visual-head h2 {
    max-width: 235px;
  }

  .canvas-wrap {
    height: 370px;
    min-height: 360px;
  }

  .canvas-wrap::after {
    inset: 7px;
  }

  .metrics {
    gap: 6px 16px;
  }

  .metric-label {
    font-size: 8.5px;
  }

  .metric-value {
    font-size: 12px;
  }

  .formula {
    padding: 5px 8px;
    font-size: 10.5px;
    line-height: 1.58;
  }

  .note {
    font-size: 10px;
    line-height: 1.55;
  }

  .transport-btn {
    padding: 0 7px;
    font-size: 10px;
  }

  .transport {
    grid-template-columns: auto minmax(92px, 1fr) auto;
  }

  .control-card {
    padding-right: 13px;
    padding-left: 13px;
  }

  .panel-head h3 {
    font-size: 19px;
  }

  .shortcut-row {
    gap: 6px 9px;
    font-size: 8.5px;
  }
}

/* Presentation mode */
body.is-presenting .masthead,
body.is-presenting .site-footer {
  display: none;
}

body.is-presenting .page {
  display: flex;
  width: 100%;
  max-width: none;
  min-height: 100vh;
  flex-direction: column;
  padding: 12px clamp(16px, 2.5vw, 38px);
}

body.is-presenting .chapter-nav {
  flex: 0 0 auto;
  margin-bottom: 10px;
}

body.is-presenting .workspace {
  min-height: 0;
  flex: 1 1 auto;
}

body.is-presenting .canvas-wrap {
  height: calc(100vh - 278px);
  min-height: 360px;
}

body.is-presenting .visual-card,
body.is-presenting .control-card {
  min-height: 0;
}

body.is-presenting .control-card {
  overflow-y: auto;
}

@media (max-width: 900px) {
  body.is-presenting .page {
    display: block;
    min-height: 100vh;
    padding: 12px;
    overflow-y: auto;
  }

  body.is-presenting .workspace {
    display: grid;
  }

  body.is-presenting .canvas-wrap {
    height: 62vh;
    min-height: 360px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* The figures use light annotations on a navy field. Keep their numeric
   readouts on the same field and large enough for classroom projection. */
#readout {background: #162634; color: #e3eff0; border-top: 1px solid #314655;}
#readout div, #readout span {font-size: max(14px, .97rem) !important; overflow-wrap: anywhere;}
#readout b {color: #79e6d2;}
.control-card .hint-block p {font-size: 14px;}
.hero-quote {line-height: 1.4;}
