:root {
  --paper: #F1F5F9;
  --surface: #FFFFFF;
  --ink: #12233A;
  --muted: #586A80;
  --line: #D3DCE6;
  --accent: #1F4FD8;
  --accent-soft: #E3EBFF;
  --mark: #E8A900;
  --good: #1B7F55;
  --bad: #BF3A2E;
  --code-bg: #0F1D30;
  --code-ink: #DCE6F2;
  --display: "Avenir Next", "Avenir", "Segoe UI", "Helvetica Neue", sans-serif;
  --body: "Charter", "Iowan Old Style", "Georgia", serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0C1725; --surface: #132134; --ink: #E4ECF5; --muted: #90A2B7;
    --line: #25384F; --accent: #86ABFF; --accent-soft: #1B2F52; --good: #5CC797; --bad: #F0857A;
    --code-bg: #08111D;
  }
}
:root[data-theme="dark"] {
  --paper: #0C1725; --surface: #132134; --ink: #E4ECF5; --muted: #90A2B7;
  --line: #25384F; --accent: #86ABFF; --accent-soft: #1B2F52; --good: #5CC797; --bad: #F0857A;
  --code-bg: #08111D;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 18px; line-height: 1.65;
  display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: 100vh;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Sidebar */
#side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--line); background: var(--surface);
  padding: 24px 20px 16px; font-family: var(--display); font-size: 14.5px; line-height: 1.35;
  display: flex; flex-direction: column; gap: 16px;
}
.brand { text-decoration: none; color: var(--ink); display: block; }
.brand-name { display: block; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { color: var(--muted); font-size: 13px; }
.gauge { font-size: 13px; color: var(--muted); }
.gauge-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0 4px; }
.gauge-fill { height: 100%; background: linear-gradient(90deg, #8FB4EE, #1F4FD8 60%, #0C1D36); transition: width .4s ease; }
.gauge-ends { display: flex; justify-content: space-between; }
#search {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper);
}
#nav { flex: 1; }
.nav-track { margin: 0 0 14px; }
.nav-track h3 { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 4px; letter-spacing: .01em; }
.nav-track ol { list-style: none; margin: 0; padding: 0 0 0 7px; border-left: 2px solid var(--line); }
.nav-track li a {
  display: block; position: relative; padding: 5px 8px 5px 16px; color: var(--ink);
  text-decoration: none; border-radius: 0 6px 6px 0;
}
.nav-track li a::before {
  content: ""; position: absolute; left: -6px; top: 50%; width: 8px; height: 8px; margin-top: -5px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--line);
}
.nav-track li.done a::before { background: var(--accent); border-color: var(--accent); }
.nav-track li a:hover { background: var(--paper); }
.nav-track li a.current { background: var(--accent-soft); font-weight: 600; }
.side-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.side-foot button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; }
.menu-btn { display: none; }

/* Main */
#main { padding: 48px clamp(20px, 5vw, 72px) 96px; outline: none; }
.col { max-width: 46rem; }
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 2.4rem; margin: 0 0 .4em; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; margin: 2.2em 0 .5em; }
h3 { font-size: 1.15rem; margin: 1.8em 0 .4em; }
h4 { font-size: 1rem; margin: 1.4em 0 .3em; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; margin: 0 0 1em; }
li { margin: .25em 0; }
code { font-family: var(--mono); font-size: .84em; background: var(--accent-soft); padding: .1em .35em; border-radius: 4px; }
pre {
  background: var(--code-bg); color: var(--code-ink); padding: 16px 18px; border-radius: 8px;
  overflow-x: auto; font-size: 14px; line-height: 1.55; margin: 0 0 1.2em; position: relative;
}
pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
pre[data-lang]:not([data-lang=""])::after {
  content: attr(data-lang); position: absolute; top: 6px; right: 10px;
  font-family: var(--display); font-size: 11px; color: #8FA3BC;
}
blockquote {
  margin: 0 0 1.2em; padding: 12px 16px; border-left: 4px solid var(--mark);
  background: var(--surface); border-radius: 0 8px 8px 0;
}
blockquote p:last-child { margin-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; }
table { border-collapse: collapse; font-family: var(--display); font-size: 14.5px; line-height: 1.4; width: 100%; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; border-bottom: 2px solid var(--ink); }

