/* Scientific modeling only. Append scientific-modeling-reader to body;
   directory also uses scientific-modeling-index. Load after existing CSS.
   No runtime, new storage keys, imports, or changes to shared assets. */
body.scientific-modeling-reader {
  color-scheme:light;
  --bg:#f8f7f3; --fg:#282b26; --muted:#62675e; --card:#fffefa;
  --border:#dadfd4; --accent:#ad4727; --accent-soft:#f6e9df;
  --link:#345f71; --quote-bg:#eef0e7;
  --done:#466346; --danger:#ad3631; --shadow:none;
  --sc-sage:#edf2e9; --sc-sage-ink:#466346; --sc-sage-border:#cbd8c5;
  --sc-prose:18px; --sc-offset:84px;
  margin:0; background:var(--bg); color:var(--fg);
  font:var(--sc-prose)/1.9 "PingFang SC","Microsoft YaHei","Noto Sans SC",system-ui,sans-serif;
  -webkit-font-smoothing:antialiased;
}
html[data-theme="dark"] > body.scientific-modeling-reader {
  color-scheme:dark;
  --bg:#1c201b; --fg:#eeeee5; --muted:#b0b8a8; --card:#252b23;
  --border:#46513f; --accent:#efa17f; --accent-soft:#3b2d25;
  --link:#a0c1ce; --quote-bg:#2a3326; --done:#b1c7a9; --danger:#f5a396;
  --sc-sage:#2a3627; --sc-sage-ink:#b1c7a9; --sc-sage-border:#4b5e41;
}
@media (prefers-color-scheme:dark) {
  html:not([data-theme="light"]) > body.scientific-modeling-reader {
    color-scheme:dark;
    --bg:#1c201b; --fg:#eeeee5; --muted:#b0b8a8; --card:#252b23;
    --border:#46513f; --accent:#efa17f; --accent-soft:#3b2d25;
    --link:#a0c1ce; --quote-bg:#2a3326; --done:#b1c7a9; --danger:#f5a396;
    --sc-sage:#2a3627; --sc-sage-ink:#b1c7a9; --sc-sage-border:#4b5e41;
  }
}
body.scientific-modeling-reader [hidden] { display:none!important; }
body.scientific-modeling-reader :is(a,button,input,select,textarea,summary,[tabindex]):focus-visible { outline:3px solid var(--accent); outline-offset:4px; }
body.scientific-modeling-reader :is(h1,h2,h3,h4,section,main,figure,span,div)[id] { scroll-margin-top:var(--sc-offset); }
body.scientific-modeling-reader a { color:var(--link); text-underline-offset:.22em; }
body.scientific-modeling-reader .sc-skip-link { position:fixed; z-index:300; top:8px; left:12px; transform:translateY(-200%); padding:10px 16px; border:1px solid var(--accent); border-radius:6px; background:var(--card); color:var(--fg); }
body.scientific-modeling-reader .sc-skip-link:focus { transform:none; }
body.scientific-modeling-reader :is(button,input,select,textarea) { font-family:inherit; }
body.scientific-modeling-reader ::selection { background:var(--accent); color:var(--bg); }
body.scientific-modeling-reader #scrollbar { height:3px; background:var(--accent); }
body.scientific-modeling-reader header.site { padding:0 24px; opacity:1; box-shadow:none; background:var(--bg); }
body.scientific-modeling-reader header.site .inner { max-width:1040px; height:auto; min-height:60px; gap:14px; font-size:14px; }
body.scientific-modeling-reader header.site a { color:var(--fg); }
body.scientific-modeling-reader header.site .title { padding-left:14px; text-align:left; border-left:1px solid var(--border); }
body.scientific-modeling-reader header.site :is(a,button) { display:inline-flex; align-items:center; justify-content:center; min-height:44px; }
body.scientific-modeling-reader header.site button { font:inherit; padding:6px 10px; border-radius:8px; }
body.scientific-modeling-reader header.site .prevnext { display:flex; gap:2px; }
body.scientific-modeling-reader header.site .prevnext a { min-width:44px; border-radius:6px; }
body.scientific-modeling-reader header.site :is(a,button):hover { color:var(--accent); background:var(--accent-soft); }
body.scientific-modeling-reader header.site button.done,
body.scientific-modeling-reader .donebar button.done { background:var(--done); color:var(--bg); border-color:var(--done); }

