:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --ink: #0f172a;
  --muted: #475569;
  --card: #ffffff;
  --surface: #ffffff;
  --accent: #0f766e;
  --accent-ink: #115e59;
  --accent-soft: #ccfbf1;
  --line: rgba(15, 23, 42, 0.1);
  --ok: #166534;
  --bad: #9f1239;
  --ok-bg: #dcfce7;
  --bad-bg: #ffe4e6;
  --lab: #f8fafc;
  --glass: rgba(255, 255, 255, 0.72);
  --code-inline: #e2e8f0;
  --grid: rgba(15, 23, 42, 0.045);
  --glow-a: rgba(15, 118, 110, 0.16);
  --glow-b: rgba(37, 99, 235, 0.12);
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --card: #111827;
  --surface: #0f172a;
  --accent: #2dd4bf;
  --accent-ink: #99f6e4;
  --accent-soft: rgba(45, 212, 191, 0.16);
  --line: rgba(226, 232, 240, 0.14);
  --ok: #4ade80;
  --bad: #fb7185;
  --ok-bg: rgba(22, 101, 52, 0.35);
  --bad-bg: rgba(159, 18, 57, 0.38);
  --lab: #0f172a;
  --glass: rgba(15, 23, 42, 0.72);
  --code-inline: #1e293b;
  --grid: rgba(226, 232, 240, 0.05);
  --glow-a: rgba(45, 212, 191, 0.14);
  --glow-b: rgba(96, 165, 250, 0.12);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  overflow-x: clip;
  direction: rtl;
  text-align: right;
  font-family: Heebo, "Segoe UI", Arial, sans-serif;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    radial-gradient(900px 520px at 100% -8%, var(--glow-a), transparent 60%),
    radial-gradient(760px 480px at 0% 0%, var(--glow-b), transparent 55%);
  background-size: 52px 52px, 52px 52px, auto, auto;
  color: var(--ink);
  line-height: 1.65;
  transition: background-color 0.35s ease, color 0.35s ease;
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  transition: transform 0.28s ease;
}

.topbar.is-away {
  transform: translateY(-100%);
  pointer-events: none;
}

.topbar-inner,
.page,
.footer-note {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

.page {
  padding-bottom: 4.5rem;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: inherit;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.85rem;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  padding: 0.4rem 0.05rem;
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--accent-ink);
}

.nav a.active {
  color: var(--accent);
}

.page h1 {
  margin: 0.4rem 0 0.6rem;
  font-size: 1.7rem;
}

.eyebrow,
.meta {
  color: var(--accent);
  font-weight: 700;
  margin: 0;
}