.lesson-meta { font-family: var(--display); font-size: 14px; color: var(--muted); margin-bottom: 1.6em; }
.lesson-meta a { color: inherit; }
.listen { display: inline-flex; gap: 6px; margin-left: 12px; vertical-align: middle; }
.listen button, .listen select {
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 13.5px;
}
.listen button:hover { border-color: var(--accent); }
details.reveal { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 16px; margin: 0 0 1em; }
details.reveal summary { cursor: pointer; padding: 12px 0; font-family: var(--display); font-weight: 600; }
details.reveal[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }

/* Quiz */
.quiz { margin-top: 3em; padding-top: 1.5em; border-top: 2px solid var(--ink); }
.quiz h2 { margin-top: 0; }
.q { margin: 0 0 1.6em; }
.q-text { font-weight: 600; margin-bottom: .5em; }
.q button {
  display: block; width: 100%; text-align: left; margin: 6px 0; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  font-family: var(--display); font-size: 15.5px; line-height: 1.4;
}
.q button:hover:not(:disabled) { border-color: var(--accent); }
.q button.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.q button.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.q button:disabled { cursor: default; opacity: 1; }
.q-exp { font-size: 16px; color: var(--muted); padding: 4px 2px; }
.quiz-score { font-family: var(--display); font-weight: 600; }

/* Lesson footer */
.lesson-foot { margin-top: 2.5em; display: grid; gap: 18px; font-family: var(--display); }
.notes textarea {
  width: 100%; min-height: 110px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-family: var(--body); font-size: 16px; resize: vertical;
}
.notes label { font-size: 14px; color: var(--muted); display: block; margin-bottom: 4px; }
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--surface); font-family: var(--display); font-weight: 600;
  font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.is-done { background: var(--good); border-color: var(--good); }
.pager { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 15px; }

