/* Editorial explorer, chapter catalogue and touch layouts.
   Load after style.css. The figure stays visible while its controls scroll.
   Canvas tools occupy their own row so they never cover the construction. */

:root {
  --paper: #f7f8f4;
  --line: #dce4df;
  --soft: #edf3ee;
  --shadow: 0 10px 32px rgba(32, 63, 86, .045);
}

html { scroll-padding-top: 20px; }
body { line-height: 1.5; }
button, input, select, summary { -webkit-tap-highlight-color: transparent; }
button, select { font-family: var(--sans); }
select:focus-visible { outline: 3px solid #a8c2b5; outline-offset: 3px; }
button { transition: background-color .16s ease, border-color .16s ease; }
.masthead, main, footer { max-width: 1472px; }
.masthead { padding-top: 22px; padding-bottom: 22px; }
.intro { padding-top: 28px; padding-bottom: 24px; }
h1 { font-size: clamp(29px, 2.75vw, 38px); }
.intro > p:last-child { line-height: 1.65; }
.catalog-layout { grid-template-columns: 165px minmax(0, 1fr); gap: 26px; }
.chapter-sidebar { position: sticky; top: 20px; align-self: start; }
.chapter-link { min-height: 58px; border: 1px solid transparent; }
.chapter-link[aria-current="true"] { border-color: #d4e1d8; }
.chapter-link strong { line-height: 1.3; }
.chapter-link small { font-size: 9px; }

/* A compact search followed by a horizontal row of complete resource names. */
.catalog-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 14px;
}
.catalog-toolbar label {
  display: grid;
  gap: 5px;
  width: min(100%, 390px);
  color: var(--sage);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .25px;
}
#scene-search {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfdcd4;
  border-radius: 6px;
  padding: 10px 13px;
  background: #fff;
  color: var(--navy);
  font-size: 13px;
  line-height: 1.4;
  box-shadow: inset 0 1px 2px rgba(32, 63, 86, .025);
}
#scene-search::placeholder { color: #7a8b91; opacity: 1; }
#catalog-summary { margin: 0 0 12px; font-size: 10px; color: var(--muted); }
.catalog-content .scene-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 7px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: #b9c9bf transparent;
  padding: 3px 2px 9px;
  margin: 0 -2px 14px;
}
.catalog-content .scene-tab {
  display: block;
  flex: 0 0 auto;
  min-width: 130px;
  max-width: 215px;
  min-height: 60px;
  padding: 10px 13px;
  border: 1px solid #d6e1d9;
  border-radius: 6px;
  text-align: left;
  white-space: normal;
  scroll-snap-align: start;
}
.catalog-content .scene-tab span { max-width: none; font-size: 11px; }
.scene-tab .scene-reference {
  display: block;
  margin-bottom: 3px;
  color: var(--sage);
  font: 9px/1.2 var(--sans);
  letter-spacing: .4px;
}
.scene-tab strong { display: block; font: 13px/1.3 var(--serif); }
.catalog-content .scene-tab[aria-current="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.scene-tab[aria-current="true"] .scene-reference { color: #d9e6de; }
.scene-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}
.scene-pager button {
  min-height: 44px;
  padding: 9px 13px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--navy);
  font-size: 11px;
  line-height: 1.4;
}
.scene-pager button:hover { background: #fff; border-color: #b7c9bd; }
.scene-pager button:disabled { cursor: default; opacity: .4; }
#scene-position { text-align: center; color: var(--muted); font-size: 10px; }

/* The diagram is the principal reading surface. */
.catalog-content .explorer {
  grid-template-columns: minmax(0, 1fr) 290px;
  overflow: visible;
  box-shadow: var(--shadow);
  isolation: isolate;
}
.explorer .visual-column,
.explorer[data-scene="estereografica"] .visual-column {
  position: sticky;
  top: 16px;
  align-self: start;
  padding: 21px 22px 0;
  background: #fff;
  border-radius: 8px 0 0 8px;
}
.explorer[data-scene="estereografica"] { overflow: visible; }
.figure-heading { align-items: start; gap: 12px; }
.figure-heading > div { min-width: 0; }
.figure-heading .eyebrow { font-size: 9px; letter-spacing: 1px; line-height: 1.5; }
.catalog-content h2 { font-size: clamp(22px, 1.8vw, 27px); line-height: 1.17; }
.tag { margin-top: 3px; font-size: 8px; }
.catalog-content .canvas-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 44px minmax(0, 1fr) 21px;
  gap: 5px;
  height: 460px;
  height: clamp(365px, 49vh, 505px);
  margin-top: 12px;
}
.canvas-wrap canvas { grid-area: 2 / 1; min-width: 0; min-height: 180px; }
.canvas-tools {
  position: static;
  grid-area: 1 / 1;
  display: flex;
  justify-content: end;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.canvas-tools button {
  min-width: 44px;
  min-height: 44px;
  height: 44px;
  padding: 0 10px;
  background: #f9fbf8;
  border-color: #d8e2da;
  border-radius: 5px;
  font-size: 20px;
}
.canvas-tools button:last-child { font-size: 20px; }
.canvas-tools button span { font-size: 10px; vertical-align: 2px; }
.canvas-tools select {
  flex: 0 1 140px;
  min-width: 104px;
  max-width: 160px;
  min-height: 44px;
  padding: 0 9px;
  border: 1px solid #d8e2da;
  border-radius: 5px;
  background: #fff;
  color: var(--navy);
  font-size: 11px;
}
.drag-note {
  position: static;
  grid-area: 3 / 1;
  align-self: center;
  font-size: 10px;
  line-height: 1.3;
  color: #74858a;
}
.figure-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 16px;
  padding: 10px 0;
  border-top: 1px solid #e7ece8;
}
.figure-legend:empty { display: none; }
.legend-item { display: inline-flex; gap: 7px; align-items: center; color: var(--muted); font-size: 10px; line-height: 1.35; }
.legend-item i { display: block; width: 17px; height: 3px; flex: 0 0 17px; border-radius: 1px; background: var(--legend-color, var(--sage)); }
.equation-chip {
  margin: 0 0 12px;
  padding: 10px 13px;
  border: 1px solid #e0e8e0;
  border-radius: 5px;
  background: #f7faf6;
  color: var(--navy);
  font: 15px/1.55 var(--serif);
  overflow-wrap: anywhere;
}
.equation-chip:empty { display: none; }
.figure-caption { min-height: 0; padding: 11px 0 15px; font-size: 12px; line-height: 1.65; }
.catalog-content .controls-column {
  display: block;
  min-width: 0;
  padding: 23px 21px;
  border-radius: 0 8px 8px 0;
}
.controls-title { margin-bottom: 22px; }
.controls-title h3 { font-size: 18px; }
.control { min-width: 0; margin-bottom: 18px; }
.control label { font-size: 12px; gap: 8px; line-height: 1.45; margin-bottom: 5px; }
.control output { font-size: 19px; }
.control input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 44px;
  margin: 0;
  background: transparent;
}
.control input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 9px; background: #d4e0d6; }
.control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 21px;
  height: 21px;
  margin-top: -8.5px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--sage);
  box-shadow: 0 0 0 1px #8eac9a;
}
.control input[type="range"]::-moz-range-track { height: 4px; border-radius: 9px; background: #d4e0d6; }
.control input[type="range"]::-moz-range-thumb { width: 17px; height: 17px; border: 2px solid #fff; border-radius: 50%; background: var(--sage); box-shadow: 0 0 0 1px #8eac9a; }
.control select {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px;
  color: var(--navy);
  background: #fff;
  border: 1px solid #d2dfd5;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.5;
}
.range-ends { font-size: 9px; line-height: 1.3; margin-top: -3px; }
.check, .control.check-control label { min-height: 44px; font-size: 11px; align-items: center; line-height: 1.5; }
.check input, .control.check-control input { width: 18px; height: 18px; flex: 0 0 18px; accent-color: var(--sage); }
.control.check-control label { justify-content: start; gap: 9px; }
.presets { flex-wrap: wrap; margin: 13px 0 17px; gap: 7px; }
.presets button {
  flex: 1 1 60px;
  min-height: 44px;
  min-width: 0;
  padding: 9px 8px;
  font: 12px/1.35 var(--serif);
  overflow-wrap: anywhere;
}
.presets button[aria-pressed="true"] { border-color: var(--sage); background: #e7f0e8; box-shadow: inset 0 0 0 1px var(--sage); color: #294f42; }
.step-copy { margin: -3px 0 16px; padding: 10px 12px; border-left: 2px solid #adc2b4; color: var(--ink); background: #f1f5ef; font: 13px/1.6 var(--serif); }
.animation-button { min-height: 44px; padding: 10px 12px; font-size: 11px; margin: 7px 0 2px; }
.result { padding: 14px; }
.result-label { font-size: 9px; line-height: 1.5; }
.result p { font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; }
.suggestion > span { font-size: 13px; }
.suggestion p { font-size: 11px; line-height: 1.75; }
details { padding-top: 10px; }
summary { min-height: 44px; font-size: 12px; line-height: 1.5; }
#details { font-size: 13px; }
.normal-character-table { width: 100%; border-collapse: collapse; margin: 7px 0 17px; font-size: 12px; line-height: 1.5; text-align: left; }
.normal-character-table th { background: var(--soft); color: var(--navy); font-weight: 600; }
.normal-character-table th, .normal-character-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.normal-character-table td:last-child { color: var(--sage); }

#details .math { font-size: 14px; }
#steps { font-size: 11px; }

/* Follow an idea from one construction to the next. */
.connection-panel {
  margin-top: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0f4ee;
}
.connection-panel h2, .connection-panel h3 { font: 21px/1.25 var(--serif); }
.connection-panel > p { max-width: 760px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 15px; }
.related-scene {
  min-width: 0;
  min-height: 75px;
  padding: 13px 15px;
  border: 1px solid #d2dfd4;
  border-radius: 5px;
  background: #fff;
  text-align: left;
  color: var(--navy);
}
.related-scene:hover { border-color: #9bb6a3; background: #fafff9; }
.related-scene small { display: block; margin-bottom: 5px; color: var(--sage); font-size: 9px; line-height: 1.3; }
.related-scene strong { display: block; font: 15px/1.35 var(--serif); }
details.exploration-task { margin-top: 17px; border-color: #d4e0d4; }
.exploration-task summary { color: var(--navy); font: 15px/1.5 var(--serif); }
#task-question { flex: 1; min-width: 0; }
.task-answer { max-width: 800px; padding: 9px 0 2px; color: var(--ink); font: 14px/1.75 var(--serif); }
.task-answer p { margin: 0 0 8px; }
.reading-note { font-size: 12px; }
.reading-note button { min-height: 44px; min-width: 72px; font-size: 10px; }
footer { padding-top: 25px; }
footer span, footer p { font-size: 10px; line-height: 1.7; }
footer a { display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: 3px; }

@media (max-width: 1180px) {
  .masthead, main, footer { padding-left: 26px; padding-right: 26px; }
  .catalog-layout { grid-template-columns: 145px minmax(0, 1fr); gap: 19px; }
  .catalog-content .explorer { grid-template-columns: minmax(0, 1fr) 260px; }
  .catalog-content .controls-column { padding: 20px 17px; }
  .explorer .visual-column, .explorer[data-scene="estereografica"] .visual-column { padding: 20px 17px 0; }
  .canvas-tools button span { display: none; }
  .catalog-content .canvas-wrap { height: 420px; }
  .tag { display: none; }
}

@media (max-width: 1000px) and (min-width: 761px) {
  .catalog-layout { grid-template-columns: minmax(0, 1fr); gap: 17px; }
  .chapter-sidebar { position: static; padding: 0; }
  .chapter-sidebar > .eyebrow { display: none; }
  .chapter-links { display: flex; flex-direction: row; gap: 5px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .chapter-link { flex: 1 1 0; min-width: 0; min-height: 67px; gap: 8px; padding: 11px 8px; }
  .chapter-link strong { font-size: 13px; }
  .chapter-link small { font-size: 8px; max-width: none; }
  .mobile-chapter { display: none; }
  .catalog-content .explorer { grid-template-columns: minmax(0, 1fr) 270px; }
  .catalog-content .canvas-wrap { height: 410px; }
  .catalog-content h2 { font-size: 24px; }
  .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 8px; }
  .masthead, main, footer { padding-left: 18px; padding-right: 18px; }
  .masthead { padding-top: 14px; padding-bottom: 14px; }
  .brand { font-size: 20px; gap: 10px; }
  .brand-mark { font-size: 35px; }
  .brand small { font-size: 8px; margin-top: 3px; }
  .edition { display: none; }
  .intro { padding: 17px 0 18px; }
  .intro > .eyebrow { display: none; }
  h1 { max-width: none; font-size: 25px; line-height: 1.2; margin-bottom: 7px; letter-spacing: -.6px; }
  .intro > p:last-child { font-size: 12px; line-height: 1.5; }
  .catalog-layout { display: block; }
  .chapter-sidebar { position: static; margin-bottom: 14px; padding: 0; }
  .chapter-sidebar > .eyebrow, .chapter-links { display: none; }
  .mobile-chapter { display: flex; gap: 10px; align-items: center; font-size: 10px; }
  .mobile-chapter select { min-height: 44px; padding: 9px 11px; font-size: 15px; }
  .catalog-toolbar { align-items: center; gap: 9px; margin-bottom: 10px; }
  .catalog-toolbar label { flex: 1; width: auto; font-size: 9px; }
  #scene-search { min-height: 44px; font-size: 13px; padding: 10px 12px; }
  #catalog-summary { flex: 0 0 75px; margin: 15px 0 0; font-size: 9px; line-height: 1.6; text-align: right; }
  .catalog-content .scene-nav { margin-bottom: 9px; padding-bottom: 8px; }
  .catalog-content .scene-tab { min-width: 132px; max-width: 200px; min-height: 57px; padding: 9px 12px; }
  .scene-tab .scene-reference { font-size: 9px; }
  .scene-tab strong { font-size: 13px; }
  .scene-pager { margin-bottom: 12px; gap: 8px; }
  .scene-pager button { padding: 9px 11px; font-size: 10px; }
  #scene-position { font-size: 9px; }
  .catalog-content .explorer { grid-template-columns: minmax(0, 1fr); overflow: visible; }
  .explorer .visual-column,
  .explorer[data-scene="estereografica"] .visual-column {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 14px 15px 0;
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 6px 12px rgba(32, 63, 86, .035);
  }
  .figure-heading { gap: 7px; }
  .figure-heading .eyebrow { font-size: 8px; margin-bottom: 3px; letter-spacing: .6px; }
  .catalog-content h2 { font-size: 21px; line-height: 1.15; }
  .catalog-content .canvas-wrap { height: 265px; height: clamp(225px, 29vh, 285px); margin-top: 7px; grid-template-rows: 44px minmax(0, 1fr) 16px; gap: 3px; }
  .canvas-tools { gap: 5px; }
  .canvas-tools button { padding: 0 8px; }
  .canvas-tools select { flex-basis: 132px; font-size: 11px; }
  .drag-note { font-size: 9px; line-height: 1.25; }
  .drag-note span { font-size: 13px; }
  .figure-legend { gap: 5px 13px; padding: 6px 0; }
  .legend-item { font-size: 9px; gap: 5px; }
  .legend-item i { width: 14px; flex-basis: 14px; }
  .equation-chip { margin-bottom: 7px; padding: 6px 9px; font-size: 13px; line-height: 1.4; }
  .figure-caption { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 10px; line-height: 1.5; padding: 7px 0; margin-bottom: 5px; }
  .visual-column.mobile-caption-expanded .figure-caption { display: block; overflow: visible; }
  .catalog-content .controls-column { display: block; border-left: 0; border-top: 0; border-radius: 0 0 8px 8px; padding: 20px; }
  .controls-title { margin-bottom: 18px; }
  .controls-title h3 { font-size: 18px; }
  .control { margin-bottom: 17px; }
  .control label { font-size: 12px; }
  .control output { font-size: 19px; }
  .control select { font-size: 13px; }
  .presets { margin-bottom: 16px; }
  .presets button { font-size: 13px; }
  .check { font-size: 12px; margin-bottom: 18px; }
  .result { padding: 14px; margin-bottom: 17px; }
  .result p { font-size: 16px; }
  .suggestion { margin: 0 0 17px; }
  .suggestion p { font-size: 12px; line-height: 1.7; }
  #details { font-size: 14px; line-height: 1.75; }
  #steps { font-size: 12px; }
  .connection-panel { margin-top: 16px; padding: 19px 17px; }
  .connection-panel h2, .connection-panel h3 { font-size: 20px; }
  .connection-panel > p { font-size: 12px; }
  .related-grid { gap: 9px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .related-scene { min-height: 80px; padding: 12px; }
  .related-scene strong { font-size: 14px; }
  .exploration-task summary { font-size: 15px; }
  .task-answer { font-size: 14px; }
  .reading-note { font-size: 11px; gap: 8px; }
  footer { gap: 14px; padding-top: 22px; padding-bottom: 24px; }
  footer span, footer p { font-size: 9px; }
}

@media (max-width: 390px) {
  .masthead, main, footer { padding-left: 13px; padding-right: 13px; }
  .brand { font-size: 19px; }
  h1 { font-size: 23px; }
  .intro > p:last-child { font-size: 11px; }
  .explorer .visual-column, .explorer[data-scene="estereografica"] .visual-column { padding-left: 12px; padding-right: 12px; }
  .catalog-content h2 { font-size: 20px; }
  .catalog-content .canvas-wrap { height: 245px; height: clamp(215px, 28vh, 260px); }
  .canvas-tools select { flex-basis: 126px; min-width: 104px; }
  .catalog-content .controls-column { padding: 19px 17px; }
  .related-grid { grid-template-columns: minmax(0, 1fr); }
  .related-scene { min-height: 70px; }
}

@media (max-height: 570px) and (max-width: 1000px) {
  /* A fixed panel would consume the whole viewport in phone landscape. */
  .explorer .visual-column, .explorer[data-scene="estereografica"] .visual-column { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

[hidden]{display:none!important}.touch-note{display:none}.step-copy{font:12px/1.6 var(--serif);color:var(--sage);margin:9px 0 0}.presets button[aria-pressed=true]{background:var(--navy);border-color:var(--navy);color:#fff}.empty-search{font-size:12px;color:var(--muted);padding:10px}#resource-count{white-space:nowrap;color:var(--sage);font-size:11px;margin-left:6px}@media(pointer:coarse){.pointer-note{display:none}.touch-note{display:inline}}

.drag-note .pointer-note,.drag-note .touch-note{font:inherit;vertical-align:baseline;margin:0}@media(max-width:760px){.catalog-content .explorer{display:block}.catalog-content .canvas-wrap{height:260px;height:clamp(260px,32vh,300px);min-height:260px}}

/* On a phone only the canvas remains fixed. The title, legend, equation and
   caption keep their complete reading order without covering the controls. */
@media (max-width: 760px) and (min-height: 571px) {
  .catalog-content .explorer { --mobile-figure-height: 300px; }
  .explorer .visual-column,
  .explorer[data-scene="estereografica"] .visual-column {
    display: contents;
    position: static;
  }
  .visual-column > .figure-heading {
    margin: 0 14px;
    padding-top: 14px;
  }
  .catalog-content .canvas-wrap {
    position: sticky;
    top: 0;
    z-index: 3;
    height: var(--mobile-figure-height);
    padding: 7px 12px 5px;
    margin: 7px 0 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 5px 12px rgba(32, 63, 86, .045);
  }
  .visual-column > .figure-legend,
  .visual-column > .equation-chip,
  .visual-column > .figure-caption { margin-left: 14px; margin-right: 14px; }
  .visual-column > .figure-legend { border-top: 0; padding-top: 10px; }
  .visual-column > .figure-caption {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
    padding-bottom: 10px;
    margin-bottom: 0;
  }
  .controls-column :is(input, select, button, summary) {
    scroll-margin-top: calc(var(--mobile-figure-height) + 16px);
    scroll-margin-bottom: 20px;
  }
}

/* Navigation polish: complete labels, readable references and visible focus.
   These rules deliberately leave the diagram and its controls unchanged. */
.catalog-toolbar { min-width: 0; }
.catalog-toolbar label { min-width: 0; font-size: 11px; }
#scene-search { font-size: 14px; border-color: #b9cdbf; }
#scene-search:hover { border-color: #8fac99; }
#catalog-summary { font-size: 11px; line-height: 1.5; }
.catalog-content .scene-nav {
  padding: 6px 5px 12px;
  margin-left: -5px;
  margin-right: -5px;
  scroll-padding-inline: 6px;
  scrollbar-color: #8fac99 #e9efe8;
  scrollbar-width: auto;
}
.scene-nav::-webkit-scrollbar { height: 7px; }
.scene-nav::-webkit-scrollbar-track { background: #e9efe8; border-radius: 6px; }
.scene-nav::-webkit-scrollbar-thumb { background: #9cb6a5; border-radius: 6px; }
.catalog-content .scene-nav:focus-visible { outline: 2px solid var(--sage); outline-offset: 3px; border-radius: 5px; }
.catalog-content .scene-tab {
  min-width: 146px;
  max-width: 230px;
  min-height: 65px;
  border-color: #cfddd2;
  scroll-margin-inline: 6px;
}
.catalog-content .scene-tab .scene-reference { font-size: 10px; line-height: 1.4; letter-spacing: .15px; }
.catalog-content .scene-tab strong { font-size: 14px; line-height: 1.35; white-space: normal; overflow-wrap: break-word; }
.chapter-link { min-width: 0; }
.chapter-link > span { color: #617f6f; }
.chapter-link strong { min-width: 0; }
.chapter-link small { color: #627780; line-height: 1.5; }
.scene-pager button { font-size: 12px; }
#scene-position { min-width: 0; font-size: 11px; line-height: 1.45; font-variant-numeric: tabular-nums; }
:is(.chapter-link, .scene-tab, .scene-pager button, #scene-search, #chapter-select):focus-visible {
  outline: 3px solid var(--sage);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff;
}
.skip:focus { z-index: 20; }

@media (max-width: 1000px) and (min-width: 761px) {
  .chapter-link { padding: 12px 9px; align-items: start; }
  .chapter-link strong { font-size: 13px; }
  .chapter-link small { font-size: 10px; }
}

@media (max-width: 760px) {
  .catalog-toolbar { display: block; }
  .catalog-toolbar label { width: 100%; font-size: 11px; }
  #scene-search { font-size: 16px; }
  #catalog-summary { margin: 6px 0 0; text-align: left; font-size: 11px; }
  .mobile-chapter { font-size: 11px; }
  .mobile-chapter select { font-size: 16px; }
  .catalog-content .scene-tab { min-width: 142px; max-width: 218px; min-height: 64px; }
  .scene-pager { gap: 10px; }
  .scene-pager button { font-size: 12px; min-width: 94px; }
  #scene-position { font-size: 11px; }
}

.search-box { flex: 1 1 390px; min-width: 0; max-width: 560px; }
.search-box label { display: block; width: auto; margin-bottom: 6px; }
.search-box + #catalog-summary { align-self: center; max-width: 210px; }
.search-field { position: relative; display: block; min-width: 0; }
.search-field #scene-search { padding-right: 52px; }
.search-field #scene-search::-webkit-search-cancel-button { -webkit-appearance: none; }
#clear-search {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0 6px 6px 0;
  background: transparent;
  color: var(--sage);
  font-size: 23px;
  line-height: 1;
}
#clear-search:hover { background: #edf3ee; color: var(--navy); }
#search-help { margin: 5px 0 0; color: var(--muted); font: 11px/1.5 var(--sans); }
.quick-nav { display: none; }

/* Vector notation in running text: the arrow is drawn with CSS so it does
   not depend on a font supporting the combining vector character. */
.vector-label {
  position: relative;
  display: inline-block;
  min-width: .72em;
  margin-inline: .06em .09em;
  padding: .2em .02em 0;
  color: inherit;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
}
.vector-label::before {
  content: "";
  position: absolute;
  top: .11em;
  left: .02em;
  right: .02em;
  border-top: 1px solid currentColor;
}
.vector-label::after {
  content: "";
  position: absolute;
  top: 0;
  right: .02em;
  width: .22em;
  height: .22em;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  transform: rotate(45deg);
}
:is(#clear-search, .quick-nav button):focus-visible {
  outline: 3px solid var(--sage);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff;
}

@media (max-width: 760px) {
  .search-box, .search-box + #catalog-summary { max-width: none; }
  html { scroll-padding-bottom: 100px; }
  body.quick-visible { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
  body.quick-visible .controls-column :is(input, select, button, summary) { scroll-margin-bottom: 100px; }
  .quick-nav {
    position: fixed;
    z-index: 12;
    left: 50%;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 7px;
    width: min(420px, calc(100% - 26px));
    padding: 7px;
    border: 1px solid #cbdacf;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 5px 24px rgba(32, 63, 86, .16);
  }
  .quick-nav button {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    border: 1px solid #d4dfd6;
    border-radius: 5px;
    background: #f8faf6;
    color: var(--navy);
    font-size: 22px;
    line-height: 1.2;
  }
  .quick-nav button:hover { background: #edf3ee; }
  .quick-nav button:disabled { opacity: .45; cursor: default; }
  .quick-nav #quick-catalog {
    min-width: 0;
    border-color: var(--navy);
    background: var(--navy);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
  }
  .quick-nav #quick-catalog:hover { background: #2d5269; }
}

/* A custom property accepts unknown units. Keep its fallback usable before
   allowing small-viewport units, or height: var(...) can compute to auto. */
@supports (height: clamp(260px, 33vh, 300px)) {
  @media screen and (max-width: 760px) and (min-height: 571px) {
    .catalog-content .explorer { --mobile-figure-height: clamp(260px, 33vh, 300px); }
  }
}
@supports (height: 1svh) {
  @media screen and (max-width: 760px) {
    .catalog-content .canvas-wrap { height: clamp(260px, 32svh, 300px); }
  }
  @media screen and (max-width: 760px) and (min-height: 571px) {
    .catalog-content .explorer { --mobile-figure-height: clamp(260px, 33svh, 300px); }
    .catalog-content .canvas-wrap { height: var(--mobile-figure-height); }
  }
}
