/* Robot-only components. Shared colour, type, navigation, and gutters live in
   theme.css and project.css. Keep the model readable at narrow widths. */
.interface-body {
  --interface-ink: var(--text);
  --interface-muted: var(--muted);
  --interface-cyan: var(--a);
  --interface-violet: var(--b);
}
.notebook__lede { margin-top: 28px; color: var(--muted); font-size: 17px; line-height: 1.85; }
.notebook__lede p { margin: 0 0 20px; text-align: justify; text-align-last: left; }
.notebook__lede p:last-child { margin-bottom: 0; }
.notebook-topics { border: 1px solid var(--stroke); border-radius: 16px; background: var(--surface); }
.notebook-topics__picker { display: none; position: relative; z-index: 2; min-width: 0; padding: 20px; }
.notebook-topics__label { margin: 0 0 12px; color: var(--muted2); font: 500 10px/1.5 ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.notebook-topics__trigger { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 14px 16px; border: 1px solid var(--stroke); border-radius: 10px; background: var(--surface-deep); color: var(--text); font: 500 15px/1.5 Inter, sans-serif; text-align: left; cursor: pointer; transition: border-color .2s ease; }
.notebook-topics__trigger:hover, .notebook-topics__trigger[aria-expanded="true"] { border-color: var(--a); }
.notebook-topics__number { flex-shrink: 0; color: var(--a); font: 11px/1.5 ui-monospace, monospace; }
.notebook-topics__trigger svg { flex-shrink: 0; margin-left: auto; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
.notebook-topics__trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.notebook-topics__menu { position: absolute; top: calc(100% - 12px); left: 20px; right: 20px; max-height: 60vh; max-height: min(380px, 60svh); overflow-y: auto; padding: 6px; border: 1px solid var(--stroke); border-radius: 12px; background: var(--surface); box-shadow: 0 18px 48px rgba(0, 0, 0, .55); }
.notebook-topics__menu button { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 48px; padding: 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font: 400 14px/1.5 Inter, sans-serif; text-align: left; cursor: pointer; }
.notebook-topics__menu button:hover, .notebook-topics__menu button:focus-visible { background: rgba(130, 168, 255, .06); color: var(--text); }
.notebook-topics__menu button:focus-visible { outline-offset: -2px; }
.notebook-topics__menu button[aria-checked="true"] { background: rgba(130, 168, 255, .1); color: var(--text); }
.notebook-topics__menu button[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--a); }
.notebook-topics__rail { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding: 10px; }
.notebook-topic { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 72px; padding: 16px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); font: 500 13px/1.4 Inter, sans-serif; text-align: left; cursor: pointer; transition: border-color .2s ease, background .2s ease, color .2s ease; }
.notebook-topic span { color: var(--muted2); font: 10px ui-monospace, monospace; }
.notebook-topic:hover, .notebook-topic:focus-visible { border-color: rgba(130, 168, 255, .3); background: rgba(130, 168, 255, .05); color: var(--text); }
.notebook-topic[aria-expanded="true"] { border-color: rgba(130, 168, 255, .4); background: rgba(130, 168, 255, .09); color: var(--text); }
.notebook-topic[aria-expanded="true"] span { color: var(--a); }
.notebook-panel { margin-top: 4px; padding: clamp(24px, 4vw, 48px); min-width: 0; border-top: 1px solid var(--stroke); opacity: 0; transform: translateY(12px); transition: opacity .35s ease, transform .35s ease; }
.notebook-panel.is-open { opacity: 1; transform: none; }
.notebook-panel__heading > p, .model-eyebrow { margin: 0 0 16px; color: var(--a); font: 500 10px/1.5 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.notebook-panel__heading h2 { margin: 0; text-wrap: balance; }
.notebook-panel__prose { margin-top: 28px; color: var(--muted); font-size: 16px; line-height: 1.85; }
.notebook-panel__prose p { margin: 0 0 18px; text-align: justify; text-align-last: left; }
.notebook-panel__prose p:last-child { margin-bottom: 0; }
.notebook-topic-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 36px; }
.notebook-topic-link { display: block; width: fit-content; max-width: 100%; min-width: 0; padding-block: 10px; color: var(--a); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; text-decoration: underline; text-decoration-color: var(--stroke); text-underline-offset: 4px; transition: color .2s ease, text-decoration-color .2s ease; }
.notebook-topic-link[data-topic-previous] { grid-column: 1; justify-self: start; }
.notebook-topic-link[data-topic-next] { grid-column: 2; justify-self: end; text-align: right; }
.notebook-topic-link:hover { color: var(--text); text-decoration-color: var(--a); }
.notebook-figure { margin: 36px 0; overflow: hidden; border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface-deep); }
.notebook-figure a { display: block; padding: 12px; background: #f5f6fa; }
.notebook-figure img { width: 100%; }
.notebook-figure figcaption, .notebook-pcb-grid figcaption { padding: 16px 20px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.notebook-figure figcaption strong { color: var(--text); font-weight: 500; }
.notebook-schematic { min-width: 0; margin-top: 40px; }
.notebook-schematic__heading { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 16px 24px; }
.notebook-schematic__heading > div { min-width: 0; }
.notebook-schematic h3, .notebook-lessons h3 { margin: 0; color: var(--text); font-size: clamp(21px, 2.5vw, 26px); font-weight: 500; letter-spacing: -.03em; line-height: 1.3; }
.notebook-schematic__heading p { margin: 10px 0 0; color: var(--muted2); font-size: 12px; line-height: 1.6; }
.notebook-schematic__links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.notebook-schematic__links a, .notebook-schematic__preview figcaption a { padding-block: 8px; color: var(--a); font-size: 13px; line-height: 1.6; text-decoration: underline; text-decoration-color: var(--stroke); text-underline-offset: 3px; transition: color .2s ease, text-decoration-color .2s ease; }
.notebook-schematic__links a:hover, .notebook-schematic__preview figcaption a:hover { color: var(--text); text-decoration-color: var(--a); }
.notebook-schematic__sheets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.notebook-schematic__sheets button { min-height: 44px; padding: 10px 14px; border: 1px solid var(--stroke); border-radius: 8px; background: transparent; color: var(--muted); font: 400 13px/1.5 Inter, sans-serif; cursor: pointer; transition: color .2s ease, background .2s ease, border-color .2s ease; }
.notebook-schematic__sheets button:hover { border-color: var(--a); color: var(--text); }
.notebook-schematic__sheets button[aria-pressed="true"] { border-color: var(--a); background: rgba(130, 168, 255, .09); color: var(--text); font-weight: 500; }
.notebook-schematic__preview { min-width: 0; margin: 18px 0 0; overflow: hidden; border: 1px solid var(--stroke); border-radius: 12px; background: var(--surface-deep); }
.notebook-schematic__image-link { display: block; padding: clamp(6px, 1.5vw, 12px); background: #f5f6fa; cursor: zoom-in; }
.notebook-schematic__preview .notebook-schematic__image-link:focus-visible { outline-offset: -3px; }
.notebook-schematic__preview img { display: block; width: 100%; height: auto; object-fit: contain; }
.notebook-schematic__preview figcaption { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px; color: var(--muted2); font-size: 12px; line-height: 1.7; }
.notebook-pcb-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 36px; }
.notebook-pcb-grid figure { min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface-deep); }
.notebook-pcb-grid a { display: block; padding: 12px; background: #f5f6fa; }
.notebook-pcb-grid img { width: 100%; aspect-ratio: 13 / 20; object-fit: contain; }
.notebook-lessons { min-width: 0; margin-top: 40px; padding: 28px; border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface-deep); }
.notebook-lessons ol { display: grid; gap: 28px; margin: 28px 0 0; padding-left: 24px; }
.notebook-lessons li { min-width: 0; padding-left: 6px; overflow-wrap: anywhere; }
.notebook-lessons li::marker { color: var(--a); font: 12px/1.5 ui-monospace, monospace; }
.notebook-lessons h4 { margin: 0; color: var(--text); font-size: 16px; font-weight: 500; line-height: 1.5; }
.notebook-lessons p { margin: 10px 0 0; color: var(--muted); font-size: 15px; line-height: 1.85; text-align: justify; text-align-last: left; }

/* Mechanical CAD views retain their full framing; portrait views stay compact. */
.mechanical-section { min-width: 0; margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--stroke); }
.mechanical-section h3 { margin: 0; color: var(--text); font-size: clamp(21px, 2.5vw, 26px); font-weight: 500; letter-spacing: -.03em; line-height: 1.3; }
.mechanical-figure { min-width: 0; }
.mechanical-figure--portrait { max-width: 450px; margin-inline: auto; }
.mechanical-figure--assembly { max-width: 700px; margin-inline: auto; }
.mechanical-figure a { cursor: zoom-in; }
.mechanical-figure a:focus-visible { outline-offset: -3px; }
.mechanical-figure img { height: auto; object-fit: contain; }
.mechanical-section > .mechanical-figure:last-child { margin-bottom: 0; }