body.scientific-modeling-reader main { max-width:824px; margin:0 auto; padding:44px 32px 96px; min-width:0; }
body.scientific-modeling-reader.overview-reading main { max-width:1080px; }
body.scientific-modeling-reader .ov-layout { display:grid; grid-template-columns:minmax(0,760px) 216px; gap:40px; align-items:start; }
body.scientific-modeling-reader .ov-body { min-width:0; width:100%; }
body.scientific-modeling-reader main :is(p,li,dd) { line-height:1.9; overflow-wrap:anywhere; }
body.scientific-modeling-reader main p { margin:1em 0; }
body.scientific-modeling-reader main :is(h1,h2,h3,h4) { color:var(--fg); overflow-wrap:anywhere; text-wrap:pretty; }
body.scientific-modeling-reader main h1 { font-size:clamp(28px,3vw,36px); line-height:1.45; margin:0 0 26px; letter-spacing:-.015em; }
body.scientific-modeling-reader main h2 { font-size:25px; line-height:1.5; margin:52px 0 22px; padding-top:24px; border-top:1px solid var(--border); }
body.scientific-modeling-reader main h3 { font-size:21px; line-height:1.6; margin:32px 0 16px; }
body.scientific-modeling-reader main h4 { font-size:18px; margin:28px 0 14px; }
body.scientific-modeling-reader main :is(ul,ol) { padding-left:1.5em; }
body.scientific-modeling-reader main li { margin:.55em 0; }
body.scientific-modeling-reader main li::marker { color:var(--muted); }
body.scientific-modeling-reader main :is(strong,b) { font-weight:650; }
body.scientific-modeling-reader main hr { border:0; border-top:1px solid var(--border); margin:36px 0; }
body.scientific-modeling-reader main hr:has(+ h2) { display:none; }
body.scientific-modeling-reader main blockquote { margin:26px 0; padding:16px 22px; background:var(--quote-bg); border-left:3px solid var(--accent); border-radius:0 8px 8px 0; }
body.scientific-modeling-reader main blockquote p { margin:.45em 0; }
body.scientific-modeling-reader main .toc-box { display:block; padding:12px 20px; font-size:16px; border-radius:8px; box-shadow:none; }
/* aria-expanded is already authored in the frozen HTML; it is not a JS-ready
   signal. The existing script creates this floating button only after setup. */
body.scientific-modeling-reader:has(> .ov-save-floating) main > .toc-box { display:none; }
body.scientific-modeling-reader:not(:has(> .ov-save-floating)) .ov-rail { display:none; }
body.scientific-modeling-reader:not(:has(> .ov-save-floating)) .ov-layout { display:block; }
body.scientific-modeling-reader.overview-reading:not(:has(> .ov-save-floating)) main { max-width:824px; }
body.scientific-modeling-reader main details:not(.cr-fold):not(.toc-box) { padding:16px 20px; border-radius:8px; box-shadow:none; }
body.scientific-modeling-reader main details > summary { min-height:44px; padding:5px 0; line-height:1.7; }
body.scientific-modeling-reader main details:not(.cr-fold) > summary { color:var(--sc-sage-ink); font-weight:600; }
body.scientific-modeling-reader main details[open]:not(.cr-fold) > summary { padding-bottom:14px; border-bottom:1px solid var(--border); }
body.scientific-modeling-reader .ov-rail { top:84px; max-height:calc(100dvh - 108px); padding:16px; border-radius:8px; font-size:14px; box-shadow:none; }
body.scientific-modeling-reader .ov-rail nav { gap:4px; margin:16px 0; }
body.scientific-modeling-reader .ov-rail nav a { min-height:44px; padding:10px; border-radius:6px; }
body.scientific-modeling-reader .ov-rail nav a[aria-current="location"] { background:var(--accent-soft); color:var(--accent); box-shadow:inset 2px 0 var(--accent); }
body.scientific-modeling-reader :is(.ov-route-toggle,.ov-save,.ov-save-floating,.ov-choice-save) { min-height:44px; border-radius:8px; }
body.scientific-modeling-reader .ov-save { background:var(--sc-sage); color:var(--sc-sage-ink); border-color:var(--sc-sage-border); }
body.scientific-modeling-reader .ov-save-floating { font-size:14px; background:var(--sc-sage); color:var(--sc-sage-ink); border-color:var(--sc-sage-border); box-shadow:none; }
body.scientific-modeling-reader .ov-save-feedback { font-size:16px; box-shadow:none; }
body.scientific-modeling-reader main :is(.reading-recap,.reader-rescue,.reading-information) { padding:20px 24px; background:var(--sc-sage); border:1px solid var(--sc-sage-border); border-left:3px solid var(--sc-sage-ink); border-radius:8px; box-shadow:none; }
body.scientific-modeling-reader main :is(.reading-recap,.reader-rescue,.reading-information) > :last-child { margin-bottom:0; }
body.scientific-modeling-reader main .experiment-result { margin:28px 0; padding:20px 24px; background:var(--card); border:1px solid var(--border); border-left:3px solid var(--accent); border-radius:8px; }
body.scientific-modeling-reader main .experiment-result h3 { font-size:20px; margin-top:0; }
body.scientific-modeling-reader main :is(.reading-stage-note,.reading-time,.dia-lead,.reading-task-body) { font-size:var(--sc-prose); }
body.scientific-modeling-reader main .reading-task-list { grid-template-columns:1fr; }
body.scientific-modeling-reader main .reading-task { border-radius:8px; }