.muted,
.footer-note {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.card,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

a.card {
  text-decoration: none;
  color: inherit;
}

a.card:hover,
.area-card:hover {
  border-color: var(--accent);
}

.area-card h2 {
  margin: 0.2rem 0 0.4rem;
  font-size: 1.15rem;
}

.unit-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.pill {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.pill.soon {
  background: #f5f5f4;
  color: var(--muted);
}

.goals {
  padding-inline-start: 1.2rem;
}

.section {
  margin: 1.75rem 0;
}

.section h3 {
  font-size: 1.05rem;
  margin: 1.1rem 0 0.4rem;
}

.term-list dt {
  font-weight: 700;
  margin-top: 0.8rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.term-list dd {
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

pre {
  margin: 0.75rem 0;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

pre,
code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, Monaco, monospace;
}

.code {
  background: #1c1917;
  color: #f5f5f4;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-size: 0.9rem;
  direction: ltr;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}

.lab {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1.15rem 1.2rem 1.05rem;
  margin: 1.75rem 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.lab-head {
  margin-bottom: 0.85rem;
}

.lab-kicker {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0f766e;
}

.lab-live {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: lab-ping 1.6s ease-out infinite;
}

@keyframes lab-ping {
  70% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.lab h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.lab-brief {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.lab-stage {
  margin: 0.7rem 0 0.85rem;
}

.lab-with-code {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 0.75rem;
  align-items: start;
}

.lab-code-panel,
.lab-panel,
.lab-with-code > * {
  min-width: 0;
  max-width: 100%;
}

.lab-code-panel .lab-snippet {
  margin: 0;
  padding: 0.55rem 0.45rem;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.lab-snippet code {
  display: block;
}

.code-line {
  display: block;
  padding: 0.05rem 0.4rem;
  margin: 0.05rem 0;
  border-radius: 4px;
  border-left: 3px solid transparent;
}

.code-line.on {
  background: rgba(45, 212, 191, 0.18);
  border-left-color: #2dd4bf;
  color: #ccfbf1;
}

.lab-panel {
  background: var(--surface);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}

.lab-panel-k {
  margin: 0 0 0.55rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.lab > .feedback {
  margin-top: 0.75rem;
  background: #0f172a;
  color: #cbd5e1;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.55;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  min-height: 3.2rem;
}

.lab > .feedback::before {
  content: "[מערכת] ";
  color: #38bdf8;
  font-weight: 700;
}

.lab > .feedback.ok {
  color: #bbf7d0;
}

.lab > .feedback.ok::before {
  color: #4ade80;
}

.lab > .feedback.bad {
  color: #fecdd3;
}

.lab > .feedback.bad::before {
  color: #fb7185;
}

.shared-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 8.5rem;
}

.shared-val {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 2rem;
  font-weight: 800;
  color: #4ade80;
  background: #0f172a;
  padding: 0.55rem 1.1rem;
  border-radius: 12px;
  min-width: 4.5rem;
}

.race-board {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.7rem;
  align-items: stretch;
}

.step-line {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
  padding: 0.28rem 0.45rem;
  border-radius: 6px;
  color: #64748b;
  direction: ltr;
  text-align: left;
}

.step-line.on {
  background: #0f172a;
  color: #67e8f9;
}

.sql-engine {
  background: #0f172a;
  color: #86efac;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  min-height: 3.4rem;
  direction: rtl;
  text-align: right;
}

.web-stage {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.web-end {
  background: var(--surface);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-weight: 700;
  text-align: center;
  min-width: 5.5rem;
}

.web-end.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.quiz,
.tree-node {
  margin: 0.75rem 0;
}

.option,
.tree-toggle,
button.primary,
button.ghost {
  font: inherit;
  cursor: pointer;
}

.option {
  display: block;
  width: 100%;
  text-align: right;
  direction: rtl;
  unicode-bidi: isolate;
  margin: 0.4rem 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.option:hover {
  border-color: var(--accent);
}

.option.correct {
  background: var(--ok-bg);
  border-color: var(--ok);
}

.option.wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
}

.feedback {
  margin-top: 0.5rem;
  font-weight: 600;
}

.feedback.ok {
  color: var(--ok);
}

.feedback.bad {
  color: var(--bad);
}

.tree-toggle {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
}

.tree-children {
  margin: 0.5rem 0 0.5rem 0;
  padding-inline-start: 1rem;
  border-inline-start: 2px solid var(--line);
}

.risk-form label {
  display: grid;
  gap: 0.3rem;
  margin: 0.7rem 0;
  font-weight: 600;
}

.risk-form input {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
}

button.ghost {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-weight: 700;
  padding: 0;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0;
}

.filter-row button {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
}

.filter-row button.active {
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.kind {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}

.soon-box {
  padding: 1.25rem;
}

.mem-cols,
.copy-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.mem-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  min-height: 8rem;
}

.mem-col h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.slot {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  margin: 0.35rem 0;
  font-size: 0.9rem;
}

.slot.dead {
  background: var(--bad-bg);
  border-style: solid;
  border-color: var(--bad);
}

.slot.ok {
  background: var(--ok-bg);
}

.slot.linked {
  background: #fef9c3;
  border-style: solid;
  border-color: #ca8a04;
}

.stack-viz {
  margin: 0.75rem 0;
}

.page-summary {
  max-width: 960px;
  padding-bottom: 4rem;
}

.lead {
  font-size: 1.05rem;
}

.prose-chapter,
.prose-part,
.cards-chapter {
  scroll-margin-top: 1rem;
}

.prose-chapter > h2 {
  margin-bottom: 0.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--accent);
}

.prose-part {
  margin: 1.3rem 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.prose-part h3 {
  font-size: 1.08rem;
  margin: 0 0 0.45rem;
}

.prose-part code,
.section code,
.study-text code,
.option code,
.feedback code,
.fold-body code,
.card-rich code,
.card-detail code,
.print-quiz code,
.exam-sol code,
.verdict code,
.drill code {
  font-size: 0.92em;
  background: var(--code-inline);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

.study-text {
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.study-text p {
  margin: 0.45rem 0;
}

.study-text ul {
  margin: 0.4rem 0 0.7rem;
  padding-inline-start: 1.2rem;
}

.study-text li {
  margin: 0.25rem 0;
}

.quiz-lead > p:first-child {
  font-weight: 700;
}

.drill .quiz-lead > p:first-child {
  font-size: 1.2rem;
}

.study-text pre.code {
  margin: 0.75rem 0;
}

.study-text pre.code code,
pre.code code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: inherit;
}

.cards-chapter {
  margin: 1.75rem 0 2.5rem;
  padding: 1rem 0 0.25rem;
  border-top: 1px dashed var(--line);
}

.cards-chapter-title {
  font-size: 1.05rem;
  margin: 0 0 0.85rem;
  color: var(--accent-ink);
}

.grid-cards {
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  align-items: stretch;
}

.card-rich {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card-rich h2 {
  font-size: 1.08rem;
  margin: 0.15rem 0 0.5rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card-rich p {
  margin: 0 0 0.65rem;
}

.card-detail {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 !important;
  padding-top: 0.45rem;
  border-top: 1px solid var(--line);
}

.to-cards {
  font-weight: 700;
}

.toc-fab {
  position: fixed;
  bottom: 1.25rem;
  inset-inline-start: 1.25rem;
  z-index: 40;
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.28);
}

.toc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.35);
  z-index: 50;
}

.toc-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: min(22rem, 92vw);
  z-index: 60;
  background: var(--card);
  border-inline-end: 1px solid var(--line);
  padding: 1rem 1.1rem 2rem;
  overflow: auto;
  box-shadow: 8px 0 24px rgba(28, 25, 23, 0.08);
}

.toc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.toc-x {
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.toc-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 1rem 0 0.35rem;
}

.toc-choice {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  font-size: 0.92rem;
  margin: 0.35rem 0;
  cursor: pointer;
}

.toc-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.6rem 0;
}

.toc-links a.is-current {
  font-weight: 700;
}

.toc-tree {
  padding-inline-start: 1.1rem;
  margin: 0.2rem 0 1rem;
}

.toc-tree ul {
  padding-inline-start: 0.9rem;
  margin: 0.25rem 0 0.5rem;
}

.toc-tree a {
  text-decoration: none;
  color: var(--ink);
}

.toc-tree a:hover {
  color: var(--accent);
}

.lab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.7rem 0 0.3rem;
}

.viz {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin: 1rem 0 1.4rem;
}

.viz-kicker {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  text-transform: uppercase;
}

.viz h3 {
  margin: 0.15rem 0 0.7rem;
  font-size: 1.05rem;
}

.viz-fb {
  margin: 0.65rem 0 0;
  font-weight: 600;
}

.viz-fb.ok {
  color: var(--ok);
}

.viz-fb.bad {
  color: var(--bad);
}

.cia-tri {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  direction: ltr;
}

.cia-node,
.layer-row,
.track,
.door,
.iso-bldg,
.sql-pipe,
.osi-layer {
  font: inherit;
  cursor: pointer;
  text-align: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
}

.cia-node {
  padding: 0.85rem 0.4rem;
  font-weight: 700;
  animation: cia-breathe 3.2s ease-in-out infinite;
}

.cia-node span {
  display: block;
  font-size: 1.4rem;
  color: var(--accent);
}

.cia-node.on,
.layer-row.on,
.track.on,
.door.on,
.iso-bldg.on,
.sql-pipe.on,
.osi-layer.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.22);
}

.cia-node:nth-child(1) {
  animation-delay: 0s;
}
.cia-node:nth-child(2) {
  animation-delay: 0.4s;
}
.cia-node:nth-child(3) {
  animation-delay: 0.8s;
}

@keyframes cia-breathe {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.layer-stack {
  display: grid;
  gap: 0.4rem;
}

.layer-row {
  padding: 0.55rem 0.7rem;
  font-weight: 600;
}

.trust-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.trust-bead {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-weight: 700;
}

.trust-arr {
  color: var(--muted);
  font-weight: 700;
}

.trust-row.play .trust-bead {
  animation: bead-on 0.7s ease both;
}

.trust-row.play [data-trust="0"] {
  animation-delay: 0s;
}
.trust-row.play [data-trust="1"] {
  animation-delay: 0.28s;
}
.trust-row.play [data-trust="2"] {
  animation-delay: 0.56s;
}

@keyframes bead-on {
  0% {
    transform: scale(0.92);
    background: var(--surface);
  }
  40% {
    transform: scale(1.08);
    background: var(--ok-bg);
    border-color: var(--ok);
  }
  100% {
    transform: scale(1);
    background: var(--ok-bg);
    border-color: var(--ok);
  }
}

.ptr-scene {
  display: flex;
  align-items: flex-end;
  gap: 1.2rem;
  justify-content: center;
  min-height: 8rem;
}

.ptr-house {
  width: 7.2rem;
  text-align: center;
  transition: opacity 0.35s, transform 0.35s;
}

.ptr-roof {
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-inline-start: 3.6rem solid transparent;
  border-inline-end: 3.6rem solid transparent;
  border-bottom: 1.6rem solid #0f766e;
}

.ptr-body {
  display: block;
  background: var(--accent-soft);
  border: 1px solid #0f766e;
  border-top: 0;
  padding: 0.9rem 0.4rem;
  font-weight: 700;
}

.ptr-mail {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  min-width: 6.5rem;
  text-align: center;
}

.ptr-house.glow,
.ptr-mail.glow {
  animation: glow-ok 0.8s ease;
}

.ptr-mail.empty {
  background: var(--bad-bg);
  border-color: var(--bad);
}

.ptr-house.gone {
  opacity: 0.25;
  transform: scale(0.92);
}

@keyframes glow-ok {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 101, 52, 0.45);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(22, 101, 52, 0);
  }
}

.plate-rack {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0.25rem;
  min-height: 7.5rem;
  margin-bottom: 0.5rem;
}

.plate {
  width: min(16rem, 90%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  text-align: center;
  font-weight: 600;
  animation: plate-in 0.35s ease;
}

.plate.on-top {
  background: var(--accent-soft);
  border-color: var(--accent);
}

@keyframes plate-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.draw-svg {
  width: min(100%, 18rem);
  height: auto;
  display: block;
  margin: 0 auto;
}

.cup-draw,
.stack-scene,
.gil-draw,
.lane-draw {
  margin: 0 auto 0.7rem;
}

.cup-svg {
  width: min(100%, 14rem);
}

.glass,
.glass-rim {
  fill: none;
  stroke: #e7e5e4;
  stroke-width: 3;
}

.table {
  fill: #44403c;
}

.water {
  fill: #38bdf8;
  transform: translateY(128px);
  transition: transform 1.15s ease;
}

.cup-draw.is-fit .water {
  transform: translateY(46px);
}

.cup-draw.is-over .water {
  transform: translateY(-8px);
}

.rim-water,
.puddle,
.drop,
.spill-stream {
  opacity: 0;
}

.rim-water {
  fill: #7dd3fc;
  transition: opacity 0.3s ease 0.5s;
}

.puddle {
  fill: #0284c7;
  transform-box: fill-box;
  transform-origin: center;
  transform: scaleX(0.15);
  transition: opacity 0.35s ease 0.75s, transform 0.55s ease 0.75s;
}

.spill-stream {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 4;
  stroke-linecap: round;
  transition: opacity 0.3s ease 0.55s;
}

.drop {
  fill: #38bdf8;
}

.cup-draw.is-over .rim-water,
.cup-draw.is-over .spill-stream {
  opacity: 0.95;
}

.cup-draw.is-over .puddle {
  opacity: 0.9;
  transform: scaleX(1);
}

.cup-draw.is-over .drop {
  animation: drip 0.95s ease-in infinite;
}

.cup-draw.is-over .drop.d2 {
  animation-delay: 0.25s;
}

.cup-draw.is-over .drop.d3 {
  animation-delay: 0.45s;
}

@keyframes drip {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    transform: translateY(42px);
    opacity: 0;
  }
}

.stack-scene {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.8rem;
  align-items: stretch;
  max-width: 26rem;
}

.stack-svg {
  width: min(100%, 13rem);
  grid-row: 1;
}

.stack-legend {
  list-style: none;
  position: relative;
  margin: 0;
  padding: 0;
  min-height: 0;
  font-weight: 800;
  font-size: 0.86rem;
}

.stack-legend li {
  position: absolute;
  inset-inline-start: 0;
  transform: translateY(-50%);
}

.stack-legend li:nth-child(1) { top: 13.5%; }
.stack-legend li:nth-child(2) { top: 28.8%; }
.stack-legend li:nth-child(3) { top: 43.8%; }
.stack-legend li:nth-child(4) { top: 57.9%; }
.stack-legend li:nth-child(5) { top: 75.3%; }

.stack-scene figcaption,
.cup-draw figcaption,
.lane-cap {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0.2rem 0 0;
}

.slab rect {
  fill: #44403c;
  stroke: #d6d3d1;
  stroke-width: 2;
}

.slab.gold rect {
  fill: #854d0e;
  stroke: #facc15;
}

.slab.base rect {
  fill: #292524;
}

.bird ellipse,
.bird path {
  fill: #facc15;
}

.bird .eye {
  fill: #1c1917;
}

.bird .wing {
  fill: #eab308;
}

.stack-water {
  fill: #38bdf8;
  height: 10px;
  transition: height 1s ease;
}

.stack-scene.is-ok .stack-water {
  height: 42px;
}

.stack-scene.is-spill .stack-water {
  height: 176px;
}

.crack,
.check,
.stop,
.bad-tag {
  opacity: 0;
}

.crack {
  fill: none;
  stroke: #7f1d1d;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.check circle,
.stop circle {
  fill: #14532d;
}

.stop circle {
  fill: #7f1d1d;
}

.check path,
.stop path {
  fill: none;
  stroke: #fafaf9;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.tag rect {
  fill: #fef9c3;
  stroke: #ca8a04;
}

.tag text {
  fill: #1c1917;
  font-size: 12px;
  font-weight: 800;
}

.stack-scene.is-ok .check,
.stack-scene.is-ok .tag {
  opacity: 1;
}

.stack-scene.is-ok .ret-slab rect {
  stroke: #4ade80;
}

.stack-scene.is-spill .crack,
.stack-scene.is-spill .stop,
.stack-scene.is-spill .bad-tag {
  opacity: 1;
}

.stack-scene.is-spill .tag {
  opacity: 0;
}

.stack-scene.is-spill .bird {
  transform-box: fill-box;
  transform-origin: center;
  animation: bird-shake 0.45s ease 2;
}

.stack-scene.is-spill .ret-slab rect {
  stroke: #fb7185;
}

@keyframes bird-shake {
  0%,
  100% {
    transform: rotate(0);
  }
  30% {
    transform: rotate(-12deg);
  }
  70% {
    transform: rotate(10deg);
  }
}

.term-flow,
.isa-row,
.guard-grid {
  display: grid;
  gap: 0.6rem;
}

.term-flow {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.isa-row,
.guard-grid {
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
}

.pic-btn {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0.35rem 0.25rem 0.5rem;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 0.2rem;
}

.pic-btn span {
  font-size: 0.82rem;
  font-weight: 800;
}

.pic-btn:hover,
.pic-btn.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mini-svg {
  width: 4.2rem;
  height: auto;
}

.mini-svg.tall {
  width: 6.5rem;
}

.ink {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.ink.shield,
.ink.tear {
  fill: none;
}

.fruit {
  fill: #ef4444;
}

.leaf {
  fill: #22c55e;
}

.stem,
.roof,
.wall,
.window {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.wall {
  fill: #44403c;
}

.window {
  fill: #7dd3fc;
}

.roof {
  fill: #b45309;
}

.pin path {
  fill: #0f766e;
}

.pin text {
  fill: #fafaf9;
  font-size: 11px;
  font-weight: 800;
}

.page {
  fill: #e7e5e4;
}

.lines,
.ban,
.ban-slash {
  fill: none;
  stroke: #1c1917;
  stroke-width: 2;
}

.ban {
  stroke: #be123c;
}

.ban-slash {
  stroke: #be123c;
  stroke-width: 2.4;
}

.play {
  fill: #1c1917;
}

.col {
  fill: #57534e;
}

.col.bad {
  fill: #be123c;
}

.col.good {
  fill: #15803d;
}

.person .head {
  fill: #a8a29e;
  stroke: currentColor;
  stroke-width: 2;
}

.person.on .head {
  fill: #38bdf8;
}

.person .limb,
.lock rect,
.lock path,
.road,
.screen,
.walker,
.mail rect,
.mail path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lock rect {
  fill: #facc15;
  stroke: #854d0e;
}

.lock path {
  stroke: #854d0e;
}

.lock {
  transform-box: view-box;
  transform-origin: 0 0;
  transition: transform 0.5s ease;
}

.gil-draw.swapped .lock {
  transform: translate(53%, 0);
}

.screen {
  fill: #1e293b;
}

.road {
  stroke-width: 4;
}

.mail rect {
  fill: #fef9c3;
  stroke: #ca8a04;
}

.mail path {
  stroke: #ca8a04;
}

.mail.echo {
  opacity: 0;
}

.lane-draw.is-replay .mail.echo {
  opacity: 1;
  transition: opacity 0.35s ease;
}

.lane-draw.is-mitm .walker {
  stroke: #fb7185;
}

.lane-cap {
  display: flex;
  justify-content: space-between;
  max-width: 18rem;
  margin: 0.25rem auto 0;
}

.envelope {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.35rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  min-width: min(22rem, 100%);
}

.env-buf,
.env-ret,
.env-seal {
  text-align: center;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

.env-buf {
  background: var(--code-inline);
}

.env-ret {
  background: var(--accent-soft);
}

.env-seal {
  background: #fef9c3;
  border: 2px dashed #ca8a04;
}

.env-seal.ok {
  background: var(--ok-bg);
  border-style: solid;
  border-color: var(--ok);
}

.env-seal.broke {
  background: var(--bad-bg);
  border-color: var(--bad);
  animation: canary-shake 0.45s ease;
}

@keyframes canary-shake {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-8deg);
  }
  75% {
    transform: rotate(8deg);
  }
}

.vt-scene {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.vt-obj,
.vt-tab {
  min-width: 9rem;
}

.vt-arrow {
  font-size: 1.4rem;
  color: var(--accent);
}

.door-row,
.track-pair,
.iso-pair,
.sql-pair,
.endian-row,
.hyb-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.door-row.compact,
.iso-pair.compact {
  margin-bottom: 0.5rem;
}

.door,
.sql-pipe {
  padding: 0.7rem;
  display: grid;
  gap: 0.3rem;
}

.door-tag {
  font-weight: 700;
}

.bad-door,
.bad-pipe {
  border-color: #fecaca;
}

.ok-door,
.ok-pipe {
  border-color: #bbf7d0;
}

.track {
  padding: 0.65rem;
  text-align: right;
  display: grid;
  gap: 0.4rem;
}

.track-label {
  font-weight: 700;
}

.pkt-line {
  display: flex;
  gap: 0.35rem;
  height: 1.1rem;
  align-items: center;
}

.pkt {
  display: block;
  height: 0.7rem;
  border-radius: 4px;
  background: var(--accent);
  animation: pkt-slide 1.8s linear infinite;
}

.pkt.p1 {
  width: 2.2rem;
}
.pkt.p2 {
  width: 1.4rem;
  animation-delay: 0.3s;
}
.pkt.p3 {
  width: 1.8rem;
  animation-delay: 0.6s;
}

.datagrams .pkt {
  width: 1.6rem;
  height: 1.1rem;
  animation-name: dgram-hop;
}

@keyframes pkt-slide {
  0% {
    transform: translateX(8px);
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateX(-18px);
    opacity: 0.5;
  }
}

@keyframes dgram-hop {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.endian-row,
.hyb-row {
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

bdi,
.latn,
[dir="ltr"],
[dir="rtl"],
[dir="auto"] {
  unicode-bidi: isolate;
}

.latn,
bdi.latn,
bdi[dir="ltr"],
[dir="ltr"] {
  direction: ltr;
  text-align: left;
}

bdi[dir="rtl"],
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

code,
kbd,
samp,
var {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}

.endian-box,
.hyb-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
  text-align: center;
}

.ok-box {
  background: var(--ok-bg);
  border-color: var(--ok);
}

.bytes {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.35rem 0;
}

.bytes span {
  background: #1c1917;
  color: #fefce8;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace;
}

.http-road {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.http-end {
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  white-space: nowrap;
}

.http-wire {
  position: relative;
  flex: 1;
  height: 2.4rem;
  background: repeating-linear-gradient(
    -45deg,
    #e7e5e4,
    #e7e5e4 6px,
    #fafaf9 6px,
    #fafaf9 12px
  );
  border-radius: 999px;
  overflow: hidden;
}

.http-pkt {
  position: absolute;
  top: 0.35rem;
  right: 6%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.http-pkt.fly {
  animation: http-fly 1.4s ease-in-out;
}

@keyframes http-fly {
  0% {
    right: 6%;
  }
  45% {
    right: 62%;
  }
  55% {
    right: 62%;
  }
  100% {
    right: 6%;
  }
}

.ticket {
  max-width: 16rem;
  margin: 0 auto;
  background: #fffbeb;
  border: 2px dashed #d97706;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  text-align: center;
}

.ticket.stamped {
  border-style: solid;
  animation: stamp 0.4s ease;
}

@keyframes stamp {
  0% {
    transform: scale(1.08) rotate(-2deg);
  }
  100% {
    transform: none;
  }
}

.iso-bldg {
  display: grid;
  gap: 0.25rem;
  padding: 0.55rem;
}

.iso-roof {
  font-weight: 700;
  background: #0f766e;
  color: #fff;
  border-radius: 6px 6px 0 0;
  padding: 0.3rem;
}

.iso-bldg.ct .iso-roof {
  background: #57534e;
}

.iso-floor {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0.3rem;
  font-size: 0.9rem;
}

.warn-floor {
  background: #fef9c3;
}

.wrap-meter {
  position: relative;
  height: 1.35rem;
  background: var(--code-inline);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0 1.1rem;
}

.wrap-bar {
  height: 100%;
  width: 28%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.45s ease, background 0.3s;
}

.wrap-bar.wrapped {
  background: var(--bad);
  animation: wrap-snap 0.4s ease;
}

.wrap-cap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  pointer-events: none;
}

.int-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.int-facts div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
}

.int-facts strong {
  display: block;
  margin-top: 0.12rem;
  color: var(--ink);
  font-size: 0.92rem;
}

.lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.lang-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--card);
}

.lang-chip.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

@keyframes wrap-snap {
  0% {
    transform: scaleX(1.4);
  }
  100% {
    transform: none;
  }
}

.osi-stack {
  display: grid;
  gap: 0.3rem;
}

.osi-layer {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  padding: 0.4rem 0.65rem;
  text-align: right;
}

.osi-num {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent-soft);
  font-weight: 700;
  font-size: 0.85rem;
}

.osi-layer.on {
  animation: layer-pop 0.35s ease;
}

@keyframes layer-pop {
  from {
    transform: scale(0.97);
  }
  to {
    transform: none;
  }
}

.race-lanes {
  display: grid;
  gap: 0.45rem;
  margin: 0.5rem 0 0.7rem;
}

.race-lane {
  display: grid;
  grid-template-columns: 4.2rem 1fr;
  gap: 0.4rem;
  align-items: center;
  font-weight: 600;
}

.race-lane i {
  display: block;
  height: 0.85rem;
  width: 14%;
  border-radius: 999px;
  background: #a8a29e;
  transition: width 0.45s ease, background 0.3s;
}

.race-lane i.go {
  background: #f59e0b;
}

.race-lane i.locked {
  background: var(--accent);
}

@media (max-width: 640px) {
  .page {
    padding-bottom: 6rem;
  }

  .mem-cols,
  .copy-cols,
  .race-board,
  .web-stage,
  .lab-with-code {
    grid-template-columns: minmax(0, 1fr);
  }

  .term-flow,
  .cia-tri,
  .door-row,
  .track-pair,
  .iso-pair,
  .sql-pair,
  .endian-row,
  .hyb-row,
  .int-facts,
  .lang-grid,
  .threat-kids,
  .grid-cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .envelope {
    grid-template-columns: minmax(0, 1fr);
  }

  .pager {
    flex-direction: column;
  }

  .stage-tools {
    top: 0.5rem;
    inset-inline-start: 0.5rem;
    max-width: calc(100vw - 6.5rem);
  }

  .wordmark.is-float {
    top: 0.5rem;
    inset-inline-end: 0.5rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
  }

  .toc-fab {
    bottom: 1rem;
    inset-inline-start: 1rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
  }

  .ai-fab {
    bottom: 1rem;
    left: 1rem;
    padding: 8px 14px;
    font-size: 0.85rem;
  }
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.fold {
  margin: 1.05rem 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.fold[open] {
  border-color: var(--accent);
}

.fold > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  font-weight: 700;
  color: var(--accent-ink);
  border-radius: 14px;
}

.fold > summary::-webkit-details-marker {
  display: none;
}

.fold > summary::before {
  content: "+";
  flex: 0 0 1.65rem;
  height: 1.65rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  line-height: 1;
}

.fold[open] > summary::before {
  content: "−";
}

.fold > summary:hover {
  background: var(--accent-soft);
}

.fold-body {
  padding: 0.15rem 1rem 1rem;
  border-top: 1px solid var(--line);
}

.fold-body .fold {
  margin-inline: 0;
}

@media (prefers-reduced-motion: reduce) {
  .fold > summary,
  .topbar {
    transition: none;
  }
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.25rem;
}

.rail a:hover,
.rail a:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.theme-toggle,
.wordmark.is-float {
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--ink);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}

.theme-toggle {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.theme-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
  transition: transform 0.4s ease;
}

[data-theme="dark"] .theme-toggle svg {
  transform: rotate(-20deg);
}

.theme-toggle:hover,
.wordmark.is-float:hover {
  transform: translateY(-2px);
}

.theme-toggle.is-float,
.wordmark.is-float {
  position: fixed;
  top: 1rem;
  z-index: 40;
}

.theme-toggle.is-float {
  inset-inline-start: 1rem;
}

.wordmark.is-float {
  inset-inline-end: 1rem;
  text-decoration: none;
  font-weight: 800;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
}

.page-stage {
  padding-top: 4.6rem;
}

.hero,
.why-card,
.path-stop,
.portal {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.hero {
  text-align: center;
  border-radius: 28px;
  padding: 2rem 1.4rem 1.7rem;
  max-width: 760px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(1.7rem, 8vw, 3.35rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0.55rem 0 0.7rem;
  text-wrap: balance;
}

.hero-lead {
  margin: 0 auto;
  max-width: 38rem;
  color: var(--muted);
}

.hero-pill {
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 0.28rem 0.75rem;
  cursor: pointer;
  margin-top: 0.85rem;
}

.hero-pill[aria-expanded="true"] {
  background: var(--accent);
  color: #fff;
}

.why {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  max-width: 760px;
  margin: 0 auto;
  transition: grid-template-rows 0.45s ease, opacity 0.35s ease, margin 0.45s ease;
}

.why.open {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 0.85rem;
}

.why-inner {
  overflow: hidden;
}

.why-card {
  border-radius: 20px;
  padding: 1rem 1.15rem 1.15rem;
  text-align: right;
}

.why-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.why-card p {
  margin: 0;
  color: var(--muted);
}

.stage-chevron {
  width: 0.7rem;
  height: 0.7rem;
  margin: 1.15rem auto 0.35rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  animation: bob 1.6s ease-in-out infinite;
}

@keyframes bob {
  50% {
    transform: translateY(6px) rotate(45deg);
  }
}

.stage-portals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.15rem;
}

.portal {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 0.85rem;
  min-height: 0;
  border-radius: 22px;
  text-decoration: none;
  color: inherit;
  text-align: start;
  padding: 1rem 1.1rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.portal:hover,
.portal:focus-visible {
  transform: translateY(-3px);
}

.portal-practice {
  --portal: #059669;
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--portal) 16%, transparent), var(--glass));
}

.portal-summary {
  --portal: #2563eb;
  background:
    linear-gradient(195deg, color-mix(in srgb, var(--portal) 16%, transparent), var(--glass));
}

.portal-icon {
  grid-row: span 2;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--portal);
  background: color-mix(in srgb, var(--portal) 14%, var(--surface));
}

.portal-icon svg {
  width: 1.45rem;
  height: 1.45rem;
}

.portal-kicker {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--portal);
}

.portal strong {
  font-size: clamp(1.2rem, 2.4vw, 1.65rem);
  font-weight: 800;
  line-height: 1.12;
}

.course-path {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.path-stop {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border-radius: 18px;
  padding: 0.75rem 0.95rem;
  border-inline-start: 4px solid transparent;
  animation: rise 0.45s ease both;
  animation-delay: calc(var(--i) * 45ms);
}

.path-stop:hover,
.path-stop:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.path-stop:focus-visible {
  outline: 2px solid var(--hue, var(--accent));
  outline-offset: 3px;
}

.path-stop:active {
  transform: translateY(0);
}

.path-stop.is-resume {
  border-inline-start-color: var(--hue);
  background: linear-gradient(to left, color-mix(in srgb, var(--hue) 16%, transparent), var(--glass) 46%);
}

.path-num {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--hue, var(--accent));
  background: color-mix(in srgb, var(--hue, var(--accent)) 16%, var(--surface));
}

.path-stop.is-seen .path-num::after {
  content: "";
  position: absolute;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--hue, var(--accent));
  top: -1px;
  inset-inline-end: -1px;
  box-shadow: 0 0 0 2px var(--surface);
}

.path-go {
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--hue, var(--accent));
  color: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  white-space: nowrap;
}

