/* The cutaway uses layer tint for depth and one accent for paths and selection. */
.model-guide { --guide-blood: #923c31; max-width: 1320px; padding-bottom: 48px; }
:root[data-theme="dark"] .model-guide { --guide-blood: #e79a86; }
.guide-layout { display: grid; grid-template-columns: minmax(166px, .21fr) minmax(0, 1fr); gap: clamp(16px, 3vw, 36px); align-items: start; }
.guide-content { min-width: 0; display: grid; gap: 16px; }
.model-guide { padding-top: clamp(18px,4vw,44px); }
.guide-content h1 { font-size: clamp(26px,3.7vw,40px); }
.guide-toc a[aria-current="page"] { background: var(--tint); border-inline-start: 2px solid var(--accent); padding-inline-start: 8px; font-weight: 700; }
.guide-pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.guide-pager a:last-child { margin-inline-start: auto; }
.model-guide .anatomy-figure { max-width: 760px; margin: 14px auto 0; }
.anatomy-figure canvas, .anatomy-figure svg { display: block; width: 100%; height: auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.anatomy-figure canvas { height: clamp(226px,40vw,390px); cursor: grab; touch-action: pan-y; }
.tissue-3d { cursor: grab; touch-action: pan-y; }
.anatomy-figure canvas:active { cursor: grabbing; }
.anatomy-figure [hidden] { display: none; }
.anatomy-stage { display: flex; flex-direction: column; gap: 8px; }
.anatomy-render { min-width: 0; }
#layer-volume-controls { display: grid; gap: 5px; }
#anatomy-details { margin-top: 8px; }
@media(min-width: 1240px) {
  .anatomy-stage { flex-direction: row-reverse; align-items: center; gap: 12px; }
  .anatomy-render { flex: 1 1 auto; }
  #layer-volume-controls { flex: 0 0 175px; }
  #layer-volume-controls .anatomy-angles { grid-template-columns: 1fr; }
}
.anatomy-toolbar, #anatomy-parts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.anatomy-toolbar select { max-width: 100%; }
.anatomy-toolbar button { margin-inline-start: auto; }
.anatomy-angles { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px 14px; }
.anatomy-angles label { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.anatomy-angles input { grid-column: 1/-1; width: 100%; margin: 0; min-height: 44px; accent-color: var(--accent); }
#anatomy-parts label { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; }
#anatomy-parts input { accent-color: var(--accent); }
#anatomy-note { min-height: 38px; }
@media(max-width:480px) { .anatomy-angles { grid-template-columns: minmax(0,1fr); } }
.guide-toc { position: sticky; top: 16px; align-self: start; border-inline-start: 2px solid var(--line); padding-inline-start: 13px; }
.guide-toc summary { font-size: 15px; cursor: pointer; }
.guide-toc ol { margin: 8px 0 0; padding-inline-start: 20px; font-size: 13px; color: var(--soft-ink); }
.guide-toc a { display: block; min-height: 44px; padding: 8px 2px; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.guide-content h2[id] { scroll-margin-top: 18px; }
.guide-chapter header > p { color: var(--soft-ink); max-width: 65em; }
.guide-reading { margin-top: 22px; padding: 15px 0 0; border-top: 1px solid var(--line); }
.reading-links { display:flex; flex-wrap:wrap; gap:4px 16px; margin-top:12px; }
.reading-links a { display:inline-flex; align-items:center; min-height:44px; }
.result-guide .guide-reading > p, .guide-inverse .guide-reading > p,
.result-guide details > p { max-width:68ch; line-height:1.75; margin-block:9px; }
.result-guide .guide-reading[id], .guide-inverse .guide-reading[id] { scroll-margin-top:18px; }
.guide-inverse .lesson-grid { stroke:var(--soft-ink); stroke-dasharray:4 3; fill:none; }
.walkthrough-keyfacts, .walkthrough-actions, .walkthrough-steps { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; }
.walkthrough-keyfacts span { border-inline-start: 2px solid var(--accent); padding-inline-start: 8px; color: var(--soft-ink); }
.walkthrough-keyfacts strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.walkthrough-steps a { display: inline-flex; align-items: center; min-height: 44px; }
.walkthrough-units { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.walkthrough pre { overflow: auto; max-width: 100%; padding: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.walkthrough code { overflow-wrap: anywhere; }
.walkthrough-phase { display: flex; flex-wrap: wrap; gap: 6px 22px; padding-inline-start: 25px; color: var(--ink); font-weight: 650; }
.walkthrough .guide-reading { scroll-margin-top: 18px; }
#walk-video video { display: block; width: 100%; height: auto; aspect-ratio: 16/9; margin-top: 12px; background: var(--mast); border-radius: var(--radius); }
#walk-video video::cue { background: var(--mast); color: var(--mast-ink); }
#walk-transcript { margin-top: 12px; }
#walk-transcript li + li { margin-top: 6px; }
#walk-transcript time { font-variant-numeric: tabular-nums; color: var(--soft-ink); margin-inline-end: 6px; }
@media (max-width: 600px) { .walkthrough-units { grid-template-columns: minmax(0,1fr); } }
.structure-index { display: flex; flex-wrap: wrap; gap: 5px 15px; margin-top: 12px; }
.structure-index a { display: inline-flex; align-items: center; min-height: 44px; }
.structural-topic { scroll-margin-top: 18px; }
.structure-figures { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; align-items: start; margin-top: 14px; }
.structure-figure, .structure-setting, .structure-data { min-width: 0; }
.structure-figure svg, .structure-data svg { display: block; width: 100%; height: auto; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.structure-figure svg text, .structure-data svg text { fill: currentColor; font-size: 14px; }
.structure-figure svg circle { fill: currentColor; }
.structure-figure[data-structure-scene] svg { cursor: grab; touch-action: pan-y; }
.structure-plane { fill: var(--tint); stroke: var(--soft-ink); stroke-width: 1; }
.structure-guide { fill: none; stroke: var(--soft-ink); stroke-width: 1; stroke-dasharray: 4 3; }
.structure-axis, .structure-ray { fill: none; stroke: currentColor; stroke-width: 1.5; }
.structure-ray { stroke-width: 2; }
.structure-path, .structure-wire, .structure-tube, .structure-zero { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.structure-path { stroke-width: 3; }
.structure-tube { stroke: var(--guide-blood); }
.structure-tissue { fill: var(--tint); stroke: var(--line); }
.structure-epi { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
.structure-share-track { fill:none; stroke:var(--soft-ink); }
.structure-share-fill { fill:var(--accent); }
.structure-rotate { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; font-size: 13px; }
.structure-rotate label { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; }
.structure-rotate input { flex: 1; width: 0; min-height: 44px; accent-color: var(--accent); }
.structure-rotate output { min-width: 42px; font-variant-numeric: tabular-nums; }
.structure-setting { padding: 10px 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.structure-setting-caption, .structure-setting-bounds { display:flex; flex-wrap:wrap; justify-content:space-between; gap:4px 12px; align-items:baseline; }
.structure-setting-caption output { font-weight:700; font-variant-numeric:tabular-nums; }
.structure-setting input { display:block; width:100%; min-height:44px; margin:0; padding:0; background:none; border:0; accent-color:var(--accent); }
.structure-setting-bounds { color:var(--soft-ink); font-size:.8rem; }
.structure-data .optics-legend { margin: 5px 0; }
.structure-chapter code { overflow-wrap: anywhere; }
@media (max-width: 650px) {
  .structure-figures { grid-template-columns: minmax(0,1fr); }
  .structure-figure svg text, .structure-data svg text { font-size: 16px; }
}
.lesson-diagram { max-width: 640px; margin-top: 12px; }
.lesson-diagram svg { display: block; width: 100%; height: auto; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.lesson-diagram text { fill: currentColor; font-size: 15px; }
.lesson-stroke { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.lesson-primary { fill: var(--accent); }
.lesson-secondary { fill: var(--soft-ink); }
.lesson-muted { fill: var(--line); }
.lesson-trace { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.lesson-trace.alternative { stroke: currentColor; stroke-dasharray: 5 4; }
.guide-table th[scope="row"] { font-weight: 620; }
.guide-reading h3, .guide-explanations h3, .optics-widget > h3 { font-size: 16px; }
.collagen-mechanism { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 7px; margin-top: 9px; padding: 9px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--ink); font-size: 13px; }
.collagen-mechanism b { color: var(--accent); }
@media (max-width: 510px) {
  .collagen-mechanism { grid-template-columns: minmax(0,1fr); text-align: center; }
  .collagen-mechanism b { transform: rotate(90deg); justify-self: center; }
}
.guide-reading p, .guide-explanations p { margin-top: 7px; line-height: 1.7; }
.appearance-swatches { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-block: 10px; }
.appearance-sample { min-width: 0; display: flex; flex-direction: column; align-items: stretch; text-align: left; gap: 4px; }
.appearance-sample[aria-pressed='true'] { border-color: var(--accent); background: var(--tint); }
.appearance-sample small { color: var(--soft-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.appearance-chip { height: clamp(45px,8vw,85px); border: 1px solid var(--line); border-radius: 5px; }
.appearance-chart { min-width: 0; margin: 8px 0; }
.appearance-chart svg { display: block; width: 100%; height: auto; min-width: 0; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.appearance-chart svg text { fill: currentColor; font-size: 14px; }
.appearance-zero { stroke: var(--soft-ink); stroke-width: 1.3; }
.appearance-peak { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.appearance-inactive { stroke-width: 1.4; }
.appearance-explanation { padding: 7px 10px; background: var(--tint); border-inline-start: 2px solid var(--accent); font-size: 13px; }
@media(max-width:480px) {
  .appearance-swatches { gap: 4px; }
  .appearance-sample { padding-inline: 5px; }
  .appearance-chart svg text { font-size: 16px; }
}
.guide-field-controls { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: end; }
.guide-field-controls label, .guide-catalog-layout > label { display: grid; gap: 4px; min-width: 0; font-size: 13px; font-weight: 650; }
.guide-field-controls label:first-child { flex: 1 1 215px; }
.guide-field-controls select, .guide-catalog-layout select, .guide-field-controls input { width: 100%; max-width: 100%; min-height: 44px; }
.guide-field-controls input[type="search"] { border: 1px solid var(--line); background: var(--bg); border-radius: 7px; padding: 8px; }
.guide-catalog-layout { display: grid; grid-template-columns: minmax(140px, .33fr) minmax(0,1fr); gap: 12px; margin-top: 8px; align-items: start; }
.guide-field-detail { min-width: 0; border-inline-start: 2px solid var(--accent); padding-inline-start: 12px; overflow-wrap: anywhere; }
.guide-field-detail dl { display: grid; grid-template-columns: minmax(60px,auto) minmax(0,1fr); gap: 5px 10px; margin-top: 7px; }
.guide-field-detail dt { color: var(--soft-ink); font-size: 13px; }
.guide-field-detail dd { font-size: 14px; }
.guide-long-table { max-height: 370px; }
.guide-long-table .guide-table tbody th { min-width: 140px; }
.guide-demo { border: 1px solid var(--line); border-radius: var(--radius); margin-top: 12px; padding: clamp(9px,2vw,15px); min-width: 0; }
.guide-demo-head { display: grid; grid-template-columns: 1fr minmax(150px, .8fr); gap: 9px; align-items: center; }
.guide-demo-head label { display: grid; grid-template-columns: 1fr auto; font-size: 13px; gap: 4px; }
.guide-demo-head input { grid-column: 1/-1; min-height: 44px; width: 100%; accent-color: var(--accent); }
.guide-demo-head output { font-variant-numeric: tabular-nums; }
#guide-mechanism-plot, .sample-charts svg { display: block; width: 100%; height: auto; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
#guide-mechanism-plot text, .sample-charts svg text { fill: currentColor; font-size: 14px; }
.vessel-example { stroke: var(--guide-blood); stroke-width: 2; }
#sample-metrics { display: grid; grid-template-columns: minmax(0,.8fr) minmax(0,1.2fr); gap: 12px; margin: 10px 0; align-items: start; }
#sample-metrics .guide-table { table-layout: fixed; }
#sample-metrics .guide-table th, #sample-metrics .guide-table td { min-width: 0; white-space: normal; }
.sample-charts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.sample-charts h3 { margin-bottom: 5px; }
.sample-held { fill: var(--bg); stroke: var(--ink); stroke-width: 1.2; }
@media (max-width: 600px) {
  .guide-catalog-layout, .guide-demo-head, .sample-charts, #sample-metrics { grid-template-columns: minmax(0,1fr); }
  #guide-mechanism-plot text, .sample-charts svg text { font-size: 16px; }
}
.guide-explanations { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin-top: 19px; }
.guide-explanations article { border-top: 1px solid var(--line); padding-top: 9px; }
.tissue-figures { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 14px; margin-top: 16px; }
.tissue-2d, .tissue-3d { display: block; width: 100%; height: auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.tissue-2d text { fill: currentColor; font-size: 13px; }
.tissue-matrix { fill: var(--tint); stroke: var(--soft-ink); stroke-width: 1; }
.tissue-frame { fill: none; stroke: var(--soft-ink); stroke-width: 1; stroke-dasharray: 4 3; }
.tissue-vessel { fill: var(--surface); stroke: var(--guide-blood); stroke-width: 3; }
.tissue-vessel-tube { fill: none; stroke: var(--guide-blood); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.tissue-bundle { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.tissue-light { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-dasharray: 5 2; }
.tissue-leader { fill: none; stroke: var(--soft-ink); stroke-width: 1; }
.tissue-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; }
.tissue-legend span { display: inline-flex; align-items: center; gap: 4px; }
.tissue-legend i { width: 15px; height: 5px; }
.legend-vessel { background: var(--guide-blood); border-radius: 2px; }
.legend-bundle { border-block: 1px solid var(--accent); }
.legend-matrix { border: 1px solid var(--soft-ink); background: var(--tint); }
.tissue-controls { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 0 8px; align-items: center; margin-top: 8px; }
.tissue-controls button { grid-row: 1 / span 2; min-width: 44px; }
#tissue-left { grid-column: 1; }
#tissue-right { grid-column: 3; }
.tissue-controls label { grid-area: 1 / 2; font-size: 12px; }
.tissue-controls input { grid-area: 2 / 2; width: 100%; min-height: 28px; margin: 0; accent-color: var(--accent); }
.tissue-controls output { margin-inline-start: 5px; font-variant-numeric: tabular-nums; }
.optics-widget { margin-top: 17px; padding: clamp(10px, 2vw, 17px); border: 1px solid var(--line); border-radius: var(--radius); }
.optics-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-weight: 650; }
.optics-toolbar select { max-width: 100%; }
.optics-chart { min-width: 0; margin-top: 7px; }
.optics-chart svg { display: block; width: 100%; height: 244px; font-size: 11px; color: var(--soft-ink); }
.optics-chart text { fill: currentColor; }
.optics-grid { stroke: var(--grid); }
.optics-line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.optics-series-0 { stroke: var(--measured); }
.optics-series-1 { stroke: var(--fitted); stroke-dasharray: 5 3; }
.optics-direct { fill: var(--ink); stroke: var(--surface); stroke-width: 2.5; paint-order: stroke; }
.optics-cursor { stroke: var(--soft-ink); stroke-dasharray: 2 4; pointer-events: none; }
.optics-legend { display: flex; flex-wrap: wrap; gap: 4px 13px; font-size: 12px; }
.optics-legend span { display: flex; gap: 5px; align-items: center; }
.optics-legend i { width: 18px; border-bottom: 2px solid var(--measured); }
.optics-legend .optics-series-1 { border-bottom: 2px dashed var(--fitted); }
.optics-readout, .guide-source { color: var(--soft-ink); font-size: 12px; overflow-wrap: anywhere; }
.optics-readout { display: block; min-height: 28px; }
.guide-source { margin-top: 6px; }
.optics-table { max-height: 260px; }
.guide-table-wrap { overflow: auto; margin: 12px 0 6px; }
.guide-table th, .guide-table td { vertical-align: top; min-width: 110px; }
.guide-table td { line-height: 1.6; }
.guide-table tbody th { position: static; white-space: normal; background: var(--bg); }
@media (max-width: 560px) {
  .guide-table th, .guide-table td { min-width: 0; padding-inline: 6px; }
  .guide-table thead th { white-space: normal; }
  .guide-table tbody th { width: 23%; }
}
.guide-table caption { margin-bottom: 4px; }
.guide-example-table th, .guide-example-table td { min-width: 0; }
.guide-chapter .button { margin-top: 10px; }
.model-guide h2 { font-size: clamp(19px, 3vw, 23px); line-height: 1.35; }
.model-guide header > p { margin-top: 8px; }
.guide-structure header > p, .guide-forward header > p { color: var(--soft-ink); }
.guide-cutaway { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(16px, 3vw, 36px); align-items: start; margin-top: 20px; }
.guide-figure { min-width: 0; margin: 0; }
.guide-diagram { display: block; width: 100%; height: auto; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.guide-diagram text { font-size: 14px; fill: currentColor; }
.guide-diagram .guide-svg-note { font-size: 12px; fill: var(--soft-ink); }
.guide-region rect { stroke: var(--soft-ink); stroke-width: .8; }
.guide-epidermis rect { fill: var(--surface); }
.guide-dermis rect { fill: var(--tint); }
.guide-subcut rect { fill: var(--bg); }
.guide-region.is-active rect { stroke: var(--accent); stroke-width: 2.5; }
.guide-region.is-active text { font-weight: 720; }
.guide-slices { stroke: var(--line); fill: none; }
.guide-ray, .guide-direction, #guide-arrow { color: var(--accent); }
.guide-ray .guide-branch { stroke-dasharray: 4 3; marker-end: none; }
.guide-ray .guide-through { marker-end: url(#guide-arrow); }
.guide-direction circle { fill: var(--surface); stroke: currentColor; stroke-width: 2; }
.guide-loss { fill: none; stroke: var(--ink); stroke-width: 2; }
.guide-figure figcaption, .guide-note { color: var(--soft-ink); font-size: 13px; margin-top: 8px; }
.guide-layer-copy { display: grid; gap: 12px; }
.guide-layer-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.guide-layer-controls button { min-width: 0; padding-inline: 5px; }
.guide-layer-controls button[aria-pressed="true"] { background: var(--tint); border-color: var(--accent); box-shadow: inset 0 -2px var(--accent); }
.guide-layer-detail { border-inline-start: 2px solid var(--accent); padding-inline-start: 12px; }
.guide-layer-detail:not([hidden]) + .guide-layer-detail:not([hidden]) { margin-top: 13px; }
.guide-layer-detail p, .guide-flow p { margin-top: 5px; }
.guide-layer-detail h3, .guide-flow h3 { font-size: 16px; }
.guide-layer-detail p, .guide-flow p, .guide-inverse p { line-height: 1.7; }
.guide-forward { margin: 28px 0; }
/* Step labels name the input and output of each stage. */
.guide-flow { list-style: none; padding: 0; margin: 15px 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.guide-flow li { border-top: 2px solid var(--accent); padding-top: 9px; }
.guide-step-link { color: var(--accent); font-size: 13px; font-weight: 650; }
.guide-flow h3 { margin-top: 3px; }
.guide-settings { margin-top: 18px; }
.guide-settings p { color: var(--soft-ink); max-width: 64em; }
.guide-inverse p { max-width: 66em; margin: 8px 0 12px; }
@media (max-width: 860px) {
  .guide-layout { grid-template-columns: minmax(0,1fr); }
  .guide-toc { position: static; }
  .guide-toc ol { columns: 2; }
  .guide-toc li { break-inside: avoid; }
}
@media (max-width: 700px) {
  .guide-cutaway, .guide-flow, .tissue-figures, .guide-explanations { grid-template-columns: minmax(0, 1fr); }
  .guide-figure { max-width: 500px; }
  .guide-forward { margin-block: 0; }
  .guide-flow { gap: 12px; }
}
@media (max-width: 350px) { .guide-toc ol { columns: 1; } }
@media (forced-colors: active), print {
  .optics-line { stroke: CanvasText; }
  .optics-legend i { border-color: CanvasText; }
  .tissue-vessel-tube { stroke: CanvasText; }
  .tissue-bundle { stroke: Highlight; }
}
@media (max-width: 450px) { .model-guide-header .brand span { display: none; } }
@media (forced-colors: active) {
  .guide-region rect { fill: Canvas; stroke: CanvasText; }
  .guide-region.is-active rect { stroke: Highlight; }
  .guide-ray, .guide-direction, #guide-arrow { color: CanvasText; }
}