body.scientific-modeling-reader main :is(.tw,.table-scroll) { min-width:0; max-width:100%; overflow-x:auto; overscroll-behavior-x:contain; margin:26px 0; scrollbar-color:var(--muted) var(--quote-bg); }
body.scientific-modeling-reader main .tw:has(> .table-scroll) { overflow:visible; }
body.scientific-modeling-reader main .tw > .table-scroll { margin:0; }
body.scientific-modeling-reader main table { font-size:16px; line-height:1.8; }
body.scientific-modeling-reader main :is(th,td) { padding:12px 14px; vertical-align:top; overflow-wrap:normal; }
body.scientific-modeling-reader main th { font-weight:600; background:var(--quote-bg); }
body.scientific-modeling-reader .table-scroll-hint { color:var(--muted); font-size:14px; }
body.scientific-modeling-reader main pre { max-width:100%; overflow:auto; overscroll-behavior:contain; line-height:1.8; }
body.scientific-modeling-reader main pre:not(.cr-pre) { padding:20px; border-radius:8px; box-shadow:none; }
body.scientific-modeling-reader main pre:not(.cr-pre) code { font-size:16px; white-space:pre; overflow-wrap:normal; }
body.scientific-modeling-reader main :not(pre) > code { font-size:.9em; white-space:normal; overflow-wrap:anywhere; }
body.scientific-modeling-reader main .cr-card { border-radius:8px; box-shadow:none; }
body.scientific-modeling-reader main .cr-study.cr-has-notes { display:block; }
body.scientific-modeling-reader main .cr-notes { margin-top:16px; }
body.scientific-modeling-reader main .cr-note { font-size:16px; }
body.scientific-modeling-reader main .cr-note strong { font-size:17px; }
body.scientific-modeling-reader .cr-button { min-height:44px; }
body.scientific-modeling-reader main :is(.visual-block,.vb-flow,.vb-flow-row,.vb-flow-step,.vb-flow-unit,.vb-tree-flow,.vb-tree-row,.vb-compare,.vb-calc,.framecard,.panels) { min-width:0; max-width:100%; overflow-wrap:anywhere; }
body.scientific-modeling-reader main :is(.visual-block,.framecard,.panels) { border-radius:8px; box-shadow:none; }
body.scientific-modeling-reader main :is(.vb-flow-step,.vb-tree-node,.vb-steps li,.vb-compare p,.framecard li,.panels li) { font-size:var(--sc-prose); }
body.scientific-modeling-reader main figure.dia { max-width:100%; margin:30px 0; padding:0 0 8px; overflow-x:auto; overscroll-behavior-x:contain; }
/* Existing direct SVGs all use a 760-wide viewBox. Do not constrain clones
   in the diagram dialog, icons, or the figure team's opt-in new assets. */
body.scientific-modeling-reader main figure.dia:not(.sm-figure):not([data-scientific-figure]) > svg { display:block; width:760px; min-width:760px; max-width:none; height:auto; margin:0; }
/* 03's released diagrams use 480-wide viewBoxes and 18px minimum labels.
   Preserve their natural type size; only their local figure viewport scrolls. */
body.scientific-modeling-reader main figure.dia.sm-figure > svg { display:block; width:480px; min-width:480px; max-width:none; height:auto; margin-inline:auto; }
body.scientific-modeling-reader main figure.dia.sm-figure { display:flex; flex-direction:column; }
/* The shared toolbar uses inline top/left; static positioning deliberately
   ignores those offsets and puts the control before the authored artwork. */