/* Home: the depth chart */
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); max-width: 16ch; line-height: 1.05; }
.hero p { max-width: 38rem; font-size: 1.1rem; }
.hero .btn { margin-top: .4em; }
.strata { margin-top: 48px; max-width: 60rem; border-radius: 12px; overflow: hidden; }
.stratum {
  display: grid; grid-template-columns: 5.5rem 1fr auto; gap: 20px; align-items: center;
  padding: 22px 26px; text-decoration: none; font-family: var(--display);
  color: #12233A;
}
.stratum.deep { color: #EAF1FA; }
.stratum:hover .stratum-title { text-decoration: underline; }
.stratum-depth { font-family: var(--mono); font-size: 13px; opacity: .75; }
.stratum-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.stratum-blurb { font-size: 14.5px; opacity: .85; line-height: 1.4; margin-top: 2px; }
.stratum-prog { font-size: 14px; white-space: nowrap; text-align: right; }
.stratum-prog i { display: block; width: 90px; height: 5px; border-radius: 3px; background: rgba(127,127,127,.35); margin-top: 6px; overflow: hidden; }
.stratum-prog i b { display: block; height: 100%; background: currentColor; }

/* Labs */
.lab {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; margin: 0 0 1.4em; font-family: var(--display); font-size: 14.5px; line-height: 1.4;
}
.lab-title { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.lab-hint { color: var(--muted); margin-bottom: 12px; }
.lab-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; margin-bottom: 12px; }
.ctl { display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.ctl output { color: var(--ink); font-family: var(--mono); font-size: 12.5px; }
.ctl input[type=number], .ctl select, .ctl input[type=text] {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); width: 9.5rem; color: var(--ink);
}
.ctl input[type=range] { width: 9.5rem; accent-color: var(--accent); }
.ctl.check { display: flex; align-items: center; gap: 6px; color: var(--ink); }
.lab button.sm {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); cursor: pointer;
}
.lab button.sm:hover { border-color: var(--accent); }
.lab canvas { max-width: 100%; border-radius: 6px; background: var(--paper); display: block; }
.lab textarea { width: 100%; min-height: 70px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); font-family: var(--mono); font-size: 13px; color: var(--ink); }
.lab .out { font-family: var(--mono); font-size: 13px; }
.lab table { font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.chip { font-family: var(--mono); font-size: 13px; padding: 2px 6px; border-radius: 4px; background: var(--accent-soft); white-space: pre; }
.chip:nth-child(3n+1) { background: color-mix(in srgb, var(--mark) 28%, var(--surface)); }
.chip:nth-child(3n+2) { background: color-mix(in srgb, var(--good) 22%, var(--surface)); }
.heat { border-collapse: separate; border-spacing: 2px; width: auto; font-family: var(--mono); font-size: 12px; }
.heat td, .heat th { padding: 0; border: 0; text-align: center; }
.heat th { font-weight: 400; color: var(--muted); padding: 2px 5px; white-space: nowrap; }
.heat td { width: 30px; height: 26px; border-radius: 3px; }
.bars { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: 5.5rem 1fr 3.6rem; gap: 8px; align-items: center; font-family: var(--mono); font-size: 13px; }
.bar i { display: block; height: 14px; border-radius: 3px; background: var(--accent); min-width: 1px; }
.bar.cut { opacity: .35; }
.fit-yes { color: var(--good); font-weight: 600; }
.fit-no { color: var(--bad); }
.lab-grid { display: grid; gap: 24px; max-width: 60rem; }
.empty { color: var(--muted); font-family: var(--display); }

@media (max-width: 860px) {
  body { display: block; font-size: 17px; }
  #side { position: fixed; inset: 0 auto 0 0; width: min(320px, 88vw); z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open #side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .menu-btn {
    display: block; position: fixed; z-index: 30; right: 14px; bottom: 14px; padding: 10px 16px;
    border-radius: 24px; border: 0; background: var(--ink); color: var(--paper); font-family: var(--display); font-weight: 600;
  }
  #main { padding-top: 28px; }
  .stratum { grid-template-columns: 1fr; gap: 6px; }
  .stratum-prog { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* Artifact-only features: sync status, ask about this lesson, podcast */
.sync { color: var(--muted); font-size: 12px; flex-basis: 100%; }
.side-foot { flex-wrap: wrap; gap: 6px; }
.chat { margin-top: 3em; padding-top: 1.5em; border-top: 2px solid var(--ink); }
.chat h2 { margin-top: 0; }
.chat-log { display: grid; gap: 12px; margin-bottom: 14px; }
.chat-msg { padding: 12px 16px; border-radius: 10px; min-width: 0; overflow-wrap: anywhere; }
.chat-msg.user { background: var(--accent-soft); font-family: var(--display); font-size: 16px; justify-self: end; max-width: 85%; }
.chat-msg.assistant { background: var(--surface); border: 1px solid var(--line); }
.chat-msg.assistant > :last-child { margin-bottom: 0; }
.chat-msg.assistant h2 { font-size: 1.15rem; margin: 1em 0 .4em; }
.chat-msg.assistant h2:first-child { margin-top: 0; }
.chat-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chat-quick button {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  font-family: var(--display); font-size: 13.5px; cursor: pointer;
}
.chat-quick button:hover { border-color: var(--accent); }
.chat-form { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-family: var(--body); font-size: 16px; resize: vertical;
}
.listen { flex-wrap: wrap; }
.listen button:disabled { opacity: .7; cursor: progress; }

/* Safe areas and theme plumbing for hosted viewing */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
:root[data-theme="dark"] { color-scheme: dark; }
#main {
  padding-left: max(clamp(20px, 5vw, 72px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(20px, 5vw, 72px), env(safe-area-inset-right, 0px));
}
#side { padding-left: max(20px, env(safe-area-inset-left, 0px)); }
.stratum > * { min-width: 0; }
@media (max-width: 860px) {
  #side { padding-top: calc(24px + env(safe-area-inset-top, 0px)); padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .menu-btn { right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .listen { margin-left: 0; margin-top: 8px; display: flex; }
}

/* AWS-hosted build: sign-in and podcast player */
.auth-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
dialog.auth { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); padding: 24px; width: min(360px, 90vw); }
dialog.auth::backdrop { background: rgba(0, 0, 0, .45); }
.auth-form { display: grid; gap: 12px; }
.auth-form h2 { margin: 0; }
.auth-form input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }
.auth-row { display: flex; gap: 10px; align-items: center; }
.auth-row button:not(.btn) { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; }
.auth-msg { margin: 0; color: var(--muted); font-size: 14px; min-height: 1.2em; }
.podcast-audio { display: block; width: 100%; margin: 12px 0; }

/* Highlight, then Explain */
.explain-btn { position: absolute; z-index: 30; font: 600 14px/1 inherit; padding: 9px 14px; border-radius: 999px; border: 0;
  background: var(--accent); color: #fff; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.explain-panel { position: fixed; z-index: 40; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: min(440px, calc(100vw - 32px)); max-height: min(70vh, 640px); overflow: auto; padding: 16px 18px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .28); }
.explain-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.explain-close { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 4px; }
.explain-panel blockquote { margin: 0 0 12px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--accent-soft); font-size: 14px; }
.explain-body { font-size: 15px; line-height: 1.55; }
.explain-body pre { overflow: auto; }
.explain-q { font-weight: 600; margin: 14px 0 6px; }
.explain-form { display: flex; gap: 8px; margin-top: 12px; }
.explain-form input { flex: 1; min-width: 0; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }
@media (max-width: 600px) { .explain-panel { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); width: auto; max-height: 60vh; } }