.resume-strip {
  display: block;
  max-width: 760px;
  margin: 1rem auto 0;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 14px;
  padding: 0.7rem 1rem;
  transition: transform 0.25s ease;
}

.resume-strip:hover,
.resume-strip:focus-visible {
  transform: translateY(-2px);
}

.stage-more {
  text-align: center;
  margin: 0.4rem 0 0.2rem;
}

.stage-more a {
  font-weight: 700;
  text-decoration: none;
}

.rise {
  animation: rise 0.6s ease both;
}

.rise-2 {
  animation-delay: 0.12s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.back {
  display: inline-flex;
  font-weight: 700;
  text-decoration: none;
}

.back-row {
  margin-bottom: 0.2rem;
}

.path {
  display: grid;
  gap: 0.7rem;
}

.path-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  animation: rise 0.45s ease both;
}

.path-index {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: var(--hue, var(--accent));
}

.path-copy {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.path-copy span {
  color: var(--muted);
  font-size: 0.92rem;
}

a.path-row:hover {
  transform: translateY(-2px);
}

.unit-head h1 {
  margin-bottom: 0.3rem;
}

.read {
  display: grid;
  grid-template-columns: minmax(200px, 250px) minmax(0, 1fr);
  gap: 1.15rem;
  align-items: start;
}

.rail,
.read-main,
.section,
.prose-part,
.lab,
.quiz,
.panel,
.viz,
.fold,
.card {
  min-width: 0;
}

.rail {
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6.2rem);
  overflow: auto;
  padding: 0.85rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  scrollbar-width: thin;
}

