/* From Atoms to Devices: course website. Colours and type follow branding/GUIDELINES.md of open-nemo. */

:root {
  --brand: #33103A;
  --accent: #9A5CA6;
  --accent-strong: #7A3D88;
  --tint: #EBDCEF;
  --tint-soft: #F4ECF6;
  --ink: #1F1A21;
  --muted: #5E5463;
  --faint: #8C8590;
  --rule: #DDD6E0;
  --rule-soft: #ECE7EE;
  --bg: #FFFFFF;
  --panel: #F7F3F8;
  --panel-2: #FBF9FC;
  --code-bg: #F7F3F8;
  --on-accent: #FFFFFF;
  --btn-accent: #8A4A98;
  --shadow: 0 1px 2px rgba(51, 16, 58, .06), 0 6px 24px rgba(51, 16, 58, .07);
  --shadow-lg: 0 2px 6px rgba(51, 16, 58, .08), 0 18px 48px rgba(51, 16, 58, .12);
  --fig-bg: #FFFFFF;

  /* figure colours (GUIDELINES.md section 6) */
  --s-open-nemo: #8A4A98;
  --s-nemo5: #C86A12;
  --s-family: #00897B;
  --s-reference: #1F1A21;
  --s-context: #8C8590;
  --c-navy: #0B1D60;
  --c-bronze: #5B4404;
  --c-periwinkle: #7584FE;
  --r-barrier: #F6DBD4;
  --r-well: #C9D9EE;
  --r-doped: #7FA7D6;
  --r-box: #DDD6E0;
  --r-dielectric: #F3E6B3;
  --r-metal: #B8B0BC;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --top: 60px;
  --side: 292px;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #FFFFFF; --accent: #C9A3D2; --accent-strong: #DDBEE4; --tint: #33103A; --tint-soft: #2A1830;
    --ink: #E8E2EA; --muted: #A89EAC; --faint: #8C8590; --rule: #3A3140; --rule-soft: #2C2431;
    --bg: #17121A; --panel: #221B26; --panel-2: #1C161F; --code-bg: #1E1822; --on-accent: #33103A; --btn-accent: #C9A3D2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 48px rgba(0, 0, 0, .4);
    --fig-bg: #FFFFFF;
    --s-open-nemo: #A864B6; --s-nemo5: #D27A2A; --s-family: #13A090; --s-reference: #E8E2EA; --s-context: #8C8590;
    --c-navy: #DDB938; --c-bronze: #A9B0FD; --c-periwinkle: #FEE484;
    --r-barrier: #4A2E2A; --r-well: #24344A; --r-doped: #2F5684; --r-box: #3A3140; --r-dielectric: #4A4226; --r-metal: #5E5663;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #FFFFFF; --accent: #C9A3D2; --accent-strong: #DDBEE4; --tint: #33103A; --tint-soft: #2A1830;
  --ink: #E8E2EA; --muted: #A89EAC; --faint: #8C8590; --rule: #3A3140; --rule-soft: #2C2431;
  --bg: #17121A; --panel: #221B26; --panel-2: #1C161F; --code-bg: #1E1822; --on-accent: #33103A; --btn-accent: #C9A3D2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 48px rgba(0, 0, 0, .4);
  --fig-bg: #FFFFFF;
  --s-open-nemo: #A864B6; --s-nemo5: #D27A2A; --s-family: #13A090; --s-reference: #E8E2EA; --s-context: #8C8590;
  --c-navy: #DDB938; --c-bronze: #A9B0FD; --c-periwinkle: #FEE484;
  --r-barrier: #4A2E2A; --r-well: #24344A; --r-doped: #2F5684; --r-box: #3A3140; --r-dielectric: #4A4226; --r-metal: #5E5663;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(var(--top) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16.5px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }
:root[data-theme="dark"] a, :root:not([data-theme="light"]) a { }
img { max-width: 100%; }
svg.i { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: var(--tint); }
h1, h2, h3, h4 { color: var(--brand); line-height: 1.25; letter-spacing: -0.01em; }
code { font-family: var(--mono); font-size: .88em; }
:not(pre) > code { background: var(--panel); border: 1px solid var(--rule-soft); border-radius: 5px; padding: .08em .35em; }
kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); background: var(--bg); }