body.scientific-modeling-reader main figure.dia.sm-figure .diagram-tools { position:static; order:-1; align-self:flex-end; margin-bottom:8px; }
body.scientific-modeling-reader .diagram-expand::before { background:var(--card); border-color:var(--border); box-shadow:none; }
body.scientific-modeling-reader .diagram-expand:hover::before { background:var(--accent-soft); border-color:var(--accent); }
body.scientific-modeling-reader main figure :is(img,object) { display:block; max-width:100%; height:auto; margin-inline:auto; }
body.scientific-modeling-reader main figure figcaption { font-size:16px; line-height:1.85; text-align:left; color:var(--muted); margin:16px 0 0; padding:0; overflow-wrap:anywhere; }
body.scientific-modeling-reader main figure.dia::before { max-width:100%; white-space:normal; width:auto; font-size:14px; border-radius:6px; }
body.scientific-modeling-reader .dia-note { font-size:16px; line-height:1.85; }
body.scientific-modeling-reader main .katex-display { max-width:100%; overflow-x:auto; overflow-y:hidden; padding:8px 2px; }
body.scientific-modeling-reader :is(#diagram-reader,#site-glossary,.ov-dialog) { background:var(--card); color:var(--fg); border-color:var(--border); }
body.scientific-modeling-reader .donebar { margin-top:44px; padding-top:28px; border-top:1px solid var(--border); }
body.scientific-modeling-reader .donebar button { min-height:48px; padding:10px 24px; border-radius:8px; font-size:17px; box-shadow:none; }
body.scientific-modeling-reader .donebar .hint { font-size:14px; }
body.scientific-modeling-reader main .pagenav { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; margin-top:32px; }
body.scientific-modeling-reader main .pagenav a { min-width:0; border-radius:8px; padding:18px 20px; font-size:17px; box-shadow:none; }
body.scientific-modeling-reader .pagenav .dir { font-size:14px; margin-bottom:8px; }

/* Directory preserves existing row order, IDs, data-md keys and controls. */
body.scientific-modeling-reader.scientific-modeling-index main { max-width:1104px; }
body.scientific-modeling-reader.scientific-modeling-index .hero { padding:0 0 32px; margin:0; text-align:left; background:none; border:0; }
body.scientific-modeling-reader.scientific-modeling-index .hero h1 { max-width:820px; font-size:clamp(30px,4vw,42px); }
body.scientific-modeling-reader.scientific-modeling-index .hero p { max-width:760px; font-size:18px; color:var(--muted); }
body.scientific-modeling-reader.scientific-modeling-index .hero b { color:var(--fg); }
body.scientific-modeling-reader.scientific-modeling-index .cta { display:inline-flex; align-items:center; justify-content:center; max-width:100%; min-height:48px; padding:10px 20px; margin:14px 0 0; border-radius:8px; background:var(--accent); color:var(--bg); font-size:16px; text-decoration:none; }
body.scientific-modeling-reader.scientific-modeling-index .dash { gap:14px 22px; margin:0 0 40px; padding:20px 24px; background:var(--sc-sage); border:1px solid var(--sc-sage-border); border-radius:8px; box-shadow:none; }
body.scientific-modeling-reader.scientific-modeling-index .pct { min-width:76px; font-size:28px; color:var(--sc-sage-ink); }
body.scientific-modeling-reader.scientific-modeling-index .track { height:6px; background:var(--border); }
body.scientific-modeling-reader.scientific-modeling-index .fill { background:var(--sc-sage-ink); }
body.scientific-modeling-reader.scientific-modeling-index .dash .label { font-size:14px; line-height:1.8; color:var(--muted); }
body.scientific-modeling-reader.scientific-modeling-index .stage { margin-top:42px; }
body.scientific-modeling-reader.scientific-modeling-index .stage h2 { margin:0 0 20px; padding:0; border:0; }
body.scientific-modeling-reader.scientific-modeling-index .stage h2 small { display:block; margin-top:8px; font-size:16px; font-weight:400; color:var(--muted); line-height:1.8; }
body.scientific-modeling-reader.scientific-modeling-index .cards { display:grid; grid-template-columns:1fr; gap:0; border-top:1px solid var(--border); }
body.scientific-modeling-reader.scientific-modeling-index .card { display:grid; grid-template-columns:24px 30px minmax(0,1fr) auto; align-items:start; gap:12px; margin:0; padding:20px 8px; background:transparent; color:var(--fg); border:0; border-bottom:1px solid var(--border); border-radius:0; box-shadow:none; transform:none; transition:none; text-decoration:none; }
body.scientific-modeling-reader.scientific-modeling-index .card:hover { background:var(--quote-bg); }
body.scientific-modeling-reader.scientific-modeling-index .card .check { color:var(--muted); font-size:18px; line-height:1.85; }
body.scientific-modeling-reader.scientific-modeling-index .card .badge { background:none; padding:0; font-size:20px; line-height:1.7; }
body.scientific-modeling-reader.scientific-modeling-index .card .cname { font-size:18px; line-height:1.85; min-width:0; overflow-wrap:anywhere; }
body.scientific-modeling-reader.scientific-modeling-index .card .time { font-size:14px; line-height:2.4; color:var(--muted); white-space:normal; }
body.scientific-modeling-reader.scientific-modeling-index .sc-unit-note { display:block; grid-column:3 / -1; font-size:16px; color:var(--muted); line-height:1.8; }
body.scientific-modeling-reader.scientific-modeling-index :is(.sc-index-intro,.sc-index-boundary) { max-width:760px; margin:24px 0; font-size:16px; color:var(--muted); }
body.scientific-modeling-reader.scientific-modeling-index .sc-index-boundary { padding:16px 20px; border-left:3px solid var(--sc-sage-ink); background:var(--sc-sage); border-radius:0 8px 8px 0; }
body.scientific-modeling-reader.scientific-modeling-index .sc-index-route { display:flex; flex-wrap:wrap; gap:10px; margin:24px 0; }
body.scientific-modeling-reader.scientific-modeling-index .sc-index-route a { display:inline-flex; align-items:center; min-height:44px; padding:8px 14px; border:1px solid var(--border); border-radius:8px; background:var(--card); font-size:16px; }
body.scientific-modeling-reader.scientific-modeling-index footer { margin-top:44px; font-size:14px; }

@media (max-width:980px) {
  body.scientific-modeling-reader.overview-reading main { max-width:824px; }
  body.scientific-modeling-reader .ov-layout { display:flex; flex-direction:column; gap:24px; }
  body.scientific-modeling-reader .ov-rail { order:-1; position:static; max-height:none; width:100%; }
}
@media (max-width:760px) {
  body.scientific-modeling-reader main { padding:32px 24px 96px; }
  body.scientific-modeling-reader main .pagenav { gap:12px; }
  body.scientific-modeling-reader main .pagenav a { padding:16px; }
}
@media (max-width:640px) {
  body.scientific-modeling-reader { --sc-prose:17px; --sc-offset:76px; }
  body.scientific-modeling-reader header.site { padding:0 12px; }
  body.scientific-modeling-reader header.site .inner { min-height:56px; justify-content:space-between; gap:4px; font-size:13px; }
  body.scientific-modeling-reader header.site :is(.title,.prevnext) { display:none; }
  body.scientific-modeling-reader header.site button { padding:6px 8px; }
  body.scientific-modeling-reader header.site #themeToggle { min-width:44px; }
  body.scientific-modeling-reader main { padding:28px 20px 96px; }
  body.scientific-modeling-reader main h1 { font-size:28px; line-height:1.5; margin-bottom:24px; }
  body.scientific-modeling-reader main h2 { font-size:23px; margin-top:40px; padding-top:20px; }
  body.scientific-modeling-reader main h3 { font-size:20px; }
  body.scientific-modeling-reader main :is(.reading-recap,.reader-rescue,.reading-information,.experiment-result) { padding:18px; }
  body.scientific-modeling-reader main details:not(.cr-fold) { padding-inline:16px; }
  body.scientific-modeling-reader main .pagenav { grid-template-columns:1fr; }
  body.scientific-modeling-reader .pagenav .next { text-align:left; }
  body.scientific-modeling-reader .ov-save-floating { right:12px; bottom:max(12px,env(safe-area-inset-bottom)); padding:8px 12px; }
  body.scientific-modeling-reader.scientific-modeling-index .hero p { font-size:17px; }
  body.scientific-modeling-reader.scientific-modeling-index .dash { padding:18px; }
  body.scientific-modeling-reader.scientific-modeling-index .card { grid-template-columns:20px 24px minmax(0,1fr); gap:6px 10px; padding:18px 2px; }
  body.scientific-modeling-reader.scientific-modeling-index .card .cname { font-size:17px; }
  body.scientific-modeling-reader.scientific-modeling-index .card .time { grid-column:3; line-height:1.8; }
  body.scientific-modeling-reader.scientific-modeling-index .sc-unit-note { grid-column:3; }
  body.scientific-modeling-reader.scientific-modeling-index .sc-index-route { display:grid; grid-template-columns:1fr; }
}
@media (prefers-reduced-motion:reduce) {
  html:has(> body.scientific-modeling-reader) { scroll-behavior:auto; }
  body.scientific-modeling-reader * { scroll-behavior:auto; transition:none!important; }
}
@media print {
  body.scientific-modeling-reader :is(header.site,#scrollbar,.ov-rail,.ov-save-floating,.donebar) { display:none; }
  body.scientific-modeling-reader main { max-width:none; padding:0; }
  body.scientific-modeling-reader .ov-layout { display:block; }
}