.rail-kicker {
  margin: 0.15rem 0.45rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
}

.rail nav {
  display: grid;
  gap: 0.15rem;
}

.rail a {
  display: block;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  padding: 0.38rem 0.5rem;
  border-radius: 10px;
}

.rail a.is-current {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
}

.rail-summary {
  margin-top: 0.7rem;
  font-weight: 700;
  color: var(--accent) !important;
}

.section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.15rem 1.15rem;
  margin: 0 0 0.9rem;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 5.2rem;
}

.section > h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.18rem;
  margin-top: 0.15rem;
}

.section > h2::before {
  content: "";
  width: 0.4rem;
  height: 1.05rem;
  border-radius: 99px;
  background: var(--accent);
  flex: none;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 0.4rem;
  margin-bottom: 1.5rem;
}

.pager a {
  flex: 1;
  display: grid;
  gap: 0.15rem;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.pager a span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.pager-prev {
  text-align: start;
}

.pager-next {
  text-align: end;
}

.pager a:hover {
  border-color: var(--accent);
}

[data-theme="dark"] .lab,
[data-theme="dark"] .viz,
[data-theme="dark"] .lab-panel,
[data-theme="dark"] .option,
[data-theme="dark"] .tree-toggle,
[data-theme="dark"] .filter-row button,
[data-theme="dark"] .risk-form input {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

[data-theme="dark"] .lab-kicker,
[data-theme="dark"] .viz-kicker {
  color: var(--accent);
}

[data-theme="dark"] .http-wire {
  background: repeating-linear-gradient(-45deg, #1e293b, #1e293b 6px, #0f172a 6px, #0f172a 12px);
}

[data-theme="dark"] .code-line.on {
  color: #ecfeff;
}

[data-theme="dark"] .slot.linked {
  background: rgba(202, 138, 4, 0.28);
  color: #fde68a;
}

a.card,
.portal,
.path-stop,
.theme-toggle,
.pager a {
  transition: transform 0.25s ease, background-color 0.35s ease, color 0.35s ease, border-color 0.25s ease,
    box-shadow 0.25s ease;
}

@media (max-width: 900px) {
  .stage-portals {
    grid-template-columns: 1fr;
  }

  .page {
    padding-inline: 0.85rem;
  }

  .hero {
    padding: 1.35rem 1rem 1.15rem;
  }

  .path-stop {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .path-go {
    grid-column: 2;
    justify-self: start;
  }
}

@media (max-width: 860px) {
  .read {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: static;
    top: auto;
    max-height: none;
    z-index: auto;
    background: var(--glass);
    backdrop-filter: blur(14px);
  }

  .section {
    scroll-margin-top: 14.5rem;
  }

  .rail-kicker,
  .rail-summary {
    display: none;
  }

  .rail nav {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
  }

  .rail a {
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-chevron,
  .rise,
  .rise-2,
  .path-row,
  .path-stop {
    animation: none !important;
  }

  html {
    scroll-behavior: auto;
  }
}

.stage-search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  max-width: 36rem;
  margin: 0.8rem auto 0;
}

.stage-search input,
.drill-setup select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  min-width: 0;
}

.stage-search input {
  flex: 1 1 14rem;
}

.search-group {
  margin: 1.2rem 0;
}

.search-group h2 {
  font-size: 0.95rem;
  margin: 0 0 0.45rem;
}

.search-hit {
  display: grid;
  gap: 0.15rem;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  margin: 0.4rem 0;
}

.search-hit span {
  color: var(--muted);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-hit:hover {
  border-color: var(--accent);
}

.drill-setup-card,
.drill {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.1rem 1.15rem;
  margin: 0.6rem 0 1.2rem;
  box-shadow: var(--shadow-sm);
}

.drill-setup {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  align-items: end;
  margin-top: 0.7rem;
}

.drill-setup label {
  display: grid;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.88rem;
}

.drill-review {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  align-items: center;
}

.drill h1 {
  font-size: 1.25rem;
}

.drill-meta {
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 0.4rem;
}

.exam-prompt {
  white-space: pre-wrap;
}

.ai-bubble {
  display: inline-block;
  margin-inline-end: 0.35rem;
  padding: 0.02rem 0.42rem 0.08rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-decoration: none;
  vertical-align: 0.12em;
  cursor: help;
}

.ai-bubble:hover,
.ai-bubble:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .ai-bubble {
    transition: none;
  }
}

.drill-score {
  font-size: 1.35rem;
  font-weight: 800;
}

.drill-end {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.ghost-btn,
.primary-link {
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
}

.ghost-btn {
  background: transparent;
  color: var(--accent-ink);
  border: 1px solid var(--line);
}

.primary-link {
  background: var(--accent);
  color: #fff;
}

.option:disabled {
  cursor: default;
}

.flash-card {
  width: 100%;
  min-height: 16rem;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.2rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  text-align: center;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}

.flash-card.is-back {
  background: var(--accent-soft);
}

.flash-card strong {
  font-size: 1.35rem;
  line-height: 1.35;
}

.flash-kicker {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent-ink);
}

.flash-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.flash {
  max-width: 40rem;
  margin: 0 auto;
}

.exam-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  position: sticky;
  top: 5.2rem;
  z-index: 3;
  background: var(--glass);
  backdrop-filter: blur(10px);
  padding: 0.4rem 0;
}

.exam-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent-ink);
}