.logo-dark, .when-dark { display: none; }
:root[data-theme="dark"] .logo-dark, :root[data-theme="dark"] .when-dark { display: inline; }
:root[data-theme="dark"] .logo-light, :root[data-theme="dark"] .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-dark, :root:not([data-theme="light"]) .when-dark { display: inline; }
  :root:not([data-theme="light"]) .logo-light, :root:not([data-theme="light"]) .when-light { display: none; }
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 50;
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--brand); min-width: 0; }
.brand img { flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-title { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 4px; margin-left: auto; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 19px; text-decoration: none;
}
.icon-btn:hover { background: var(--panel); color: var(--ink); }
.nav-toggle { display: none; }

.search { position: relative; margin-left: 28px; flex: 0 1 360px; }
.search input {
  width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--rule); background: var(--panel-2);
  padding: 0 40px 0 36px; font: inherit; font-size: 14.5px; color: var(--ink); outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); background: var(--bg); }
.search-icon { position: absolute; left: 11px; top: 10px; color: var(--faint); font-size: 17px; pointer-events: none; }
.search kbd { position: absolute; right: 10px; top: 10px; }
.search-results {
  display: none; position: absolute; top: 46px; left: 0; width: min(560px, 92vw); max-height: 70vh; overflow: auto;
  background: var(--bg); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
}
.search.open .search-results { display: block; }
.search-results a { display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.search-results a:hover, .search-results a.sel { background: var(--panel); }
.search-results .sr-k { font-size: 11.5px; color: var(--accent-strong); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.search-results .sr-t { display: block; font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.search-results .sr-s { display: block; font-size: 12.5px; color: var(--muted); }
.search-results .sr-none { padding: 12px; color: var(--muted); font-size: 14px; }
.search-results mark { background: var(--tint); color: inherit; border-radius: 3px; }

/* ---------------------------------------------------------------- layout */
.layout { display: flex; padding-top: var(--top); min-height: 100vh; }
.sidebar {
  position: sticky; top: var(--top); height: calc(100vh - var(--top)); width: var(--side); flex: none;
  border-right: 1px solid var(--rule); overflow-y: auto; background: var(--bg);
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
.sidebar-inner { padding: 18px 12px 40px; }
.side-home { display: block; padding: 7px 10px; margin-bottom: 6px; font-weight: 600; font-size: 14px; text-decoration: none; color: var(--ink); border-radius: 8px; }
.side-home:hover, .side-home.active { background: var(--panel); }
.side-sec { margin: 1px 0; }
.side-sec summary {
  list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; border-radius: 8px;
  font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.35;
}
.side-sec summary::-webkit-details-marker { display: none; }
.side-sec summary:hover { background: var(--panel); }
.side-num { font-family: var(--mono); font-size: 11.5px; color: var(--accent-strong); font-weight: 600; flex: none; }
.side-sec ul { list-style: none; margin: 2px 0 8px; padding: 0 0 0 14px; border-left: 1px solid var(--rule); margin-left: 19px; }
.side-sec li a {
  display: flex; gap: 8px; padding: 5px 10px; font-size: 13.5px; line-height: 1.4; color: var(--muted); text-decoration: none; border-radius: 7px;
}
.side-sec li a:hover { color: var(--ink); background: var(--panel); }
.side-sec li a.active { color: var(--brand); background: var(--tint); font-weight: 600; }
:root[data-theme="dark"] .side-sec li a.active { color: #fff; }
.side-lnum { font-family: var(--mono); font-size: 11px; color: var(--faint); min-width: 3.4em; padding-top: 2px; flex: none; }
.side-overview { font-style: italic; }
.side-ltitle .math { font-size: .95em; }
.nav-scrim { display: none; }

.main { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 40px; padding: 36px 40px 80px; }
.article { width: 100%; max-width: 860px; min-width: 0; }
.article.wide { max-width: 1180px; }
.toc { width: 230px; flex: none; }
.toc-inner { position: sticky; top: calc(var(--top) + 32px); max-height: calc(100vh - var(--top) - 60px); overflow: auto; font-size: 13.5px; }
.toc-title { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li a { display: block; padding: 4px 0 4px 14px; margin-left: -1px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; line-height: 1.4; }
.toc li a:hover { color: var(--ink); }
.toc li a.active { color: var(--accent-strong); border-left-color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------------- lecture header */
.crumbs { display: flex; gap: 8px; font-size: 13.5px; color: var(--faint); margin-bottom: 14px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent-strong); }
.kicker { margin: 0 0 6px; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-strong); }
.lecture-head h1 { font-size: clamp(28px, 3.6vw, 40px); margin: 0 0 18px; letter-spacing: -.02em; line-height: 1.15; text-wrap: balance; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--rule); color: var(--ink); text-decoration: none; font-size: 13.5px; background: var(--bg);
}
.chip svg { font-size: 16px; color: var(--accent-strong); }
.chip:hover { border-color: var(--accent); color: var(--ink); background: var(--panel-2); }
.chip-live { background: var(--tint); border-color: transparent; color: var(--brand); font-weight: 600; cursor: pointer; }
.chip-live svg { fill: currentColor; stroke: none; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 30px 0 18px; }
.summary-card { background: var(--panel); border-radius: var(--radius); padding: 18px 22px 8px; font-size: 15px; line-height: 1.6; }
.summary-card.nb { background: var(--bg); border: 1px solid var(--rule); }
.summary-card ul { padding-left: 18px; margin: 8px 0 12px; }
.summary-card li { margin: 5px 0; }
.summary-card li::marker { color: var(--accent); }
.summary-h { font-size: 12px !important; letter-spacing: .08em; text-transform: uppercase; color: var(--muted) !important; margin: 0 0 8px !important; border: 0 !important; padding: 0 !important; }

.run-panel {
  display: grid; grid-template-columns: 1fr; gap: 14px; align-items: center;
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 20px; margin: 0 0 8px;
  background: linear-gradient(135deg, var(--panel-2), var(--bg));
}
.run-head { display: flex; gap: 14px; align-items: center; }
.run-head strong { display: block; color: var(--brand); font-size: 15.5px; }
.run-head span { font-size: 14px; color: var(--muted); line-height: 1.45; }
.run-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--tint); color: var(--brand); font-size: 20px; flex: none; }
.run-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-left: 54px; }
.run-local { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.run-local summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; width: fit-content; }
.run-local p { margin: 8px 0; }
pre.shell { background: var(--code-bg); border: 1px solid var(--rule-soft); border-radius: 9px; padding: 12px 14px; font-size: 13px; overflow: auto; color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 9px;
  border: 1px solid var(--rule); background: var(--bg); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s, transform .1s;
}
.btn svg { font-size: 17px; }
.btn:hover { border-color: var(--accent); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--btn-accent); border-color: var(--btn-accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--brand); border-color: var(--brand); color: var(--bg); }
:root[data-theme="dark"] .btn-primary:hover { background: #fff; color: #33103A; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; }
.btn-ghost:hover { background: var(--panel); border-color: transparent; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15.5px; border-radius: 11px; }

.code-toggle-row { display: flex; justify-content: flex-end; margin: 6px 0 -6px; }

/* ---------------------------------------------------------------- notebook body */
.nb-body h2 {
  font-size: 25px; margin: 54px 0 14px; padding-top: 22px; border-top: 1px solid var(--rule); position: relative;
}
.nb-body h3 { font-size: 19px; margin: 32px 0 10px; }
.nb-body p, .nb-body li { text-wrap: pretty; }
.nb-body a { overflow-wrap: anywhere; }
.nb-body ul, .nb-body ol { padding-left: 22px; }
.nb-body li { margin: 4px 0; }
.nb-body li::marker { color: var(--accent); }
.h-anchor { margin-left: 8px; color: var(--faint); text-decoration: none; opacity: 0; font-weight: 400; transition: opacity .15s; }
h2:hover .h-anchor, h3:hover .h-anchor { opacity: 1; }
.math-block { overflow-x: auto; overflow-y: hidden; margin: 16px 0; padding: 4px 0; }
.math.display { display: block; overflow-x: auto; overflow-y: hidden; }
.katex { font-size: 1.07em; }
.katex-display { margin: .6em 0; }
.nb-body table { border-collapse: collapse; margin: 18px 0; font-size: 14.5px; display: block; overflow-x: auto; }
.nb-body th, .nb-body td { border-bottom: 1px solid var(--rule); padding: 7px 12px; text-align: left; }
.nb-body th { color: var(--muted); font-weight: 600; font-size: 13px; }
.nb-body blockquote { margin: 16px 0; padding: 4px 18px; border-left: 3px solid var(--accent); color: var(--muted); background: var(--panel-2); border-radius: 0 8px 8px 0; }

figure { margin: 22px 0; }
figure.slide { margin: 26px auto; max-width: 720px; }
.slide-frame { border-radius: 10px; overflow: hidden; border: 1px solid var(--rule); box-shadow: var(--shadow); background: #fff; line-height: 0; }
.slide-frame img { width: 100%; display: block; cursor: zoom-in; }
figcaption { margin-top: 10px; font-size: 13.5px; color: var(--muted); line-height: 1.5; text-align: left; }

.cell.code { margin: 20px 0; }
.code-src { border-radius: 10px; }
.code-src > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px;
  border-radius: 8px; font-size: 13px; color: var(--muted); border: 1px dashed var(--rule); user-select: none;
}
.code-src > summary::-webkit-details-marker { display: none; }
.code-src > summary:hover { color: var(--ink); border-color: var(--accent); border-style: solid; }
.code-src[open] > summary { color: var(--brand); border-style: solid; background: var(--panel); border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-color: transparent; }
.code-ico { font-size: 15px; display: inline-flex; color: var(--accent-strong); }
.code-label { font-weight: 600; }
.code-meta { color: var(--faint); font-family: var(--mono); font-size: 11.5px; }
pre.hl, pre.md-code {
  margin: 0; background: var(--code-bg); border: 1px solid var(--rule); border-radius: 0 10px 10px 10px;
  padding: 14px 16px; overflow: auto; font-size: 13px; line-height: 1.55; color: var(--ink); tab-size: 4;
}
pre.md-code { border-radius: 10px; margin: 14px 0; }
pre.out-text {
  margin: 10px 0 0; padding: 12px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: var(--ink);
  background: var(--panel-2); border-left: 3px solid var(--rule); border-radius: 0 8px 8px 0; overflow: auto; white-space: pre;
}
.nb-fig { margin: 14px 0 0; background: var(--fig-bg); border-radius: 10px; border: 1px solid var(--rule); padding: 8px; line-height: 0; }
.nb-fig img { width: 100%; display: block; cursor: zoom-in; }

.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 64px; }
.pn {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--rule); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); font-weight: 600; font-size: 15px; line-height: 1.35;
}
.pn:hover { border-color: var(--accent); background: var(--panel-2); color: var(--ink); }
.pn small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; margin-bottom: 2px; }
.pn svg { font-size: 20px; color: var(--accent-strong); flex: none; }
.pn.next { justify-content: flex-end; text-align: right; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(23, 18, 26, .86); display: grid; place-items: center; padding: 3vw; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; background: #fff; box-shadow: 0 20px 80px rgba(0,0,0,.5); }

/* ---------------------------------------------------------------- interactive widgets */
.fad-widget {
  position: relative; margin: 34px 0; border: 1px solid var(--rule); border-radius: 16px; background: var(--bg);
  box-shadow: var(--shadow); overflow: hidden;
}
.fad-widget::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, #DDB938, #C35F86, var(--s-open-nemo), #2A3B8F);
}
.fw-head { padding: 20px 22px 4px; }
.fw-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--accent-strong); margin-bottom: 4px;
}
.fw-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.fw-title { margin: 0 0 6px; font-size: 19px !important; border: 0 !important; padding: 0 !important; }
.fw-desc { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.fw-desc p { margin: 0 0 6px; }
.fw-body { display: grid; grid-template-columns: minmax(220px, 268px) minmax(0, 1fr); gap: 0; margin-top: 14px; border-top: 1px solid var(--rule-soft); }
.fad-widget.no-controls .fw-body { grid-template-columns: minmax(0, 1fr); }
.fad-widget.controls-top .fw-body { grid-template-columns: minmax(0, 1fr); }
.fad-widget.controls-top .fw-controls { border-right: 0; border-bottom: 1px solid var(--rule-soft); display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 26px; align-items: end; }
.fad-widget.controls-top .fw-presets { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; padding-top: 10px; }
.fad-widget.controls-top .fw-presets .fw-lab { margin: 0 6px 0 0; }
.fad-widget.controls-top .fw-presets button { display: inline-block; width: auto; margin-top: 0; }
.fad-widget.controls-top .fw-buttons { grid-column: span 1; }
@media (min-width: 1480px) {
  .page-lecture .fad-widget { margin-left: -48px; margin-right: -48px; }
}
.fw-controls { padding: 16px 20px 18px; background: var(--panel-2); border-right: 1px solid var(--rule-soft); display: flex; flex-direction: column; gap: 4px; }
.fw-main { padding: 12px 16px 14px; min-width: 0; }
.fw-plots { display: grid; gap: 8px 14px; }
.fw-plot { min-width: 0; position: relative; }
.fw-plot-title { font-size: 13px; font-weight: 700; color: var(--ink); margin: 4px 0 0 6px; }
.fw-plot canvas { display: block; width: 100%; border-radius: 8px; }
.fw-ctrl { padding: 7px 0; }
.fw-ctrl label, .fw-ctrl .fw-lab { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13.5px; color: var(--ink); font-weight: 500; margin-bottom: 6px; }
.fw-val { font-family: var(--mono); font-size: 12.5px; color: var(--accent-strong); font-weight: 600; white-space: nowrap; background: var(--bg); border: 1px solid var(--rule-soft); border-radius: 6px; padding: 1px 7px; }
.fw-help { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
input[type=range].fw-range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; margin: 0; }
input[type=range].fw-range::-webkit-slider-runnable-track { height: 5px; border-radius: 4px; background: linear-gradient(90deg, var(--s-open-nemo) var(--fill, 50%), var(--rule) var(--fill, 50%)); }
input[type=range].fw-range::-moz-range-track { height: 5px; border-radius: 4px; background: var(--rule); }
input[type=range].fw-range::-moz-range-progress { height: 5px; border-radius: 4px; background: var(--s-open-nemo); }
input[type=range].fw-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6.5px; border-radius: 50%; background: var(--bg); border: 2px solid var(--s-open-nemo); box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .1s; }
input[type=range].fw-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--s-open-nemo); }
input[type=range].fw-range:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type=range].fw-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
select.fw-select {
  width: 100%; height: 34px; border-radius: 8px; border: 1px solid var(--rule); background: var(--bg); color: var(--ink);
  font: inherit; font-size: 13.5px; padding: 0 10px;
}
.fw-choice { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg); border: 1px solid var(--rule); border-radius: 9px; padding: 3px; }
.fw-choice button { flex: 1 1 auto; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.fw-choice button:hover { color: var(--ink); }
.fw-choice button.on { background: var(--btn-accent); color: var(--on-accent); }
.fw-ctrl label.fw-toggle, .fw-toggle { display: flex; justify-content: flex-start; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; user-select: none; margin-bottom: 0; }
.fw-toggle input { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--rule); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.fw-toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.fw-toggle input:checked { background: var(--s-open-nemo); }
.fw-toggle input:checked::after { transform: translateX(14px); }
.fw-buttons { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 0; }
.fw-buttons .btn { height: 32px; font-size: 13px; padding: 0 12px; }
.fw-presets { margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--rule); }
.fw-presets .fw-lab { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.fw-presets button { display: block; width: 100%; text-align: left; border: 1px solid var(--rule); background: var(--bg); color: var(--ink); font: inherit; font-size: 12.5px; padding: 6px 10px; border-radius: 7px; cursor: pointer; margin-top: 5px; line-height: 1.35; }
.fw-presets button:hover { border-color: var(--accent); }
.fw-presets button.on { border-color: var(--accent); background: var(--tint); }
.fw-readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; margin-top: 10px; }
.fw-readout { background: var(--panel-2); border: 1px solid var(--rule-soft); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.fw-readout .rl { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.fw-readout .rv { display: block; font-family: var(--mono); font-size: 15.5px; font-weight: 600; color: var(--ink); white-space: normal; overflow-wrap: anywhere; }
.fw-readout .ru { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.fw-note { margin-top: 10px; font-size: 14px; color: var(--ink); background: var(--tint-soft); border-radius: 9px; padding: 9px 13px; line-height: 1.5; }
.fw-note:empty { display: none; }
.fw-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; padding: 12px 22px 16px; border-top: 1px solid var(--rule-soft); font-size: 13px; color: var(--muted); background: var(--panel-2); }
.fw-try { margin: 0; padding: 0; list-style: none; flex: 1 1 380px; }
.fw-try li { position: relative; padding-left: 18px; margin: 3px 0; line-height: 1.45; }
.fw-try li::before { content: "→"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.fw-try-h { font-weight: 700; color: var(--ink); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.fw-source { flex: 0 1 300px; font-size: 12.5px; line-height: 1.45; }
.fw-source::before { content: "Model · "; font-weight: 700; color: var(--faint); }
.fw-loading { padding: 40px; text-align: center; color: var(--faint); font-size: 14px; }
.fw-error { padding: 14px 22px; color: #B3261E; font-size: 13.5px; font-family: var(--mono); white-space: pre-wrap; }
.fad-widget .js-plotly-plot .modebar { opacity: 0; transition: opacity .2s; }
.fad-widget .fw-plot:hover .modebar { opacity: 1; }
.fad-widget .modebar-btn path { fill: var(--muted) !important; }

/* ---------------------------------------------------------------- home */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 44px; align-items: center; padding: 18px 0 40px; }
.hero h1 { font-size: clamp(34px, 4.6vw, 56px); line-height: 1.05; letter-spacing: -.03em; margin: 8px 0 20px; }
.hero h1 .accent { color: var(--accent); }
.lede { font-size: 18px; line-height: 1.6; color: var(--muted); margin: 0 0 26px; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-viz { border-radius: 20px; border: 1px solid var(--rule); background: var(--bg); box-shadow: var(--shadow-lg); overflow: hidden; min-height: 400px; position: relative; }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 20px 0 64px; }
.how-item { border: 1px solid var(--rule); border-radius: 14px; padding: 20px 22px; background: var(--panel-2); }
.how-item h3 { margin: 10px 0 6px; font-size: 18px; }
.how-item p { margin: 0; font-size: 14.5px; color: var(--muted); line-height: 1.55; }
.how-n { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--tint); color: var(--brand); font-weight: 700; font-size: 14px; }
.contents-title { font-size: 30px; margin: 0 0 22px; letter-spacing: -.02em; }
.sec-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.sec-block { border: 1px solid var(--rule); border-radius: 16px; padding: 6px; background: var(--bg); transition: box-shadow .2s, border-color .2s; }
.sec-block:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--rule)); }
.sec-head { display: flex; gap: 14px; padding: 14px 14px 10px; text-decoration: none; color: inherit; border-radius: 12px; }
.sec-head:hover { background: var(--panel-2); color: inherit; }
.sec-num { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--accent-strong); background: var(--tint); border-radius: 8px; height: 30px; min-width: 38px; display: grid; place-items: center; flex: none; }
.sec-head h3 { margin: 2px 0 4px; font-size: 18px; }
.sec-head p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sec-list { list-style: none; margin: 4px 0 6px; padding: 0 8px; }
.sec-list a { display: flex; gap: 10px; align-items: baseline; padding: 5px 8px; border-radius: 7px; font-size: 14px; color: var(--ink); text-decoration: none; line-height: 1.4; }
.sec-list a:hover { background: var(--panel); }
.lnum { font-family: var(--mono); font-size: 11.5px; color: var(--faint); min-width: 3.6em; flex: none; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: auto; flex: none; align-self: center; }
.cite { margin-top: 70px; padding-top: 30px; border-top: 1px solid var(--rule); max-width: 820px; }
.cite h2 { font-size: 22px; }
.cite p { color: var(--muted); font-size: 15px; }
.cite-box { background: var(--panel); border-radius: 10px; padding: 12px 16px; color: var(--ink) !important; }