/* Diagrams written in lessons: steps, seq, bars */
.fig { margin: 0 0 1.5em; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-family: var(--display); font-size: 14.5px; line-height: 1.4; }
.fig figcaption { font-weight: 700; margin-bottom: 12px; }
.fig-scroll { overflow-x: auto; }
.fig-steps ol { list-style: none; margin: 0; padding: 0; counter-reset: st; }
.fig-steps li { position: relative; display: grid; grid-template-columns: 9.5rem 1fr; gap: 4px 14px; padding: 0 0 14px 30px; counter-increment: st; }
.fig-steps li:last-child { padding-bottom: 0; }
.fig-steps li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; animation: stpulse calc(var(--n) * 1.1s) calc(var(--i) * 1.1s) infinite; }
.fig-steps li::after { content: ""; position: absolute; left: 9.5px; top: 22px; bottom: 2px; width: 1.5px; background: var(--line); }
.fig-steps li:last-child::after { display: none; }
.fig-steps li span { color: var(--muted); font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
@keyframes stpulse { 0%, 100% { background: var(--accent-soft); color: var(--accent); } 4%, 12% { background: var(--accent); color: var(--surface); } 20% { background: var(--accent-soft); color: var(--accent); } }
@media (max-width: 560px) { .fig-steps li { grid-template-columns: 1fr; } }
.fbars { display: grid; gap: 10px; }
.fbar > span { display: block; font-size: 13.5px; margin-bottom: 3px; }
.fbar > div { display: flex; align-items: center; gap: 8px; }
.fbar i { display: block; height: 14px; width: 0; min-width: 2px; border-radius: 3px; background: var(--accent); transition: width .9s cubic-bezier(.2,.7,.2,1); flex: none; max-width: calc(100% - 6.5rem); }
.fbar i.hi { background: var(--mark); }
.fbar em { font-style: normal; font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.fbars.tight { gap: 4px; max-width: 26rem; }
.fbars.tight .fbar { display: grid; grid-template-columns: 4rem 1fr; align-items: center; }
.fbars.tight .fbar > span { margin: 0; font-family: var(--mono); }
.fbars.tight i { transition: none; }
.fig-seq svg { display: block; width: 100%; height: auto; font-family: var(--display); }
.fig-seq .life { stroke: var(--line); stroke-dasharray: 3 4; }
.fig-seq .actor { fill: var(--accent-soft); stroke: var(--accent); }
.fig-seq .an { fill: var(--ink); font-size: 12.5px; font-weight: 600; text-anchor: middle; }
.fig-seq .msg { stroke: var(--accent); stroke-width: 1.6; fill: none; animation: sqpulse calc(var(--n) * .9s) calc(var(--i) * .9s) infinite; }
.fig-seq .msg.dash { stroke-dasharray: 5 4; stroke: var(--muted); }
.fig-seq .mt { fill: var(--ink); font-size: 12px; text-anchor: middle; }
.fig-seq .mt.self { text-anchor: start; }
@keyframes sqpulse { 0%, 100% { stroke-width: 1.6; } 3%, 9% { stroke-width: 3.6; } 14% { stroke-width: 1.6; } }

/* Animated visuals */
.viz-pair { display: flex; flex-wrap: wrap; gap: 12px; }
.viz-pair.top { align-items: flex-start; }
.viz-note, .viz-cap { margin-top: 10px; color: var(--muted); font-size: 14px; max-width: 44rem; }
.viz-cap { color: var(--ink); min-height: 2.8em; }
.bp, .bf { display: block; width: 100%; height: auto; font-family: var(--display); }
.bp text, .bf text { text-anchor: middle; }
.bp-node rect { fill: var(--paper); stroke: var(--line); }
.bp-node.on rect { fill: var(--accent-soft); stroke: var(--accent); }
.bp .nm { font-size: 10.5px; fill: var(--muted); }
.bp .vl { font-size: 14px; font-family: var(--mono); fill: var(--ink); font-weight: 600; }
.bp-grad rect { fill: var(--mark); }
.bp-grad text { font-size: 11.5px; font-family: var(--mono); fill: #1a1300; font-weight: 600; }
.bp-w rect { fill: var(--surface); stroke: var(--line); }
.bp-w.upd rect { stroke: var(--good); stroke-width: 2; }
.bp-w .vl { font-size: 12px; }
.bp-w .gr { font-size: 10.5px; font-family: var(--mono); fill: var(--mark); font-weight: 700; }
.bp-w line { stroke: var(--muted); }
.bp-e { stroke: var(--line); stroke-width: 2; }
.bp-e.on { stroke: var(--accent); }
.bp-b { stroke: var(--mark); stroke-width: 2; fill: none; stroke-dasharray: 5 3; }
.bf .hw { stroke: var(--accent); stroke-width: 5; opacity: .35; }
.bf .bx { fill: var(--paper); stroke: var(--line); }
.bf .bx.done { stroke: var(--accent); }
.bf .bx.hot { fill: var(--mark); stroke: var(--mark); }
.bf .tx { font-size: 12.5px; fill: var(--ink); font-weight: 600; }
.bf .bx.hot + .tx, .bf .bx.hot + .tx + .sb { fill: #1a1300; }
.bf .sb { font-size: 9.5px; fill: var(--muted); }
.bf .lb { font-size: 11px; fill: var(--muted); text-anchor: start; }
.bf .rd, .bf .wr { stroke: var(--line); stroke-width: 1.5; fill: none; }
.bf .rd.hot, .bf .wr.hot { stroke: var(--mark); stroke-width: 2.5; }
.bf .pl { font-size: 15px; fill: var(--muted); text-anchor: start; }
.bf .pl.hot { fill: var(--mark); font-weight: 700; }
.pipe { display: grid; gap: 10px; }
.pstage { border-left: 3px solid var(--accent); padding: 2px 0 4px 12px; animation: pin .5s ease both; }
@keyframes pin { from { opacity: 0; transform: translateY(6px); } }
.ptitle b { display: block; }
.ptitle span { display: block; color: var(--muted); font-size: 13.5px; margin: 2px 0 8px; max-width: 42rem; }
.ptext { font-family: var(--body); font-size: 16px; }
.ptext.mono { font-family: var(--mono); font-size: 14px; }
.prow { display: flex; flex-wrap: wrap; gap: 4px; }
.pchip { font-family: var(--mono); font-size: 13px; padding: 2px 7px; border-radius: 4px; background: var(--accent-soft); white-space: pre; display: inline-block; margin: 1px; }
.pchip.num { background: color-mix(in srgb, var(--good) 22%, var(--surface)); }
.pchip.new { background: var(--mark); color: #1a1300; }
.ptable { width: auto; border-collapse: collapse; font-size: 13px; }
.ptable th { text-align: left; font-weight: 400; color: var(--muted); padding: 2px 14px 4px 0; border: 0; }
.ptable td { padding: 3px 14px 3px 0; border: 0; }
.ppair { display: flex; flex-wrap: wrap; gap: 12px; }
.lab pre.ptensor, .lab pre.ret-prompt { margin: 0; padding: 8px 12px; border-radius: 6px; background: var(--code-bg); color: var(--code-ink); font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; }
.ret-side { flex: 1 1 15rem; min-width: 14rem; font-size: 14px; }
.ret-side p { margin: 0 0 10px; }
.ret-h { font-weight: 700; margin-bottom: 4px; }
.ret-side ol { margin: 0; padding-left: 1.3em; }
.ret-side li { margin-bottom: 3px; }
.ret-side li i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.ret-side li em { font-style: normal; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: 8px; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .fig-steps li::before, .fig-seq .msg, .pstage { animation: none; } .fbar i { transition: none; } }

/* Sign-in screen (AWS build): nothing else is shown until there is a session */
html.gated body > :not(.gate) { display: none !important; }
html.gated body { display: block; }
.gate { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(22rem, 1fr); background: var(--paper); color: var(--ink); font-family: var(--display); }
.gate-strata { position: relative; display: grid; grid-template-columns: 4.5rem 1fr; background: #0B1C36; overflow: hidden; }
.gate-strata ol { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-rows: 1fr; }
.gate-strata li { --d: calc(var(--i) / 9); margin: 0; display: flex; align-items: center; padding: 0 clamp(1rem, 3vw, 2.5rem); font-size: clamp(.95rem, 1.35vw, 1.2rem); font-weight: 600; letter-spacing: -.005em;
  background: color-mix(in oklab, #D6E5F6 calc(100% - var(--d) * 100%), #0B1C36); color: #0B1C36;
  animation: gate-settle .7s cubic-bezier(.2, .7, .2, 1) calc(var(--i) * 70ms) both; }
.gate-strata li:nth-child(n+5) { color: #E8F0FA; }
.gate-rule { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: .6rem; padding: 1.4rem 0; background: #0B1C36; color: #C9D8EC; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.gate-rule i { position: relative; width: 1px; background: repeating-linear-gradient(to bottom, #6F87A8 0 1px, transparent 1px 12px); width: 9px; background-size: 9px 12px; opacity: .9; }
.gate-rule b { position: absolute; left: 50%; top: 0; width: 11px; height: 11px; margin-left: -5.5px; border-radius: 50%; background: var(--mark); box-shadow: 0 0 0 4px rgba(232, 169, 0, .22); animation: gate-sound 2.6s cubic-bezier(.45, 0, .2, 1) .5s both; }
@keyframes gate-settle { from { opacity: 0; transform: translateY(-14px); } }
@keyframes gate-sound { from { top: 0; } to { top: calc(100% - 11px); } }
.gate-panel { display: grid; place-items: center; padding: clamp(1.5rem, 5vw, 4rem); }
.gate-form { width: min(23rem, 100%); display: grid; gap: 1.05rem; }
.gate-form h1 { margin: 0; font-size: clamp(2.4rem, 5vw, 3.4rem); line-height: 1; letter-spacing: -.03em; font-weight: 800; }
.gate-sub { margin: -.3rem 0 .7rem; color: var(--muted); font-size: 1rem; line-height: 1.45; max-width: 21rem; }
.gate-field { display: grid; gap: .35rem; font-size: .9rem; font-weight: 600; }
.gate-field[hidden], .gate-hint[hidden] { display: none; }
.gate-field input { width: 100%; font: inherit; font-weight: 400; font-size: 1rem; padding: .75rem .85rem; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.gate-field input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.gate-pw { position: relative; }
.gate-pw input { padding-right: 4.2rem; }
.gate-peek { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); padding: .35rem .6rem; border: 0; border-radius: 6px; background: none; color: var(--accent); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.gate-peek:hover { background: var(--accent-soft); }
.gate-hint { margin: -.5rem 0 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.gate-msg { margin: 0; min-height: 1.3em; color: var(--bad); font-size: .9rem; font-weight: 600; }
.gate-msg:empty { min-height: 0; }
.gate-go { padding: .85rem 1rem; border: 0; border-radius: 8px; background: var(--accent); color: var(--surface); font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; }
.gate-go:hover { filter: brightness(1.08); }
.gate-go:focus-visible, .gate-peek:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.gate-go:disabled { opacity: .65; cursor: progress; }
.gate-note { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; }
@media (max-width: 800px) {
  .gate { grid-template-columns: 1fr; grid-template-rows: minmax(13rem, 34dvh) 1fr; }
  .gate-strata { grid-template-columns: 3.4rem 1fr; }
  .gate-strata li { font-size: .82rem; padding: 0 .9rem; }
  .gate-rule { padding: .8rem 0; font-size: .7rem; }
  .gate-panel { place-items: start center; padding-top: 2rem; }
}
@media (prefers-reduced-motion: reduce) { .gate-strata li { animation: none; } .gate-rule b { animation: none; top: calc(100% - 11px); } }

/* Glossary terms */
.gl { text-decoration: underline dotted var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; cursor: help; border-radius: 2px; }
.gl:hover, .gl:focus-visible { background: var(--accent-soft); outline: none; }
.gl-pop { position: absolute; z-index: 60; width: min(22rem, calc(100vw - 16px)); padding: 12px 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 28px rgba(8, 20, 40, .22); font-family: var(--display); font-size: 14px; line-height: 1.45; }
.gl-pop strong { display: block; margin-bottom: 4px; }

/* offline */
.offline-state { display: block; }
.offline-state:empty { display: none; }
html.is-offline #podcast, html.is-offline .chat-quick, html.is-offline .chat-form { opacity: .5; }
.offline-none { max-width: 34rem; margin: 20vh auto; padding: 0 24px; font-size: 1.05rem; line-height: 1.5; }
.podcast-audio[hidden] { display: none; }
