/* The book's visual language, refined for a working geometry laboratory.
   This layer deliberately preserves the scene renderer and chapter catalogue. */

:root {
  --muted: #566d77;
  --surface-border: #d1ddd6;
  --focus-ring: #476f64;
}

.masthead { border-bottom-color: #d5dfd9; }
.brand { letter-spacing: -.35px; }
.intro .eyebrow { letter-spacing: 1.85px; }
.intro > p:last-child { max-width: 78ch; }
.chapter-sidebar > .eyebrow { color: #62786c; }
.chapter-link[aria-current="true"] { box-shadow: inset 3px 0 var(--sage); }
.chapter-link strong { font-weight: 400; }
.chapter-sidebar { max-height: calc(100vh - 36px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-right: 5px; }
.chapter-group { min-width: 0; }
.chapter-group > .chapter-link { width: 100%; }
.chapter-scenes { list-style: none; margin: 3px 0 9px 14px; padding: 0 0 0 12px; border-left: 1px solid #cedbd2; }
.chapter-scenes li { margin: 0; padding: 0; }
.chapter-scenes button { display: block; width: 100%; min-height: 36px; padding: 7px 8px; border: 0; border-radius: 4px; background: transparent; color: #526b62; font: 11px/1.45 var(--sans); text-align: left; cursor: pointer; }
.chapter-scenes button:hover { background: #edf3ed; color: var(--navy); }
.chapter-scenes button[aria-current="page"] { background: #e1ece3; color: #203f56; font-weight: 600; box-shadow: inset 2px 0 #476f64; }
.chapter-scenes button:focus-visible { outline: 2px solid #52796d; outline-offset: 1px; }
.scene-pager button { border-color: #d2dfd5; }
.scene-pager button:disabled { opacity: .48; }
.catalog-content .explorer { border-color: var(--surface-border); }
.figure-heading .eyebrow { color: #526f63; font-weight: 650; }
.catalog-content h2 { text-wrap: balance; letter-spacing: -.45px; }
.figure-caption { color: #526a73; }
.tag { border-color: #d4e0d8; background: #f7faf6; letter-spacing: .2px; }
.canvas-tools button:hover, .canvas-tools select:hover { border-color: #9fb8a8; }
.controls-title h3 { letter-spacing: -.2px; }
.small-number { color: var(--navy); background: #fff; border-color: #bdcfc2; }
.range-ends { color: #647a7b; font-size: 10px; }
.control label { color: var(--ink); }
.control select { border-color: #bfcfc4; }
.control select:hover { border-color: #90ab99; }
.presets button { border-color: #c3d3c8; }
.presets button[aria-pressed="true"] { box-shadow: none; }
.animation-button { border-color: #b4c8b9; background: #f0f5ef; }
.animation-button[aria-pressed="true"] { color: #8c2936; }
.result { border-color: #d4e2d7; border-left-color: var(--sage); background: #edf4ee; }
.result-label { font-weight: 650; letter-spacing: 1.3px; }
.result p { text-wrap: pretty; }
.suggestion p { text-wrap: pretty; }
#reasoning > summary { color: var(--navy); font-weight: 600; }
#reasoning[open] > summary { margin-bottom: 3px; }
#details .math { border-left-width: 3px; border-left-color: #ae874b; }
#steps { padding-left: 20px; }
#steps li { padding-left: 5px; }
#steps li::marker { color: var(--sage); font-weight: 650; }

/* Useful actions stay beside the figure, separate from the camera controls. */
.study-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px 24px;
  min-width: 0;
  margin: 2px 0 13px;
  padding: 11px 0 5px;
}
.study-context { min-width: 0; }
.study-context > span {
  display: block;
  color: var(--sage);
  font: 650 9px/1.5 var(--sans);
  letter-spacing: 1.45px;
}
.study-context p {
  margin: 3px 0 0;
  color: #526a73;
  font: 13px/1.45 var(--serif);
}
.study-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.study-actions button {
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #c7d7cb;
  border-radius: 5px;
  background: #fff;
  color: var(--navy);
  font: 500 11px/1.4 var(--sans);
}
.study-actions button:hover { background: #edf4ee; border-color: #94b09f; }
.study-actions #classroom-mode { border-color: #476f64; color: #365b4e; background: #edf3ee; }
.study-actions #classroom-mode[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.study-actions button:focus-visible,
.parameter-number:focus-visible,
#share-dialog :is(button, input, textarea):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

/* A small, live mathematical reading below the construction. */
.live-insights {
  min-width: 0;
  margin: 4px 0 14px;
  padding: 15px 16px 12px;
  border: 1px solid #d6e2d8;
  border-radius: 6px;
  background: #f6f9f4;
}
.insight-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; }
.insight-heading > span { color: #527064; font: 650 9px/1.5 var(--sans); letter-spacing: 1.15px; }
.insight-heading > strong { color: var(--navy); font: 17px/1.35 var(--serif); }
.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-top: 13px; }
.insight-item { min-width: 0; padding: 0 13px; border-left: 1px solid #dce5dc; }
.insight-item:first-child { padding-left: 0; border-left: 0; }
.insight-item:last-child { padding-right: 0; }
.insight-item > span { display: block; color: #536e73; font: 500 10px/1.45 var(--sans); }
.insight-value { min-width: 0; max-width: 100%; margin: 6px 0 4px; color: var(--navy); font: 19px/1.5 var(--serif); overflow-x: auto; overflow-y: hidden; }
.insight-value .katex-display { margin: 0; padding: 3px 0; text-align: left; }
.insight-value .katex-display > .katex { text-align: left; }
.insight-item[data-tone="sage"] .insight-value { color: #365e4e; }
.insight-item[data-tone="red"] .insight-value { color: #9d3040; }
.insight-item > p { margin: 0; color: #607579; font: 10px/1.55 var(--sans); text-wrap: pretty; }
#insight-note { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid #dce5dc; color: #536d74; font: 12px/1.65 var(--serif); }
#insight-note:empty { display: none; }

/* Direct entry complements the slider, including its native keyboard support. */
.control label .parameter-number {
  flex: 0 0 80px;
  width: 80px;
  min-width: 0;
  min-height: 38px;
  padding: 6px 7px;
  border: 1px solid #bfcec3;
  border-radius: 5px;
  background: #fff;
  color: #365c4e;
  font: 16px/1.35 var(--serif);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.parameter-number:hover { border-color: #86a492; }
.parameter-number[aria-invalid="true"] { border-color: var(--red); background: #fff5f4; }

/* A quiet confirmation and a keyboard-accessible clipboard fallback. */
.action-toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 13px 19px;
  border: 1px solid #557b6b;
  border-radius: 6px;
  color: #fff;
  background: #264f42;
  box-shadow: 0 8px 28px rgba(25, 49, 38, .17);
  font: 13px/1.6 var(--sans);
  text-align: center;
}
#share-dialog {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 26px;
  border: 1px solid #b8ccbe;
  border-radius: 9px;
  background: #fbfcf8;
  color: var(--navy);
  box-shadow: 0 18px 75px rgba(21, 48, 37, .22);
}
#share-dialog::backdrop { background: rgba(26, 48, 45, .38); }
#share-dialog h2 { margin: 0 0 12px; font: 25px/1.2 var(--serif); }
#share-dialog p { color: #536b74; font: 13px/1.7 var(--sans); }
#share-dialog :is(input, textarea) { width: 100%; min-width: 0; padding: 12px; border: 1px solid #bacdbf; border-radius: 5px; background: #fff; color: var(--navy); font: 13px/1.55 var(--sans); }
#share-dialog button { min-height: 44px; padding: 10px 17px; margin-top: 17px; border: 1px solid #476f64; border-radius: 5px; background: #edf3ee; color: #365b4e; font-size: 13px; }
#share-dialog button:hover { background: #dfece2; }

/* Classroom mode is a page layout, so it works offline and on tablets. */
body.classroom-mode { background: #f3f6f0; }
body.classroom-mode :is(.masthead, .intro, .chapter-sidebar, .catalog-toolbar, .scene-nav, .connection-panel, .reading-note, #keyboard-copy, footer, .quick-nav) { display: none !important; }
body.classroom-mode main { max-width: 1880px; padding: 16px 32px 28px; }
body.classroom-mode .catalog-layout { display: block; }
body.classroom-mode .scene-pager { margin: 0; }
body.classroom-mode .study-toolbar { margin-bottom: 15px; padding-top: 13px; }
body.classroom-mode .study-context p { font-size: 15px; }
body.classroom-mode .catalog-content .explorer { grid-template-columns: minmax(0, 1fr) minmax(290px, 340px); }
body.classroom-mode .explorer .visual-column { padding: 25px 30px 0; }
body.classroom-mode .catalog-content .controls-column { padding: 26px; }
body.classroom-mode .catalog-content h2 { font-size: clamp(26px, 2.6vw, 37px); }
body.classroom-mode .catalog-content .canvas-wrap { height: clamp(400px, 57vh, 740px); }
body.classroom-mode .control label { font-size: 14px; }
body.classroom-mode .control select { font-size: 14px; }
body.classroom-mode .result p { font-size: 18px; }
body.classroom-mode .figure-caption { font-size: 14px; }
body.classroom-mode .legend-item { font-size: 12px; }
body.classroom-mode .suggestion p { font-size: 12px; }
body.classroom-mode .insight-heading > strong { font-size: 19px; }
body.classroom-mode .insight-value { font-size: 22px; }
body.classroom-mode .insight-item > span { font-size: 11px; }
body.classroom-mode .insight-item > p { font-size: 11px; }
body.classroom-mode #insight-note { font-size: 13px; }
body.classroom-mode.quick-visible { padding-bottom: 0; }

@media (min-width: 761px) and (max-height: 860px) {
  .explorer:has(.live-insights:not([hidden])) .visual-column { position: static; }
}

@media (max-width: 1180px) {
  .study-toolbar { gap: 12px; }
  .study-actions { gap: 5px; }
  .study-actions button { padding-inline: 10px; }
  .study-context p { font-size: 12px; }
  .insight-grid { column-gap: 0; }
  .insight-item { padding-inline: 9px; }
  .insight-value { font-size: 17px; }
  body.classroom-mode main { padding-inline: 22px; }
  body.classroom-mode .catalog-content .explorer { grid-template-columns: minmax(0, 1fr) 300px; }
  body.classroom-mode .explorer .visual-column { padding-inline: 22px; }
  body.classroom-mode .catalog-content .controls-column { padding: 23px 20px; }
}

@media (max-width: 760px) {
  .study-toolbar { align-items: stretch; flex-direction: column; gap: 9px; padding-top: 2px; margin-bottom: 13px; }
  .study-context { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 14px; }
  .study-context > span { font-size: 9px; letter-spacing: 1px; }
  .study-context p { margin: 0; font-size: 12px; }
  .study-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .study-actions button { padding: 9px 6px; font-size: 11px; }
  .live-insights { margin: 10px 14px 12px; padding: 13px 12px 11px; }
  .insight-heading { gap: 5px 10px; }
  .insight-heading > strong { font-size: 17px; }
  .insight-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
  .insight-item { padding-inline: 8px; }
  .insight-item > span { font-size: 10px; }
  .insight-value { font-size: 16px; }
  .insight-item > p { font-size: 10px; line-height: 1.5; }
  #insight-note { font-size: 12px; }
  .control label .parameter-number { min-height: 44px; font-size: 16px; }
  .figure-caption { font-size: 11px; }
  .action-toast { bottom: calc(91px + env(safe-area-inset-bottom, 0px)); }
  body.classroom-mode .action-toast { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  #share-dialog { padding: 22px 19px; }
  #share-dialog :is(input, textarea) { font-size: 16px; }
  body.classroom-mode main { padding: 12px 12px 24px; }
  body.classroom-mode .catalog-content .explorer { display: block; }
  body.classroom-mode .explorer .visual-column { padding: 16px 15px 0; }
  body.classroom-mode .catalog-content h2 { font-size: 24px; }
  body.classroom-mode .catalog-content .canvas-wrap { height: 290px; height: clamp(290px, 38vh, 380px); }
  body.classroom-mode .catalog-content .explorer { --mobile-figure-height: 290px; }
  body.classroom-mode .catalog-content .controls-column { padding: 23px 19px; }
  body.classroom-mode .figure-caption { font-size: 12px; }
  body.classroom-mode .legend-item { font-size: 10px; }
  body.classroom-mode .insight-value { font-size: 17px; }
  body.classroom-mode .insight-item > p { font-size: 10px; }
  body.classroom-mode .insight-heading > strong { font-size: 17px; }
  body.classroom-mode .study-context p { font-size: 12px; }
  body.classroom-mode .controls-column :is(input, select, button, summary) { scroll-margin-bottom: 20px; }
}

@media (max-width: 430px) {
  .study-context p { display: none; }
  .study-actions { gap: 5px; }
  .study-actions button { padding-inline: 5px; font-size: 10px; }
  .insight-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .insight-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: baseline; gap: 2px 12px; padding: 0 0 10px; border-left: 0; border-bottom: 1px solid #dce5dc; }
  .insight-item:last-child { padding-bottom: 0; border-bottom: 0; }
  .insight-item > span { font-size: 11px; }
  .insight-value { margin: 0; text-align: right; }
  .insight-value .katex-display, .insight-value .katex-display > .katex { text-align: right; }
  .insight-item > p { grid-column: 1 / -1; }
  .insight-heading > strong { width: 100%; }
  .scene-pager { gap: 6px; }
  .scene-pager button { min-width: 79px; padding-inline: 8px; font-size: 11px; }
  #scene-position { font-size: 10px; }
  body.classroom-mode .catalog-content h2 { font-size: 22px; }
  body.classroom-mode .study-context p { display: none; }
}

@media (max-width: 1000px) and (max-height: 570px) {
  body.classroom-mode .explorer .visual-column { position: static; }
  body.classroom-mode .catalog-content .canvas-wrap { height: 340px; position: static; }
}

@media (prefers-reduced-motion: reduce) {
  .study-actions button, .parameter-number { transition: none; }
}

@media print {
  @page { margin: 16mm; }
  html, body, body.classroom-mode { background: #fff; color: #203f56; padding: 0; }
  .masthead, .intro, .chapter-sidebar, .catalog-toolbar, .scene-nav, .scene-pager, .study-toolbar,
  .canvas-tools, .drag-note, .quick-nav, .connection-panel, .reading-note, #keyboard-copy,
  .action-toast, #share-dialog, footer, #parameters, .check { display: none !important; }
  main, body.classroom-mode main { max-width: none; padding: 0; }
  .catalog-layout, .catalog-content .explorer, body.classroom-mode .catalog-content .explorer { display: block; }
  .explorer { border: 0; box-shadow: none; }
  .explorer .visual-column, .explorer[data-scene="estereografica"] .visual-column,
  body.classroom-mode .explorer .visual-column { display: block; position: static; padding: 0; border: 0; box-shadow: none; }
  .catalog-content .canvas-wrap, body.classroom-mode .catalog-content .canvas-wrap { position: static; display: block; height: 95mm; margin: 10px 0; padding: 0; border: 0; box-shadow: none; }
  .canvas-wrap canvas { width: 100%; height: 100%; }
  .figure-caption { display: block; overflow: visible; -webkit-line-clamp: unset; }
  .figure-heading, .live-insights, .result, .equation-chip, #details .math { break-inside: avoid; }
  .catalog-content .controls-column, body.classroom-mode .catalog-content .controls-column { padding: 12px 0 0; background: #fff; border: 0; }
  .controls-title { display: none; }
  .result, .live-insights, .equation-chip { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .katex-display, .math { overflow: visible; }
}

/* The editable number replaces the repeated output; exact special values
   remain named on their preset buttons and in the mathematical statements. */
.control:has(.parameter-number) output { display: none; }

/* One steady navigator and a complete, searchable index on every screen. */
:root { --navigator-height: 76px; }
.book-links { display: flex; align-items: center; gap: 10px; }
.book-links a { display: inline-flex; gap: 12px; align-items: center; min-height: 44px; padding: 10px 15px; border: 1px solid #c6d6ca; border-radius: 5px; text-decoration: none; color: var(--navy); font: 12px/1.4 var(--sans); }
.book-links a:first-child { background: var(--navy); color: white; border-color: var(--navy); }
.book-links a:hover { box-shadow: 0 3px 10px #203f5614; }
.scene-pager { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: auto minmax(0,1fr) 44px 44px; gap: 9px; min-height: var(--navigator-height); padding: 10px 0; margin-bottom: 8px; background: var(--paper); border-bottom: 1px solid #d3dfd6; }
.scene-pager button { min-width: 44px; min-height: 44px; padding: 8px; background: white; font-size: 21px; }
.scene-pager #open-catalog { padding: 10px 14px; display: flex; gap: 9px; align-items: center; font-size: 12px; font-weight: 600; color: #fff; background: var(--navy); border-color: var(--navy); }
#open-catalog > span { font-size: 21px; line-height: 1; }
.scene-switcher { display: grid; gap: 1px; min-width: 0; }
#scene-position { text-align: left; font-size: 10px; padding-left: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#scene-select { min-width: 0; width: 100%; min-height: 40px; padding: 5px 28px 5px 8px; background: transparent; color: var(--navy); border: 1px solid transparent; border-radius: 4px; font: 16px/1.3 var(--serif); text-overflow: ellipsis; }
#scene-select:hover { background: white; border-color: #c3d4c7; }
.study-toolbar { margin-top: 0; padding-top: 2px; }
.explorer .visual-column { top: calc(var(--navigator-height) + 8px); }
.depth-key { display: flex; flex-wrap: wrap; gap: 7px 20px; padding: 2px 0 9px; color: #657981; font: 10px/1.4 var(--sans); }
.depth-key > span { display: inline-flex; gap: 7px; align-items: center; }
.depth-key i { width: 23px; border-top: 1.8px solid #203f56; }
.depth-key .depth-back { border-top: 1.8px dashed #607c8c; }
.depth-key .depth-guide { border-top: 1.8px dotted #81998c; }
body.catalog-open { overflow: hidden; }
#catalog-dialog { width: min(880px, calc(100vw - 48px)); max-height: min(88vh, 960px); padding: 0; border: 1px solid #c6d5c9; border-radius: 13px; color: var(--navy); background: #f9fbf6; box-shadow: 0 24px 100px #142f3140; }
#catalog-dialog::backdrop { background: #1a303766; backdrop-filter: blur(3px); }
.catalog-dialog-heading { position: sticky; top: 0; z-index: 2; background: #f9fbf6; display: flex; align-items: center; justify-content: space-between; padding: 25px 28px 17px; border-bottom: 1px solid #dce5db; }
.catalog-dialog-heading .eyebrow { font-size: 9px; margin-bottom: 6px; letter-spacing: 1.3px; }
#catalog-title { font: 29px/1.2 var(--serif); margin: 0; letter-spacing: -.5px; }
#close-catalog { min-width: 44px; min-height: 44px; border: 1px solid #c6d5c9; border-radius: 50%; background: white; color: var(--navy); font-size: 28px; }
.catalog-dialog-controls { display: flex; gap: 12px; align-items: center; padding: 20px 28px 0; font-size: 12px; color: var(--sage); }
#catalog-chapter { flex: 1; min-width: 0; min-height: 44px; padding: 9px 12px; border: 1px solid #c0d1c4; border-radius: 5px; background: white; color: var(--navy); font-size: 14px; }
.catalog-dialog-content { padding: 20px 28px 28px; }
#catalog-dialog .catalog-toolbar { display: flex !important; gap: 15px; margin-bottom: 20px; }
#catalog-dialog .search-box { flex: 1; min-width: 0; }
#catalog-dialog .catalog-toolbar label { width: 100%; font-size: 11px; }
#catalog-dialog #scene-search { min-height: 46px; font-size: 16px; }
#catalog-dialog #search-help { font-size: 10px; line-height: 1.5; }
#catalog-dialog #catalog-summary { flex: 0 0 auto; margin-bottom: 28px; font-size: 11px; }
#catalog-dialog .scene-nav { display: block !important; padding: 0; margin: 0; overflow: visible; background: none; border: 0; }
.catalog-group { margin-bottom: 25px; }
.catalog-group:last-child { margin-bottom: 0; }
.catalog-group h3 { display: flex; align-items: baseline; gap: 12px; margin: 0 0 10px; font: 19px/1.3 var(--serif); }
.catalog-group h3 > span { color: var(--sage); font: 11px var(--sans); }
.catalog-group > div { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
#catalog-dialog .scene-tab { position: relative; display: block; padding: 13px 40px 13px 15px; min-height: 69px; min-width: 0; width: 100%; border: 1px solid #d3dfd4; border-radius: 6px; color: var(--navy); background: #fff; text-align: left; }
#catalog-dialog .scene-tab strong { font: 15px/1.4 var(--serif); }
#catalog-dialog .scene-tab .scene-reference { font-size: 9px; color: #527364; }
#catalog-dialog .scene-tab .scene-open { position: absolute; right: 12px; top: 24px; color: #698476; font-size: 10px; }
#catalog-dialog .scene-tab:hover { border-color: #7f9d8b; background: #edf4ed; }
#catalog-dialog .scene-tab[aria-current="true"] { background: #e8f1e8; border-color: #7d9f89; box-shadow: inset 3px 0 var(--sage); }
#catalog-dialog :is(button,input,select):focus-visible, .scene-pager :is(button,select):focus-visible { outline: 3px solid #7ba98c; outline-offset: 2px; }
#scene-title:focus, #catalog-title:focus { outline: none; }
body.classroom-mode .scene-pager { background: #f3f6f0; }
body.classroom-mode #catalog-dialog .catalog-toolbar { display: flex !important; }
body.classroom-mode #catalog-dialog .scene-nav { display: block !important; }
@media (max-width: 1000px) { .chapter-sidebar { display: none; } .catalog-layout { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 760px) {
  :root { --navigator-height: 74px; }
  .masthead { gap: 14px; flex-wrap: wrap; }
  .book-links { gap: 7px; margin-left: auto; }
  .book-links a { min-height: 40px; padding: 8px 11px; font-size: 11px; }
  .book-links a > span { display: none; }
  .scene-pager { grid-template-columns: auto minmax(0,1fr) 44px 44px; gap: 5px; padding: 8px 0; }
  .scene-pager #open-catalog { font-size: 11px; padding: 8px 10px; gap: 0; }
  #open-catalog > span { display: none; }
  #scene-position { font-size: 9px; padding-left: 6px; }
  #scene-select { padding-left: 5px; padding-right: 18px; font-size: 15px; }
  .depth-key { margin-inline: 14px; font-size: 9px; gap: 6px 16px; padding-top: 8px; }
  .catalog-content .canvas-wrap { top: var(--navigator-height); }
  .controls-column :is(input,select,button,summary) { scroll-margin-top: calc(var(--mobile-figure-height, 300px) + var(--navigator-height) + 18px); }
  #catalog-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 20px); border-radius: 10px; }
  .catalog-dialog-heading { padding: 18px 17px 13px; }
  #catalog-title { font-size: 25px; }
  .catalog-dialog-heading .eyebrow { font-size: 8px; }
  .catalog-dialog-controls { padding: 15px 17px 0; gap: 8px; font-size: 11px; }
  #catalog-chapter { font-size: 16px; }
  .catalog-dialog-content { padding: 17px; }
  #catalog-dialog .catalog-toolbar { flex-wrap: wrap; gap: 3px; }
  #catalog-dialog .search-box { flex-basis: 100%; }
  #catalog-dialog #catalog-summary { margin: 0 0 5px; text-align: left; font-size: 11px; }
  .catalog-group > div { grid-template-columns: minmax(0,1fr); }
  #catalog-dialog .scene-tab { min-height: 65px; }
  .figure-caption { display: block; -webkit-line-clamp: unset; }
  .action-toast { bottom: calc(16px + env(safe-area-inset-bottom,0px)); }
}
@media (max-width: 430px) { .masthead { gap: 10px; } .brand { flex-basis: 100%; } .book-links { margin-left: 0; } .book-links a { min-height: 40px; } .study-actions button { font-size: 11px; } }
@media (max-width:1000px) and (max-height:570px) { .scene-pager { position: static; } .catalog-content .canvas-wrap { position: static; } }
@media print { .book-links, .depth-key { display:none; } }
/* The actual book cover is displayed as an image. */
.intro { display: grid; grid-template-columns: minmax(0,1fr) 112px; align-items: center; gap: 24px; }
.intro-copy > p:last-child { margin-bottom: 0; max-width: 70ch; color: var(--muted); font: 14px/1.7 var(--serif); }
.book-cover { display: block; width: 112px; margin: 0; color: var(--sage); justify-self: end; }
.book-cover img { display: block; width: 100%; height: auto; border-radius: 1px 4px 4px 1px; box-shadow: 3px 7px 16px #1d38442e, -2px 0 0 #d5d9d0; }
.book-cover figcaption { display: block; padding-top: 8px; font: 10px/1.3 var(--sans); text-align: center; }
@media (max-width: 760px) { .intro { grid-template-columns: minmax(0,1fr) 90px; gap: 18px; padding-block: 20px; } .book-cover { width: 90px; } .intro-copy > p:last-child { font-size: 12px; line-height: 1.6; } .intro-copy > .eyebrow { font-size: 8px; margin-bottom: 10px; } #resource-count { display: block; margin: 6px 0 0; font-size: 10px; } }
@media (max-width: 430px) { .intro { grid-template-columns: minmax(0,1fr) 76px; gap: 13px; } .book-cover { width: 76px; } .intro h1 { font-size: 25px; } .book-cover figcaption { font-size: 9px; } .intro-copy > .eyebrow { font-size: 7px; letter-spacing: 1px; } }

@media(min-width:431px) and (max-width:640px){.insight-grid{grid-template-columns:1fr;gap:12px}.insight-item{padding:0 0 12px;border-left:0;border-bottom:1px solid #dce5dc}.insight-item:last-child{border-bottom:0;padding-bottom:0}.insight-value{font-size:19px}.insight-item>p{font-size:12px}.insight-item>span{font-size:11px}}
@media(min-width:1001px){.insight-item>p{font-size:11px;line-height:1.6}}
/* On a phone the controls follow the diagram immediately; explanatory cards
   remain below them and the diagram stays available while adjusting a value. */
@media(max-width:760px) and (min-height:571px){
  .catalog-content .explorer,body.classroom-mode .catalog-content .explorer{display:flex;flex-direction:column}
  .explorer .visual-column{display:contents}
  .visual-column>.figure-heading{order:0}
  .visual-column>.canvas-wrap{order:1;width:100%;flex-shrink:0}
  .visual-column>.depth-key{order:2}
  .visual-column>.equation-chip{order:3}
  .visual-column>.figure-legend{order:4}
  .catalog-content .controls-column{order:5}
  .visual-column>.live-insights{order:6}
  .visual-column>.figure-caption{order:7}
  .catalog-content .explorer{--mobile-figure-height:310px}
  .catalog-content .canvas-wrap{padding-inline:8px}
}
@media(max-width:430px){
  :root{--navigator-height:108px}
  .scene-pager{grid-template-columns:auto minmax(0,1fr) 44px 44px;grid-template-rows:44px 40px;gap:4px 6px;padding:8px 0}
  .scene-pager #open-catalog{grid-area:1/1}
  .scene-switcher{display:contents}
  .scene-pager #scene-position{grid-area:1/2;align-self:center;font-size:10px;white-space:normal;line-height:1.3;padding-left:0}
  .scene-pager #prev-scene{grid-area:1/3}
  .scene-pager #next-scene{grid-area:1/4}
  .scene-pager #scene-select{grid-area:2/1/3/-1;min-height:40px;padding:5px 28px 5px 10px;background:#fff;border-color:#d4e1d8;font-size:15px}
}
@media(min-width:761px) and (max-width:1000px){.insight-grid{grid-template-columns:1fr;gap:12px}.insight-item{padding:0 0 12px;border-left:0;border-bottom:1px solid #dce5dc}.insight-item:last-child{border-bottom:0;padding-bottom:0}.insight-item>p{font-size:12px}.insight-value{font-size:20px}}


/* Live readings must not move the controls or make the sticky figure jump.
   Reserve readable lines, never crop mathematical content or fix a maximum. */
.surface-controls { min-inline-size: 0; margin: 8px 0 16px; padding: 7px 10px; border: 1px solid #c6d3cb; border-radius: 7px; background: #f6f8f4; }
.surface-controls > legend { padding: 0 5px; color: #25483e; font: 600 12px/1.4 var(--sans); }
.surface-controls .check-control { margin: 0; }
.surface-controls .check-control label { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 5px 0; line-height: 1.4; cursor: pointer; }
.surface-controls input[type="checkbox"] { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; }
.surface-swatch { display: inline-block; flex: 0 0 13px; width: 13px; height: 13px; border: 2px solid var(--surface-color); border-radius: 3px; background: var(--surface-color); }
.surface-controls input:not(:checked) + .surface-swatch { background: transparent; }
.surface-controls label > span:last-child { min-width: 0; }
.surface-controls :focus-visible { outline: 3px solid #52796d; outline-offset: 3px; }

/* Keep named presets whole when four steps share a narrow panel. */
.presets button { flex: 1 1 auto; min-width: max-content; overflow-wrap: normal; word-break: normal; }
html { scrollbar-gutter: stable; }
.explorer { overflow-anchor: none; }
.range-control > label { display: grid; grid-template-columns: minmax(0, 1fr) 88px; align-items: start; }
.range-control > label > span { min-width: 0; }
.range-control > label > output { min-width: 0; width: 88px; text-align: right; font-variant-numeric: tabular-nums; }
.control.range-control label .parameter-number { width: 88px; min-width: 88px; }
.controls-column #status { min-block-size: 6.2em; }
.explorer[data-scene="producto-vectorial"] #status > .status-row { display: block; }
.explorer[data-scene="producto-vectorial"] #status > .status-row:first-child { white-space: nowrap; }
.explorer[data-scene="interseccion-conos"] #status { min-block-size: 7.75em; }
/* The causal-branch explanation has four lines at the narrow desktop card width. */
@media screen and (min-width: 1001px) {
  .explorer[data-scene="interseccion-conos"] .insight-item > p { min-block-size: 6.4em; }
}
.insight-heading { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 5px; }
.insight-heading > strong { min-block-size: 2.7em; }
.insight-item > span { min-block-size: 2.9em; }
.insight-value { min-block-size: 2.1em; }
.insight-item > p { min-block-size: 4.8em; }
#insight-note { min-block-size: calc(4.95em + 11px); }
@media print {
  html { scrollbar-gutter: auto; }
  .controls-column #status, .explorer[data-scene="interseccion-conos"] #status,
  .insight-heading > strong, .insight-item > span, .insight-value,
  .insight-item > p, #insight-note { min-block-size: 0; }
}

/* The pixel defaults above also work when clamp() is unavailable. */
@supports (height: clamp(290px, 38vh, 380px)) {
  @media screen and (max-width: 760px) {
    body.classroom-mode .catalog-content .explorer { --mobile-figure-height: clamp(290px, 38vh, 380px); }
  }
  @media screen and (max-width: 760px) and (min-height: 571px) {
    .catalog-content .explorer { --mobile-figure-height: clamp(310px, 38vh, 355px); }
  }
}
@supports (height: 1svh) {
  @media screen {
    #share-dialog { max-height: calc(100svh - 40px); }
    #catalog-dialog { max-height: min(88svh, 960px); }
  }
  @media screen and (max-width: 760px) {
    #catalog-dialog { max-height: calc(100svh - 20px); }
  }
  @media screen and (max-width: 760px) and (min-height: 571px) {
    .catalog-content .explorer { --mobile-figure-height: clamp(310px, 38svh, 355px); }
    body.classroom-mode .catalog-content .explorer { --mobile-figure-height: clamp(290px, 38svh, 380px); }
    body.classroom-mode .catalog-content .canvas-wrap { height: clamp(290px, 38svh, 380px); }
  }
}
@supports (height: 1dvh) {
  @media screen {
    .chapter-sidebar { max-height: calc(100dvh - 36px); }
  }
}

/* The right-hand controls scroll independently while the diagram remains
   visible. Keep the established columns, widths and parameter order. */
@media screen and (min-width: 1001px) and (min-height: 571px) {
  .catalog-content .explorer .controls-column {
    position: sticky;
    top: calc(var(--navigator-height) + 8px);
    align-self: start;
    max-height: calc(100vh - var(--navigator-height) - 24px);
    max-height: calc(100dvh - var(--navigator-height) - 24px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-gutter: stable;
  }
}

/* Playback remains beside the parameter it controls; all choices also work
   when the animation is paused. */
.explorer .animation-tools {
  min-width: 0;
  display: grid;
  gap: 7px;
  margin: 10px 0 4px;
  padding: 10px;
  border: 1px solid #cbdacf;
  border-radius: 6px;
  background: #f4f8f2;
}
.explorer .animation-tools .animation-button {
  width: 100%;
  min-height: 44px;
  margin: 0;
  border: 1px solid #a9c0af;
  border-radius: 5px;
  color: #315847;
  background: #eaf2e9;
  font: 600 12px/1.4 var(--sans);
}
.explorer .animation-tools .animation-button[aria-pressed="true"] {
  border-color: #a55a65;
  color: #8c2938;
  background: #fff4f2;
}
.explorer .animation-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1px 10px;
  min-width: 0;
}
.explorer .control .animation-options label {
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 7px;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  color: #446254;
  font: 11px/1.4 var(--sans);
  cursor: pointer;
}
.explorer .control .animation-speed select {
  flex: 0 0 72px;
  width: 72px;
  min-width: 0;
  min-height: 44px;
  padding: 7px 8px;
  font-size: 13px;
}
.explorer .animation-options input[type="checkbox"] {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--sage);
}
.explorer .animation-case-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.explorer .animation-case-buttons button {
  min-width: 0;
  min-height: 44px;
  padding: 8px 7px;
  border: 1px solid #c3d4c7;
  border-radius: 5px;
  background: #fff;
  color: var(--navy);
  font: 12px/1.4 var(--sans);
}
.explorer .animation-case-buttons button:hover { background: #eaf2e9; border-color: #8daa97; }
.explorer .animation-case-buttons button:disabled { opacity: .45; cursor: default; }
.explorer .animation-note {
  min-width: 0;
  margin: 0;
  color: #546d63;
  font: 11px/1.55 var(--sans);
  overflow-wrap: break-word;
}
.explorer .animation-note:empty { display: none; }
.explorer .animation-tools :is(button, select, input):focus-visible {
  outline: 3px solid #52796d;
  outline-offset: 2px;
}
@media screen and (max-width: 760px) {
  .explorer .control .animation-speed select { font-size: 16px; }
  .explorer .animation-note { font-size: 12px; }
}
@media print { .explorer .animation-tools { display: none; } }

/* Keep each observation's value and conclusion in independent, stable rows.
   Reservations follow actual font/width measurements and never crop content. */
.controls-column #status { display: grid; align-content: start; font-variant-numeric: tabular-nums; }
.controls-column #status > .status-row { display: block; min-width: 0; }
.insight-value { font-variant-numeric: tabular-nums; }
.readout-measure { position: fixed; inset: 0 auto auto -100000px; display: block; box-sizing: content-box; visibility: hidden; pointer-events: none; padding: 0; margin: 0; border: 0; height: auto; min-height: 0; max-height: none; }
@media print { .controls-column #status { display: block; grid-template-rows: none !important; } .controls-column #status > .status-row, .insight-heading > strong, .insight-item > span, .insight-value, .insight-item > p, #insight-note, .step-copy, #suggestion, #figure-caption, #equation, .animation-note { min-block-size: 0 !important; } }