/* ---------------------------------------------------------------- section page */
.section-hero { padding: 6px 0 28px; max-width: 860px; }
.section-hero h1 { font-size: clamp(30px, 4vw, 46px); margin: 6px 0 14px; letter-spacing: -.025em; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.lec-card { display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; text-decoration: none; color: inherit; background: var(--bg); transition: transform .15s, box-shadow .2s, border-color .2s; }
.lec-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); color: inherit; }
.card-thumb { height: 170px; background: #fff; border-bottom: 1px solid var(--rule); display: grid; place-items: center; overflow: hidden; padding: 8px; }
.card-thumb img { max-height: 100%; width: auto; object-fit: contain; }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.card-body h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.3; }
.card-blurb { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card-live { margin-top: 12px; align-self: flex-start; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--brand); background: var(--tint); padding: 3px 10px; border-radius: 99px; }

/* ---------------------------------------------------------------- footer */
.site-footer { border-top: 1px solid var(--rule); background: var(--panel-2); margin-left: var(--side); }
.footer-inner { max-width: 1100px; margin: 0 auto; padding: 28px 40px 40px; display: flex; gap: 30px; align-items: flex-start; }
.footer-inner p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1280px) {
  .toc { display: none; }
}
@media (max-width: 1020px) {
  .nav-toggle { display: inline-grid; }
  .sidebar { position: fixed; left: 0; top: var(--top); z-index: 40; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: var(--top) 0 0 0; background: rgba(23, 18, 26, .35); z-index: 39; }
  .site-footer { margin-left: 0; }
  .main { padding: 28px 24px 70px; }
  .hero { grid-template-columns: 1fr; }
  .search { margin-left: 8px; }
  .brand-sub { display: none; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .main { padding: 22px 16px 60px; }
  .summary-grid { grid-template-columns: 1fr; }
  .run-panel { grid-template-columns: 1fr; }
  .run-actions { padding-left: 0; }
  .fw-body { grid-template-columns: 1fr !important; }
  .fw-controls { border-right: 0; border-bottom: 1px solid var(--rule-soft); }
  .fw-plots { grid-template-columns: 1fr !important; }
  .how, .sec-grid { grid-template-columns: 1fr; }
  .prevnext { grid-template-columns: 1fr; }
  .search { flex: 1 1 auto; }
  .search kbd { display: none; }
  .brand-text { display: none; }
  .footer-inner { flex-direction: column; padding: 24px 16px 32px; }
  .hero-viz { min-height: 340px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media print {
  .topbar, .sidebar, .toc, .run-panel, .prevnext, .code-toggle-row, .site-footer { display: none !important; }
  .layout { padding-top: 0; }
}

/* ---------------------------------------------------------------- hero animation */
.hero-viz canvas { position: absolute; inset: 0; display: block; }
.hero-label { position: absolute; left: 16px; top: 14px; right: 16px; font-size: 13px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.hero-live { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); background: var(--tint); padding: 2px 8px; border-radius: 99px; }
.hero-stats { position: absolute; left: 16px; top: 36px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); max-width: 62%; }
.hero-stats b { font-family: var(--mono); color: var(--ink); }
.hero-stats .hero-t { font-family: var(--mono); color: var(--faint); }
.hero-bar { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.hero-bar button { border: 1px solid var(--rule); background: color-mix(in srgb, var(--bg) 88%, transparent); color: var(--ink); font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.hero-bar button:hover { border-color: var(--accent); }
.hero-bar button.on { background: var(--btn-accent); border-color: var(--btn-accent); color: var(--on-accent); }

.hl .k{color:#7A2E8A;}
.hl .kn{color:#7A2E8A;}
.hl .kc{color:#7A2E8A;}
.hl .kd{color:#7A2E8A;}
.hl .ow{color:#7A2E8A;}
.hl .nf{color:#0B4F9C;}
.hl .nc{color:#0B4F9C;}
.hl .nb{color:#00695C;}
.hl .bp{color:#00695C;}
.hl .s{color:#8A4B08;}
.hl .s1{color:#8A4B08;}
.hl .s2{color:#8A4B08;}
.hl .sa{color:#8A4B08;}
.hl .si{color:#5B4404;}
.hl .sd{color:#6B6170;font-style:italic;}
.hl .c{color:#7B727F;font-style:italic;}
.hl .c1{color:#7B727F;font-style:italic;}
.hl .cm{color:#7B727F;font-style:italic;}
.hl .m{color:#B3261E;}
.hl .mi{color:#B3261E;}
.hl .mf{color:#B3261E;}
.hl .o{color:#5E5463;}
.hl .p{color:#5E5463;}
.hl .nd{color:#0B4F9C;}
.hl .fm{color:#0B4F9C;}
:root[data-theme='dark'] .hl .k{color:#D9A6E4}
:root[data-theme='dark'] .hl .kn{color:#D9A6E4}
:root[data-theme='dark'] .hl .kc{color:#D9A6E4}
:root[data-theme='dark'] .hl .kd{color:#D9A6E4}
:root[data-theme='dark'] .hl .ow{color:#D9A6E4}
:root[data-theme='dark'] .hl .nf{color:#8DB8F2}
:root[data-theme='dark'] .hl .nc{color:#8DB8F2}
:root[data-theme='dark'] .hl .nb{color:#6FD0C0}
:root[data-theme='dark'] .hl .bp{color:#6FD0C0}
:root[data-theme='dark'] .hl .s{color:#E6BD7A}
:root[data-theme='dark'] .hl .s1{color:#E6BD7A}
:root[data-theme='dark'] .hl .s2{color:#E6BD7A}
:root[data-theme='dark'] .hl .sa{color:#E6BD7A}
:root[data-theme='dark'] .hl .si{color:#F2D9A0}
:root[data-theme='dark'] .hl .sd{color:#A89EAC}
:root[data-theme='dark'] .hl .c{color:#8F8594}
:root[data-theme='dark'] .hl .c1{color:#8F8594}
:root[data-theme='dark'] .hl .cm{color:#8F8594}
:root[data-theme='dark'] .hl .m{color:#F2958C}
:root[data-theme='dark'] .hl .mi{color:#F2958C}
:root[data-theme='dark'] .hl .mf{color:#F2958C}
:root[data-theme='dark'] .hl .o{color:#B9AFBD}
:root[data-theme='dark'] .hl .p{color:#B9AFBD}
:root[data-theme='dark'] .hl .nd{color:#8DB8F2}
:root[data-theme='dark'] .hl .fm{color:#8DB8F2}
@media (prefers-color-scheme: dark){
:root:not([data-theme='light']) .hl .k{color:#D9A6E4}
:root:not([data-theme='light']) .hl .kn{color:#D9A6E4}
:root:not([data-theme='light']) .hl .kc{color:#D9A6E4}
:root:not([data-theme='light']) .hl .kd{color:#D9A6E4}
:root:not([data-theme='light']) .hl .ow{color:#D9A6E4}
:root:not([data-theme='light']) .hl .nf{color:#8DB8F2}
:root:not([data-theme='light']) .hl .nc{color:#8DB8F2}
:root:not([data-theme='light']) .hl .nb{color:#6FD0C0}
:root:not([data-theme='light']) .hl .bp{color:#6FD0C0}
:root:not([data-theme='light']) .hl .s{color:#E6BD7A}
:root:not([data-theme='light']) .hl .s1{color:#E6BD7A}
:root:not([data-theme='light']) .hl .s2{color:#E6BD7A}
:root:not([data-theme='light']) .hl .sa{color:#E6BD7A}
:root:not([data-theme='light']) .hl .si{color:#F2D9A0}
:root:not([data-theme='light']) .hl .sd{color:#A89EAC}
:root:not([data-theme='light']) .hl .c{color:#8F8594}
:root:not([data-theme='light']) .hl .c1{color:#8F8594}
:root:not([data-theme='light']) .hl .cm{color:#8F8594}
:root:not([data-theme='light']) .hl .m{color:#F2958C}
:root:not([data-theme='light']) .hl .mi{color:#F2958C}
:root:not([data-theme='light']) .hl .mf{color:#F2958C}
:root:not([data-theme='light']) .hl .o{color:#B9AFBD}
:root:not([data-theme='light']) .hl .p{color:#B9AFBD}
:root:not([data-theme='light']) .hl .nd{color:#8DB8F2}
:root:not([data-theme='light']) .hl .fm{color:#8DB8F2}
}