/* Source diagrams and full-width derivation, followed by the simulation study. */
.model-conventions { margin: 30px 0 48px; padding: 4px 0 4px 20px; border-left: 2px solid var(--a); color: var(--muted); font-size: 14px; line-height: 1.85; }
.model-derivation { margin-top: clamp(32px, 4vw, 48px); }
.model-section { min-width: 0; }
.model-section + .model-section, .model-simulation { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--stroke); }
.model-section h3, .model-results h4 { margin: 0; color: var(--text); font-size: clamp(23px, 2.8vw, 30px); font-weight: 500; letter-spacing: -.035em; line-height: 1.3; }
.model-section h4 { margin: 0; color: var(--text); font-size: 20px; font-weight: 500; letter-spacing: -.025em; line-height: 1.4; }
.model-section p { margin: 18px 0 0; color: var(--muted); font-size: 15px; line-height: 1.85; text-align: justify; text-align-last: left; }
.model-section .model-eyebrow { margin: 0 0 16px; color: var(--a); font: 500 10px/1.5 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.model-conventions var, .model-section var { color: var(--text); font-family: "Cambria Math", Cambria, serif; }
.model-subsection { margin-top: 36px; }
.model-fbd { width: 100%; max-width: 640px; margin: 28px auto 32px; overflow: hidden; border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface-deep); }
.model-fbd a { display: block; padding: clamp(8px, 2vw, 16px); background: #f5f6fa; }
.model-fbd img { display: block; width: 100%; height: auto; object-fit: contain; }
.model-fbd figcaption { padding: 16px 20px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.model-callout { margin-top: 28px; padding: 22px; border-left: 2px solid var(--a); border-radius: 0 12px 12px 0; background: var(--surface-deep); }
.model-callout p { font-size: 14px; }
.model-stage__index { display: block; margin-bottom: 12px; color: var(--b); font: 11px/1.5 ui-monospace, monospace; }
.model-equation { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; margin: 24px 0; padding-top: 20px; border-top: 1px solid var(--stroke); text-align: center; }
.model-equation--pair { gap: 18px; }
.model-equation__row { display: grid; grid-template-columns: 3em minmax(0, 1fr) 3em; column-gap: 12px; align-items: center; min-width: 0; scroll-margin-top: 110px; }
.model-equation__row > .model-equation__viewport, .model-equation__row > math { grid-column: 2; }
.model-equation__row > math { margin: 0 auto; }
.model-equation__number { grid-column: 3; justify-self: end; padding-block: 6px; color: var(--muted2); font: 12px/1.5 ui-monospace, monospace; white-space: nowrap; transition: color .2s ease; }
.model-equation__number:hover { color: var(--a); }
.model-equation-ref, .model-results a { color: var(--a); text-decoration: underline; text-decoration-color: var(--stroke); text-underline-offset: 3px; transition: color .2s ease, text-decoration-color .2s ease; }
.model-equation-ref:hover, .model-results a:hover { color: var(--text); text-decoration-color: var(--a); }
.model-equation math { display: block; padding-block: 8px; color: var(--text); font-family: "Cambria Math", Cambria, serif; }
.model-equation--conditions { gap: 12px; }
.model-equation--conditions math { font-size: clamp(16px, 2vw, 20px); }
.model-details { margin-top: 28px; border: 1px solid var(--stroke); border-radius: 12px; background: var(--surface-deep); }
.model-details summary { padding: 18px 20px; color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; }
.model-details > div { padding: 0 20px 20px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.model-details p { margin: 0 0 12px; text-align: justify; text-align-last: left; }
.model-details p:last-child { margin: 0; }

/* Fit at a readable size first; reflow long formulas instead of scrolling. */
.model-equation__viewport { --equation-max-size: 22px; --equation-min-size: 16px; width: 100%; min-width: 0; }
.model-equation__viewport math { display: block; width: max-content; max-width: none; margin: 0 auto; padding-block: 8px; color: var(--text); font-family: "Cambria Math", Cambria, serif; font-size: var(--equation-size, var(--equation-max-size)); }
.model-equation__viewport .model-equation__compact { display: none; }
.model-equation__viewport.is-multiline .model-equation__wide { display: none; }
.model-equation__viewport.is-multiline .model-equation__compact { display: block; }

.model-simulation__inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 32px; margin: 28px 0; padding-block: 24px; border-block: 1px solid var(--stroke); }
.model-simulation__inputs > div { min-width: 0; overflow-wrap: anywhere; }
.model-simulation__inputs dt { color: var(--muted2); font: 10px/1.5 ui-monospace, monospace; letter-spacing: .06em; text-transform: uppercase; }
.model-simulation__inputs dd { margin: 8px 0 0; color: var(--text); font-size: 14px; line-height: 1.6; }

.model-results { margin-top: 40px; padding: 28px; border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface-deep); }
@media (max-width: 850px) {
  .notebook-topics__rail { display: none; }
  .notebook-topics__picker { display: block; }
  .notebook-pcb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .notebook__lede { font-size: 16px; }
  .notebook-panel { padding: 22px 18px; }
  .model-section + .model-section, .model-simulation { margin-top: 36px; padding-top: 30px; }
  .model-stage__index { font-size: 10px; }
  .model-callout, .model-results, .notebook-lessons { padding: 18px; }
  .model-fbd figcaption { padding: 14px 16px; }
  .model-simulation__inputs, .notebook-pcb-grid { grid-template-columns: 1fr; }
  .model-equation__row { grid-template-columns: minmax(0, 1fr); row-gap: 4px; }
  .model-equation__row > .model-equation__viewport, .model-equation__row > math, .model-equation__number { grid-column: 1; }
  .model-equation__viewport:not(.is-fitted) { --equation-size: var(--equation-min-size); }
  .model-equation__viewport:not(.is-fitted) .model-equation__wide { display: none; }
  .model-equation__viewport:not(.is-fitted) .model-equation__compact { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .notebook-panel { transition: none; transform: none; }
}