.exam-grid {
  margin: 0.8rem 0 1.4rem;
}

.exam-card h2 {
  font-size: 1.15rem;
}

.option.is-on,
.ghost-btn.is-on {
  outline: 2px solid var(--accent);
  background: var(--accent-soft);
}

.exam-code {
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.45;
  background: var(--lab);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}

.exam-sol {
  margin-top: 0.8rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
}

.verdict {
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
}

.verdict.ok {
  background: var(--ok-bg);
}

.verdict.fix {
  background: var(--accent-soft);
}

.verdict.new {
  background: var(--lab);
}

.layer-stage.has-side,
.cia-stage.has-side {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(12rem, 1.08fr);
  gap: 0.8rem;
  align-items: start;
}

.layer-side {
  display: none;
}

.has-side .layer-side {
  display: block;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 0.7rem 0.75rem 0.85rem;
}

.side-draw[hidden] {
  display: none !important;
}

.side-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent-ink);
}

.side-draw figcaption {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.side-draw.is-in {
  animation: side-in 0.35s ease;
}

@keyframes side-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.layer-row {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  align-items: center;
  gap: 0.55rem;
  text-align: start;
}

.layer-row small {
  display: block;
  margin-top: 0.1rem;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.78rem;
}

.layer-row:hover,
.layer-row:focus-visible,
.threat-node:hover,
.threat-node:focus-visible {
  border-color: var(--accent);
}

.layer-ico {
  width: 3.2rem;
  height: auto;
}

.ink-line,
.uml-frame,
.uml-rule {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.uml-frame {
  fill: var(--surface);
}

.uml-svg text,
.door-inside,
.size-label,
.glyph-ch,
.doc-num {
  font-family: Heebo, "Segoe UI", sans-serif;
  fill: currentColor;
}

.uml-title {
  font-size: 16px;
  font-weight: 700;
}

.uml-mem,
.size-label {
  font-size: 15px;
}

.uml-svg text.mark-pub,
.uml-diagram text.mark-pub {
  fill: #16a34a;
}

.uml-svg text.mark-priv,
.uml-diagram text.mark-priv {
  fill: #e11d48;
}

.uml-svg text.mark-prot,
.uml-diagram text.mark-prot {
  fill: #d97706;
}

.draw-svg.wide {
  width: min(100%, 42rem);
}

.uml-diagram text,
.dfd-draw text {
  font-family: Heebo, "Segoe UI", sans-serif;
  fill: currentColor;
}

.uml-name {
  font-size: 15px;
  font-weight: 700;
}

.uml-stereo {
  font-size: 12px;
  font-style: italic;
}

.uml-mem {
  font-size: 13px;
}

.uml-mult {
  font-size: 12px;
  font-weight: 700;
}

.uml-diagram .cls rect,
.uml-diagram .rel polygon {
  fill: var(--card);
  stroke: currentColor;
  stroke-width: 1.6;
}

.uml-diagram .rel-comp polygon {
  fill: currentColor;
}

.uml-diagram .uml-rule,
.uml-diagram .rel path,
.uc-link,
.actor path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.uml-diagram .rel-real path {
  stroke-dasharray: 6 4;
}

.usecase-oval,
.sys-bound,
.actor circle {
  fill: var(--card);
  stroke: currentColor;
  stroke-width: 1.8;
}

.sys-bound {
  fill: none;
}

.uml-diagram.is-on .cls,
.uml-diagram.is-on .rel,
.uml-diagram.is-on .uc-link {
  opacity: 0.28;
}

.uml-diagram.is-box .cls-ride,
.uml-diagram.is-gen .rel-gen,
.uml-diagram.is-gen .cls-user,
.uml-diagram.is-gen .cls-pass,
.uml-diagram.is-comp .rel-comp,
.uml-diagram.is-comp .rel-many,
.uml-diagram.is-comp .cls-ride,
.uml-diagram.is-comp .cls-route,
.uml-diagram.is-comp .cls-pass,
.uml-diagram.is-face .rel-real,
.uml-diagram.is-face .cls-face,
.uml-diagram.is-face .cls-ride,
.uml-diagram.is-pass .a-pass,
.uml-diagram.is-drive .a-drive {
  opacity: 1;
}

.uml-diagram.is-box .cls-ride rect,
.uml-diagram.is-gen .rel-gen path,
.uml-diagram.is-gen .rel-gen polygon,
.uml-diagram.is-comp .rel-comp path,
.uml-diagram.is-comp .rel-comp polygon,
.uml-diagram.is-comp .rel-many path,
.uml-diagram.is-face .rel-real path,
.uml-diagram.is-face .rel-real polygon,
.uml-diagram.is-pass .a-pass,
.uml-diagram.is-drive .a-drive,
.uml-diagram.is-edge .sys-bound,
.uml-diagram.is-edge .actor circle,
.uml-diagram.is-edge .actor path {
  stroke: var(--accent);
  stroke-width: 2.6;
}

.dfd-entity,
.dfd-proc {
  fill: var(--card);
  stroke: currentColor;
  stroke-width: 1.8;
}

.dfd-flow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.dfd-flow polygon {
  fill: currentColor;
}

.trust-fence {
  fill: none;
  stroke: #f59e0b;
  stroke-width: 2;
  stroke-dasharray: 5 5;
}

.dfd-draw.is-cross .cross path {
  stroke: #fb7185;
  stroke-width: 2.6;
}

.dfd-draw.is-cross .cross polygon {
  fill: #fb7185;
}

.many-side rect,
.hub {
  fill: var(--card);
  stroke: currentColor;
  stroke-width: 1.8;
}

.many-side path,
.chan {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.wake {
  fill: #38bdf8;
  opacity: 0;
}

.reactor-draw.is-many .one-side,
.reactor-draw.is-one .many-side {
  opacity: 0.3;
}

.reactor-draw.is-many .many-side rect,
.reactor-draw.is-one .hub {
  stroke: var(--accent);
  stroke-width: 2.6;
}

.reactor-draw.is-one .wake {
  opacity: 1;
}

.mark-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  font-size: 0.84rem;
}

.mark-legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cell {
  fill: #38bdf8;
}

.extra-byte rect {
  fill: #fb7185;
}

.extra-byte {
  transform: translateX(-18px);
  transform-box: fill-box;
  transform-origin: center;
}

.side-draw.is-in .extra-byte {
  animation: byte-stop 1.15s ease;
}

@keyframes byte-stop {
  0% {
    transform: translateX(46px);
  }
  62% {
    transform: translateX(-18px);
  }
  78% {
    transform: translateX(-4px);
  }
  100% {
    transform: translateX(-18px);
  }
}

.gate-line {
  fill: none;
  stroke: #0f766e;
  stroke-width: 4;
  stroke-linecap: round;
}

.paper {
  fill: #f8fafc;
  stroke: #334155;
  stroke-width: 2;
}

.flap {
  fill: #e7e5e4;
  stroke: #334155;
  stroke-width: 2;
}

.seal circle,
.small-seal {
  fill: #e11d48;
}

.seal path {
  fill: none;
  stroke: #fff;
  stroke-width: 2;
}

.seal {
  transform: scale(1);
  transform-box: fill-box;
  transform-origin: center;
}

.side-draw.is-in .seal {
  animation: seal-in 0.5s ease;
}

@keyframes seal-in {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

.doc-num {
  font-size: 22px;
  font-weight: 800;
}

.pen {
  fill: #f59e0b;
  transform: translateX(22px);
}

.side-draw.is-in .pen {
  animation: pen-stop 1.1s ease;
}

@keyframes pen-stop {
  0% {
    transform: translateX(40px);
  }
  60% {
    transform: translateX(0);
  }
  78% {
    transform: translateX(14px);
  }
  100% {
    transform: translateX(10px);
  }
}

.lock-body {
  fill: #facc15;
  stroke: #a16207;
}

.shackle {
  fill: none;
  stroke: #facc15;
  stroke-width: 2.5;
  transform: translateY(-7px);
}

.side-draw.is-in .shackle {
  transform: translateY(0);
  transition: transform 0.45s ease;
}

.ops-check {
  fill: none;
  stroke: #16a34a;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 28;
  stroke-dashoffset: 0;
}

.side-draw.is-in .ops-check {
  animation: draw-check 0.55s ease;
}

@keyframes draw-check {
  from {
    stroke-dashoffset: 28;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.eye-shape,
.eye-ico {
  fill: #f8fafc;
  stroke: #334155;
  stroke-width: 2;
}

.pupil {
  fill: #0f172a;
}

.side-draw.is-in .pupil {
  animation: look 2.2s ease-in-out infinite;
}

@keyframes look {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(8px);
  }
}

.avail-frame {
  position: relative;
}

.door-leaf {
  fill: #d6d3d1;
  stroke: #44403c;
  stroke-width: 2;
}

.knob {
  fill: #facc15;
}

.queue-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  opacity: 0.45;
}

.q {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.q circle {
  fill: #38bdf8;
  stroke: none;
}

.full-sign {
  position: absolute;
  top: 12%;
  inset-inline-start: 10%;
  background: #fb7185;
  color: #1c1917;
  font-weight: 800;
  font-size: 0.85rem;
  border-radius: 6px;
  padding: 0.05rem 0.4rem;
  opacity: 1;
}

.side-draw.is-in .q {
  animation: pop-in 0.35s ease both;
}

.side-draw.is-in .q2 {
  animation-delay: 0.12s;
}
.side-draw.is-in .q3 {
  animation-delay: 0.24s;
}
.side-draw.is-in .q4 {
  animation-delay: 0.4s;
}
.side-draw.is-in .full-sign {
  animation: fade-in 0.3s ease 0.55s both;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.trust-draw .medallion circle {
  fill: #0f766e;
}

.trust-draw .medallion text {
  fill: #fff;
  font-size: 20px;
  font-weight: 800;
  font-family: Heebo, "Segoe UI", sans-serif;
}

.chain-link {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 4;
  stroke-linecap: round;
}

.fence {
  fill: none;
  stroke: #f59e0b;
  stroke-width: 2;
  stroke-dasharray: 4 5;
}

.chain-crack {
  fill: none;
  stroke: #fb7185;
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0;
}

.trust-draw.play .chain-crack {
  opacity: 1;
}

.pulse {
  fill: #38bdf8;
  opacity: 0;
}

.trust-draw.play .pulse {
  opacity: 1;
}

.threat-draw {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
}

.threat-svg .twires {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.threat-svg .t-node rect,
.threat-svg .t-node circle {
  fill: var(--card);
  stroke: currentColor;
  stroke-width: 2;
  cursor: pointer;
}

.threat-svg .t-node text {
  font-family: Heebo, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 700;
  fill: currentColor;
  pointer-events: none;
}

.threat-svg .t-node.on rect,
.threat-svg .t-node.on circle,
.threat-svg .t-node:hover rect,
.threat-svg .t-node:hover circle,
.threat-svg .t-node:focus-visible rect,
.threat-svg .t-node:focus-visible circle {
  stroke: var(--accent);
}

.threat-wires {
  width: 100%;
  height: 2rem;
  display: block;
}

.threat-wires path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  opacity: 0.55;
}

.threat-kids {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  width: 100%;
}

.threat-node {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 2px solid currentColor;
  cursor: pointer;
  font-weight: 700;
}

.threat-node.is-root,
.threat-node.is-box {
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
}

.threat-node.is-round {
  border-radius: 999px;
  width: min(6.2rem, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 0.35rem;
  font-size: 0.82rem;
  text-align: center;
}

.threat-node.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.swatch {
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid currentColor;
  display: inline-block;
}

.swatch.round {
  border-radius: 999px;
}

.swatch.box {
  border-radius: 2px;
}

.door-svg {
  width: min(100%, 7rem);
  height: auto;
  display: block;
  margin: 0 auto;
}

.door-panel rect {
  fill: #d6d3d1;
  stroke: #44403c;
  stroke-width: 2;
}

.door-panel {
  transform-box: fill-box;
  transform-origin: left center;
  transition: transform 0.45s ease;
}

.door.on .door-panel {
  transform: scaleX(0.14);
}

.door-inside {
  font-size: 28px;
  font-weight: 800;
  opacity: 0;
}

.door.on .door-inside {
  opacity: 1;
  transition: opacity 0.25s ease 0.1s;
}

.pipe {
  fill: none;
  stroke: currentColor;
  stroke-width: 8;
  stroke-linecap: round;
}

.glyph circle {
  fill: #fb7185;
}

.glyph-ch {
  font-size: 12px;
  font-weight: 800;
  fill: #1c1917;
}

.glyph {
  transform: translateY(32px);
  transform-box: fill-box;
  transform-origin: center;
}

.sql-pipe.on .g1 {
  animation: glyph-drop 0.5s ease;
}

.sql-pipe.on .g2 {
  animation: glyph-drop 0.5s ease 0.12s;
}

@keyframes glyph-drop {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(32px);
  }
}

.crate {
  fill: #38bdf8;
  stroke: #0f766e;
  stroke-width: 2;
}

.shaft {
  fill: #0f172a;
}

.cab {
  fill: #facc15;
}

.foundation {
  fill: #78716c;
}

@media (max-width: 720px) {
  .layer-stage.has-side,
  .cia-stage.has-side {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .exam-bar {
    position: static;
  }

  .water,
  .puddle,
  .drop,
  .spill-stream,
  .rim-water,
  .stack-water,
  .bird,
  .lock,
  .mail.echo,
  .extra-byte,
  .shackle,
  .ops-check,
  .pen,
  .seal,
  .pupil,
  .q,
  .full-sign,
  .door-panel,
  .door-inside,
  .glyph,
  .pulse,
  .side-draw,
  .wake {
    transition: none;
    animation: none;
  }

  .theme-toggle:hover,
  .wordmark.is-float:hover,
  .admin-panel,
  .me-panel {
    transform: none;
    animation: none;
  }
}

.stage-tools {
  position: fixed;
  top: 1rem;
  inset-inline-start: 1rem;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.stage-tools .theme-toggle {
  position: static;
}

.account-slot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.account-btn,
.account-link,
.bookmark-btn,
.lab-done {
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  background: var(--card);
  color: var(--accent-ink);
  border: 1px solid var(--line);
}

.account-btn:hover,
.account-link:hover,
.bookmark-btn:hover,
.lab-done:hover,
.admin-tabs a:hover,
.admin-item:hover {
  border-color: var(--accent);
}

.account-btn:focus-visible,
.account-link:focus-visible,
.bookmark-btn:focus-visible,
.lab-done:focus-visible,
.admin-tabs a:focus-visible,
.admin-item:focus-visible,
.admin-form button:focus-visible,
.admin-filters input:focus-visible,
.admin-filters select:focus-visible,
.admin-form input:focus-visible,
.admin-form textarea:focus-visible,
.admin-form select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.account-btn:disabled,
.lab-done:disabled,
.admin-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

.bookmark-btn.is-on,
.lab-done.is-on,
.admin-tabs a.is-on {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.prose-part-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.prose-part-head h3 {
  margin: 0;
}

.lab-done-row {
  margin: 0.75rem 0 0;
}

.save-note {
  color: var(--muted);
  margin: 0.4rem 0;
}

.save-note.is-bad {
  color: var(--bad);
}

.me-panel,
.admin-panel {
  animation: panel-in 0.28s ease;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.me-list {
  padding-inline-start: 1.2rem;
}

.me-list li {
  margin: 0.35rem 0;
}

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.admin-tabs a {
  text-decoration: none;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  background: var(--card);
}

.admin-split {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.admin-filters,
.admin-form,
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
}

.admin-form {
  flex-direction: column;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
}

.admin-form label,
.admin-form .rich-label,
.admin-filters label,
.admin-users label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 700;
  color: var(--muted);
}

.admin-form input,
.admin-form textarea,
.admin-form select,
.admin-filters input,
.admin-filters select,
.admin-users input {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 70vh;
  overflow: auto;
  margin-top: 0.6rem;
}

.admin-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
}

.admin-item span {
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-preview {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.admin-user {
  margin: 0.7rem 0;
}

.admin-user form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}

.check-line {
  flex-direction: row !important;
  align-items: center;
}

.site-banners {
  position: relative;
  z-index: 45;
}

.site-banner {
  margin: 0;
  padding: 0.55rem 1.25rem;
  text-align: center;
  line-height: 1.45;
}

.banner-sm { font-size: 0.875rem; }
.banner-md { font-size: 1rem; }
.banner-lg { font-size: 1.25rem; }
.banner-xl { font-size: 1.5rem; }

.site-banner .is-bold { font-weight: 800; }
.site-banner .is-italic { font-style: italic; }
.site-banner .is-under { text-decoration: underline; }

.banner-tools {
  align-items: end;
}

.banner-editor {
  min-height: 4.5rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.5;
}

.banner-editor:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.banner-scope {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 0;
  padding: 0.7rem 0.9rem 0.9rem;
}

.banner-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin-top: 0.4rem;
}

.rich-editor {
  min-height: 12rem;
  max-height: 28rem;
  overflow: auto;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.65;
}

.rich-editor:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rich-editor .panel {
  margin: 0.6rem 0;
}

.box-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.box-head h1,
.box-head h2,
.box-head h3,
.box-head p {
  margin-top: 0;
}

.prose-part-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.edit-link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--muted);
  text-decoration: none;
}

.edit-link svg {
  width: 1rem;
  height: 1rem;
}

.edit-link:hover,
.edit-link:focus-visible {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.box-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 0 auto;
}

.share-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}

.share-link svg {
  width: 1rem;
  height: 1rem;
}

.share-link:hover,
.share-link:focus-visible,
.share-link.is-copied {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.part-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.8rem 0 0.2rem;
}

.part-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.part-tab span {
  color: var(--accent-ink);
}

.part-tab.is-on,
.part-tab:hover,
.part-tab:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.part-head {
  margin-top: 0.8rem;
}

.exam-card-tools {
  position: absolute;
  top: 0.55rem;
  inset-inline-start: 0.55rem;
  z-index: 2;
}
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.editable-wrap {
  position: relative;
}

.editable-wrap > .edit-link {
  position: absolute;
  top: 0.55rem;
  inset-inline-start: 0.55rem;
  z-index: 2;
}

.site-footer {
  max-width: 1180px;
  margin: 2.5rem auto 0;
  padding: 1.5rem 1.25rem 5rem;
  border-top: 1px solid var(--line);
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
}

.footer-link svg {
  width: 1.05rem;
  height: 1.05rem;
}

.footer-link:hover,
.footer-link:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.footer-disclaimer {
  color: var(--muted);
  font-size: 0.92rem;
}

.footer-disclaimer p {
  margin: 0.35rem auto;
  max-width: 46rem;
}

.footer-credit {
  margin-top: 0.8rem;
}

.admin-filters .check-line {
  align-self: end;
  margin-bottom: 0.35rem;
}

@media (max-width: 800px) {
  .admin-split {
    grid-template-columns: 1fr;
  }

  .admin-list {
    max-height: 40vh;
  }
}

.tool-dock {
  position: fixed;
  z-index: 45;
  inset-inline-end: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

.tool-fab {
  width: 3rem;
  height: 3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tool-fab svg {
  width: 1.35rem;
  height: 1.35rem;
}

.tool-fab:hover,
.tool-fab:focus-visible,
.tool-item:hover,
.tool-item:focus-visible,
.print-entry:hover,
.print-entry:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.tool-panel {
  width: min(16rem, calc(100vw - 2rem));
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tool-kicker {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.tool-item,
.print-entry {
  font: inherit;
  font-weight: 700;
  text-align: start;
  text-decoration: none;
  color: var(--accent-ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}

.stage-print {
  text-align: center;
  margin: 0.8rem 0 0;
}

.print-entry {
  display: inline-flex;
}

.print-actions,
.print-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.print-options {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}

.print-tree,
.print-kids {
  list-style: none;
  padding-inline-start: 0;
  margin: 0.4rem 0;
}

.print-kids {
  padding-inline-start: 1.2rem;
}

.print-row {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  padding: 0.2rem 0;
}

.print-sheet-host[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .tool-panel {
    animation: none;
  }
}

@media print {
  .tool-dock,
  .topbar,
  .stage-tools,
  .wordmark,
  .site-footer,
  .edit-link,
  .toc-fab,
  .ai-fab,
  .ai-tooltip,
  .ai-modal-overlay,
  .rail,
  .pager,
  .back-row,
  .lab-actions,
  .print-setup,
  .hero-pill,
  .stage-search,
  .stage-print,
  button,
  .ghost-btn,
  .primary {
    display: none !important;
  }

  .viz [hidden],
  .side-draw,
  .print-static .side-draw {
    display: block !important;
  }

  .print-static .lab-actions,
  .print-sheet button,
  .print-sheet .viz button,
  .viz button {
    display: none !important;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  body.is-range-print .page > :not(.print-sheet-host),
  body.is-range-print .site-banners,
  body.is-range-print .site-footer {
    display: none !important;
  }

  body.is-range-print .print-sheet-host {
    display: block !important;
  }

  body,
  .page,
  .print-sheet,
  .lab,
  .lab-panel,
  .card,
  .prose,
  .study-text {
    color: #111 !important;
    background: #fff !important;
  }

  pre,
  .code,
  pre.code,
  pre.code code,
  .code code {
    background: #1c1917 !important;
    color: #f5f5f4 !important;
    white-space: pre-wrap !important;
    overflow: visible !important;
  }

  h2,
  h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  .print-quiz,
  pre,
  .lab-code-panel,
  .print-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-block {
    margin: 0.35rem 0;
  }

  .print-card {
    margin: 0.35rem 0 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #ddd;
  }

  .print-card h4,
  .print-card .kind {
    margin: 0.1rem 0 0.25rem;
    color: #111 !important;
  }

  .lab {
    margin: 0.6rem 0;
    padding: 0.55rem 0.65rem;
    box-shadow: none;
  }

  .lab-kicker,
  .lab .feedback,
  .lab-done-row,
  .mem-col,
  .mem-cols,
  .copy-cols,
  .lab-panel:has(.stack-viz),
  .lab-panel:has(.wrap-meter),
  .lab-panel:has(.osi-stack) {
    display: none !important;
  }

  .lab-with-code,
  .layer-stage.has-side,
  .cia-stage.has-side {
    display: block !important;
  }

  .tree-children,
  .tree-children[hidden] {
    display: block !important;
  }

  .tree-toggle {
    display: block !important;
    background: none !important;
    border: 0 !important;
    padding: 0.15rem 0 !important;
    color: #111 !important;
    font: inherit;
    font-weight: 700;
    text-align: start;
  }
}
/* AI Assistant Styles */
.ai-fab {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 10px 18px;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  z-index: 38;
  font-weight: bold;
  color: #0f172a;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.ai-fab:hover {
  background: rgba(255, 255, 255, 0.85);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.ai-tooltip {
  display: none;
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  padding: 6px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  z-index: 70;
  gap: 6px;
}

.ai-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 7px;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
}

.ai-tooltip button {
  background: rgba(241, 245, 249, 0.85);
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  transition: all 0.2s;
}

.ai-tooltip button:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: translateY(-1px);
}

.ai-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 80;
  justify-content: center;
  align-items: center;
}

.ai-modal-content {
  background: rgba(255, 255, 255, 0.98);
  padding: 24px;
  border-radius: 16px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  text-align: right;
  border: 1px solid rgba(255,255,255,0.8);
}

.ai-modal-content h3 { 
  margin-top: 0; 
  color: #0f172a;
  font-size: 1.25rem;
  margin-bottom: 10px;
}

.ai-modal-content p {
  color: #475569;
  margin-bottom: 15px;
  font-size: 0.95rem;
}

.ai-modal-content textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  resize: vertical;
  font-family: inherit;
  font-size: 0.95rem;
  color: #334155;
  background: #f8fafc;
}

.ai-modal-content textarea:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.ai-modal-content button {
  padding: 10px 20px;
  margin-inline-end: 10px;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  background: #e2e8f0;
  color: #475569;
  font-weight: bold;
  transition: all 0.2s;
}

.ai-modal-content button:hover {
  background: #cbd5e1;
  color: #0f172a;
}

.ai-modal-content button.primary {
  background: #0284c7;
  color: white;
}

.ai-modal-content button.primary:hover {
  background: #0369a1;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

/* AI Assistant Dark Mode */
[data-theme="dark"] .ai-fab {
  background: rgba(30, 41, 59, 0.75);
  border-color: rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .ai-fab:hover {
  background: rgba(51, 65, 85, 0.85);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .ai-tooltip {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .ai-tooltip::after {
  border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent;
}

[data-theme="dark"] .ai-tooltip button {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

[data-theme="dark"] .ai-tooltip button:hover {
  background: #334155;
  color: #ffffff;
}

[data-theme="dark"] .ai-modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .ai-modal-content {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}

[data-theme="dark"] .ai-modal-content h3 {
  color: var(--ink);
}

[data-theme="dark"] .ai-modal-content p {
  color: var(--muted);
}

[data-theme="dark"] .ai-modal-content textarea {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

[data-theme="dark"] .ai-modal-content button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
}

[data-theme="dark"] .ai-modal-content button:hover {
  background: #334155;
  color: var(--ink);
}


/* Tools Menu Styles */
@media print {
    .tools-fab-container { display: none !important; }
}
.tools-fab-container {
    position: fixed;
    bottom: 25px;
    left: 25px;
    z-index: 38;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}
.tools-menu {
    display: none;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 8px;
    gap: 5px;
    transform-origin: bottom left;
    animation: menuFadeIn 0.2s ease-out;
}
@keyframes menuFadeIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.tools-menu button {
    background: transparent;
    border: none;
    padding: 10px 15px;
    text-align: right;
    width: 100%;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.tools-menu button:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.tools-fab {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    font-weight: bold;
    color: #0f172a;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tools-fab:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .tools-menu, [data-theme="dark"] .tools-fab {
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}
[data-theme="dark"] .tools-menu button {
    color: #e2e8f0;
}
[data-theme="dark"] .tools-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 860px) {
  .exam-bar {
    position: static;
  }
}

@media (max-width: 640px) {
  .tool-dock {
    top: auto;
    bottom: 1rem;
    transform: none;
  }
}
