/* ===========================================================
   e2tree — design system
   Scholarly editorial palette, distinct from TALL
   =========================================================== */

:root {
  /* Slate / indigo — e2tree signature */
  --e2: #4a6fa5;
  --e2-dark: #2d4e84;
  --e2-deep: #0d1f40;
  --e2-soft: #dce8f7;
  --e2-tint: #f0f5fc;

  /* Warm amber accent */
  --amber: #c47d2e;
  --amber-dark: #9b5e18;
  --amber-soft: #fdf0dc;
  --amber-tint: #fef8ee;

  /* Editorial neutrals */
  --ink: #0e1520;
  --ink-soft: #2c3545;
  --ink-muted: #5c6478;
  --rule: #d4d8e2;
  --rule-soft: #e8ebf2;

  /* Paper — cooler tone than TALL */
  --paper: #f8f9fc;
  --paper-warm: #f2f4f9;
  --paper-deep: #e4e8f0;
  --surface: #ffffff;

  /* Type */
  --font-display: "Fraunces", "Cormorant Garamond", Georgia, serif;
  --font-body: "Instrument Sans", "Figtree", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ===========================================================
   RESET + BASE
   =========================================================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: .25;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.05  0 0 0 0 0.08  0 0 0 0 0.15  0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

main, section, nav, footer, header { position: relative; z-index: 2; }

img { max-width: 100%; height: auto; display: block; }

a { color: var(--e2-dark); text-decoration: none; transition: color .2s var(--ease); }
a:hover { color: var(--e2-deep); }

/* ===========================================================
   TYPOGRAPHY
   =========================================================== */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.015em;
}

h1 { font-weight: 400; font-variation-settings: "opsz" 144, "SOFT" 30; line-height: 1.02; }
h2 { font-weight: 500; font-variation-settings: "opsz" 96, "SOFT" 40; line-height: 1.08; }
h3 { font-weight: 600; font-variation-settings: "opsz" 48, "SOFT" 50; line-height: 1.2; }
h4 { font-weight: 600; font-variation-settings: "opsz" 14, "SOFT" 50; line-height: 1.3; }

.display-xl {
  font-size: clamp(2.8rem, 6vw, 6rem);
  font-weight: 400;
  line-height: .95;
  letter-spacing: -0.035em;
}
.display-lg { font-size: clamp(2.2rem, 4.5vw, 4rem); line-height: 1.05; letter-spacing: -0.03em; }
.display-md { font-size: clamp(1.8rem, 3vw, 2.8rem); line-height: 1.1; letter-spacing: -0.02em; }
.display-sm { font-size: clamp(1.4rem, 2vw, 1.9rem); line-height: 1.2; }

.italic-display {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--font-body);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--e2-dark);
}
.kicker::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--e2-dark);
}

.eyebrow {
  display: block;
  font-family: var(--font-body);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: .5rem;
}

.lede {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  font-weight: 350;
  font-variation-settings: "opsz" 30, "SOFT" 50;
  line-height: 1.5;
  color: var(--ink-soft);
  letter-spacing: -0.005em;
}

p { margin: 0 0 1rem; color: var(--ink-soft); }
p.muted { color: var(--ink-muted); }
.small { font-size: .92rem; color: var(--ink-muted); }

.drop-cap::first-letter {
  font-family: var(--font-display);
  font-size: 4.5em;
  float: left;
  line-height: .85;
  padding: .18em .12em 0 0;
  color: var(--e2-deep);
  font-weight: 500;
  font-variation-settings: "opsz" 144, "SOFT" 30;
}

/* ===========================================================
   LAYOUT
   =========================================================== */
.container { max-width: 1240px; margin: 0 auto; padding: 0 clamp(1.25rem, 3vw, 2.25rem); }
.container-narrow { max-width: 860px; margin: 0 auto; padding: 0 clamp(1.25rem, 3vw, 2.25rem); }
.container-wide { max-width: 1480px; margin: 0 auto; padding: 0 clamp(1.25rem, 3vw, 2.25rem); }

.grid { display: grid; gap: clamp(1.5rem, 3vw, 2.5rem); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }

@media (max-width: 960px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-12 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid-12 { grid-template-columns: 1fr; }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; } .gap-8 { gap: 2rem; }

.text-center { text-align: center; }

.mt-0 { margin-top: 0; } .mt-2 { margin-top: .5rem; } .mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; } .mt-8 { margin-top: 2rem; } .mt-12 { margin-top: 3rem; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: .5rem; } .mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; } .mb-8 { margin-bottom: 2rem; } .mb-12 { margin-bottom: 3rem; }

section { padding: clamp(4rem, 8vw, 7rem) 0; position: relative; }
.section-tight { padding: clamp(2.5rem, 5vw, 4rem) 0; }

/* ===========================================================
   NAVBAR
   =========================================================== */
.site-nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: rgba(248, 249, 252, 0.72);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: background .35s var(--ease), border-color .35s var(--ease), box-shadow .35s var(--ease);
}
.site-nav.scrolled {
  background: rgba(248, 249, 252, 0.94);
  border-bottom-color: var(--rule);
  box-shadow: 0 8px 40px -30px rgba(13, 31, 64, 0.3);
}
.nav-rule { display: none; }
.nav-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: .9rem clamp(1.25rem, 3vw, 2.25rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink);
}
.nav-brand img { height: 34px; width: auto; }
.nav-brand .wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--e2-deep);
}
.nav-brand .wordmark sup {
  font-size: .52rem;
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: .15em;
  color: var(--e2-dark);
  background: var(--e2-soft);
  padding: .18rem .4rem;
  border-radius: 999px;
  margin-left: .4rem;
  vertical-align: middle;
}
.nav-links { display: flex; align-items: center; gap: 2rem; }
.nav-links a {
  color: var(--ink-soft);
  font-size: .95rem;
  font-weight: 500;
  position: relative;
  padding: .3rem 0;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -2px;
  height: 1px;
  background: var(--e2-dark);
  transition: right .3s var(--ease);
}
.nav-links a:hover { color: var(--e2-deep); }
.nav-links a:hover::after,
.nav-links a.active::after { right: 0; }
.nav-links a.active { color: var(--e2-deep); }

.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .9rem;
  font-weight: 600;
  padding: .55rem 1.1rem;
  border-radius: 999px;
  background: var(--e2-deep);
  color: #fff;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.nav-cta:hover { background: var(--e2-dark); color: #fff; transform: translateY(-1px); }
.nav-cta svg { width: 14px; height: 14px; }

.nav-burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-soft);
  padding: .4rem;
}

.mobile-menu {
  padding: 1rem clamp(1.25rem, 3vw, 2.25rem);
  background: var(--paper);
  border-top: 1px solid var(--rule-soft);
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.mobile-menu a {
  padding: .6rem 0;
  font-weight: 500;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule-soft);
  font-size: 1rem;
}

@media (max-width: 820px) {
  .nav-links { display: none; }
  .nav-burger { display: flex; }
  .nav-cta { display: none; }
}

/* ===========================================================
   HERO
   =========================================================== */
.hero {
  padding-top: clamp(6rem, 12vw, 10rem);
  padding-bottom: clamp(4rem, 8vw, 6rem);
}

/* ===========================================================
   BUTTONS
   =========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1.6rem;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  transition: all .2s var(--ease);
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--e2-deep);
  color: #fff;
}
.btn-primary:hover { background: var(--e2-dark); color: #fff; transform: translateY(-2px); box-shadow: 0 8px 20px -8px rgba(13,31,64,.4); }

.btn-amber {
  background: var(--amber);
  color: #fff;
}
.btn-amber:hover { background: var(--amber-dark); color: #fff; transform: translateY(-2px); box-shadow: 0 8px 20px -8px rgba(196,125,46,.35); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--rule);
}
.btn-ghost:hover { border-color: var(--e2-dark); color: var(--e2-deep); transform: translateY(-1px); }

/* ===========================================================
   PILLS / TAGS
   =========================================================== */
.pill {
  display: inline-block;
  padding: .3rem .75rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  background: var(--e2-soft);
  color: var(--e2-deep);
  border: 1px solid rgba(74, 111, 165, 0.2);
}
.pill-amber {
  background: var(--amber-soft);
  color: var(--amber-dark);
  border-color: rgba(196, 125, 46, 0.25);
}

/* ===========================================================
   CARDS
   =========================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: 12px;
  padding: 1.75rem;
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}
.card:hover { box-shadow: 0 12px 40px -20px rgba(13,31,64,.12); transform: translateY(-2px); }

.card-outline {
  background: var(--surface);
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  padding: 1.5rem;
}

/* ===========================================================
   HERO STATS
   =========================================================== */
.hero-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 14px;
  overflow: hidden;
}
.stat {
  background: var(--surface);
  padding: 1.5rem 1.75rem;
}
.stat:nth-child(1) { border-radius: 13px 0 0 0; }
.stat:nth-child(2) { border-radius: 0 13px 0 0; }
.stat:nth-child(3) { border-radius: 0 0 0 13px; }
.stat:nth-child(4) { border-radius: 0 0 13px 0; }
.stat-num {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 500;
  line-height: 1;
  color: var(--e2-deep);
  font-variation-settings: "opsz" 80, "SOFT" 20;
  letter-spacing: -0.04em;
}
.stat-label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: .35rem;
}
.stat-sub {
  font-size: .78rem;
  color: var(--ink-muted);
  margin-top: .2rem;
}

/* ===========================================================
   METHOD MODULES
   =========================================================== */
.module {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule-soft);
  align-items: flex-start;
}
.module:last-child { border-bottom: 1px solid var(--rule-soft); }
.module-num {
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 600;
  color: var(--e2-dark);
  background: var(--e2-soft);
  padding: .3rem .55rem;
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: .15rem;
  letter-spacing: .05em;
}
.module-title {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 .35rem;
}
.module-desc {
  font-size: .92rem;
  color: var(--ink-soft);
  margin: 0 0 .6rem;
}
.module-tags { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ===========================================================
   FIGURES
   =========================================================== */
.figure {
  margin: 0;
  border: 1px solid var(--rule-soft);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.figure img { cursor: zoom-in; transition: transform .4s var(--ease); }
.figure img:hover { transform: scale(1.01); }
.figcaption {
  padding: .9rem 1.25rem;
  font-size: .82rem;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule-soft);
  line-height: 1.55;
}
.fig-frame {
  border: 1px solid var(--rule-soft);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

/* ===========================================================
   CODE BLOCK
   =========================================================== */
.code-block {
  background: var(--e2-deep);
  color: #c9d8f4;
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.7;
  overflow-x: auto;
  position: relative;
  white-space: pre;
}
.code-block .comment { color: #5f7a9e; }
.code-block .fn { color: #7cc5e8; }
.code-block .str { color: #a8d4a0; }
.code-block .num { color: #f0c484; }
.code-block .kw { color: #d4a8e0; }
.code-block .copy-btn {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #8ca8d0;
  font-family: var(--font-body);
  font-size: .75rem;
  padding: .3rem .65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background .2s;
}
.code-block .copy-btn:hover { background: rgba(255,255,255,.15); color: #c9d8f4; }

/* ===========================================================
   TIMELINE / WORKFLOW STEPS
   =========================================================== */
.step-list { list-style: none; padding: 0; margin: 0; }
.step-item {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule-soft);
  align-items: flex-start;
}
.step-item:last-child { border-bottom: 1px solid var(--rule-soft); }
.step-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--e2-deep);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: .1rem;
}
.step-title {
  font-weight: 700;
  color: var(--ink);
  font-size: 1rem;
  margin-bottom: .3rem;
}
.step-desc { font-size: .93rem; color: var(--ink-soft); margin: 0; }

/* ===========================================================
   PERSON CARDS
   =========================================================== */
.person {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: 12px;
}
.person-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--rule);
}
.person-avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--e2-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--e2-deep);
  flex-shrink: 0;
  border: 2px solid var(--rule);
}
.person-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "opsz" 30, "SOFT" 50;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: .25rem;
}
.person-role {
  font-size: .85rem;
  color: var(--ink-muted);
  line-height: 1.45;
}
.person-links {
  display: flex;
  gap: .5rem;
  margin-top: .6rem;
}
.person-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--paper-warm);
  border: 1px solid var(--rule-soft);
  color: var(--ink-muted);
  transition: all .2s;
}
.person-links a:hover { background: var(--e2-soft); color: var(--e2-deep); border-color: var(--e2-soft); }
.person-links svg { width: 14px; height: 14px; }

/* ===========================================================
   CITATION BOX
   =========================================================== */
.citation {
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--e2-dark);
  border-radius: 0 8px 8px 0;
  padding: 1.4rem 1.6rem;
  font-size: .9rem;
  color: var(--ink-soft);
  line-height: 1.7;
}
.citation strong { color: var(--ink); }
.citation a { color: var(--e2-dark); text-decoration: underline; text-decoration-color: rgba(74,111,165,.35); }

/* ===========================================================
   INTERACTIVE TREE VISUALIZER
   =========================================================== */
.tree-viz-wrap {
  background: var(--e2-deep);
  border-radius: 16px;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  overflow: hidden;
  position: relative;
}
.tree-viz-label {
  font-family: var(--font-body);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(201,216,244,.5);
  margin-bottom: 1rem;
}
.tree-viz {
  width: 100%;
  display: block;
}

.forest-container {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  overflow: hidden;
}
.mini-tree {
  flex: 1;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .4s, transform .4s;
}
.mini-tree.show { opacity: 1; transform: none; }

/* Arrow between forest and e2tree */
.distill-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 1rem 0;
  color: rgba(201,216,244,.7);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
}
.distill-arrow svg { width: 28px; height: 28px; animation: pulse-arrow 2s ease-in-out infinite; }

@keyframes pulse-arrow {
  0%, 100% { transform: translateX(0); opacity: .7; }
  50% { transform: translateX(4px); opacity: 1; }
}

/* The large e2tree SVG */
.e2tree-svg-wrap {
  opacity: 0;
  transform: scale(0.97);
  transition: opacity .6s .2s var(--ease), transform .6s .2s var(--ease);
}
.e2tree-svg-wrap.show { opacity: 1; transform: scale(1); }

/* node & edge styles inside SVG */
.tree-edge { stroke: rgba(201,216,244,.25); stroke-width: 1.5; fill: none; }
.tree-node-inner { stroke: rgba(201,216,244,.4); stroke-width: 1.2; fill: rgba(74,111,165,.35); }
.tree-node-leaf { fill: rgba(196,125,46,.45); stroke: rgba(240,180,100,.5); stroke-width: 1.2; }
.tree-node-text { fill: #c9d8f4; font-family: "JetBrains Mono", monospace; font-size: 9px; text-anchor: middle; dominant-baseline: middle; }
.tree-node-text-sm { font-size: 7.5px; }

/* highlight on hover */
.tree-node-inner:hover, .tree-node-leaf:hover { filter: brightness(1.3); cursor: default; }

/* ===========================================================
   INTERACTIVE DEMO CONTROLS
   =========================================================== */
.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1rem;
}
.demo-btn {
  padding: .45rem 1rem;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(201,216,244,.8);
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.demo-btn:hover, .demo-btn.active { background: var(--e2); border-color: var(--e2); color: #fff; }

/* ===========================================================
   VERSION TAG
   =========================================================== */
.version-tag {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--e2-dark);
  background: var(--e2-tint);
  border: 1px solid var(--e2-soft);
  padding: .3rem .8rem;
  border-radius: 999px;
}
.version-tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--e2-dark);
  animation: blink 2.5s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ===========================================================
   PAPER / PUBLICATION SECTION
   =========================================================== */
.paper-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--amber-dark);
  background: var(--amber-soft);
  border: 1px solid rgba(196,125,46,.25);
  padding: .3rem .75rem;
  border-radius: 999px;
}

/* ===========================================================
   FOOTER
   =========================================================== */
footer {
  background: var(--e2-deep);
  color: rgba(201, 216, 244, 0.7);
  padding: clamp(3rem, 6vw, 4.5rem) 0 2rem;
}
footer a { color: rgba(201, 216, 244, 0.8); }
footer a:hover { color: #fff; }
.footer-brand .wordmark {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
}
.footer-tagline { font-size: .85rem; margin-top: .4rem; }
.footer-col h4 {
  font-family: var(--font-body);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(201,216,244,.5);
  margin-bottom: 1rem;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.footer-col li { font-size: .9rem; }
.footer-bottom {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(201,216,244,.1);
  font-size: .82rem;
  color: rgba(201,216,244,.4);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
}
@media (max-width: 820px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
  .footer-grid { grid-template-columns: 1fr; }
}

/* ===========================================================
   FADE IN ANIMATIONS
   =========================================================== */
.fade-in {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .65s var(--ease), transform .65s var(--ease);
}
.fade-in.visible { opacity: 1; transform: none; }
.fade-in-delay-1 { transition-delay: .1s; }
.fade-in-delay-2 { transition-delay: .2s; }
.fade-in-delay-3 { transition-delay: .3s; }

/* ===========================================================
   LIGHTBOX
   =========================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(13, 31, 64, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease);
}
.lightbox.open { opacity: 1; pointer-events: all; }
body.lightbox-open { overflow: hidden; }
.lightbox-content {
  max-width: min(90vw, 1000px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
}
.lightbox-content img { width: 100%; max-height: 70vh; object-fit: contain; }
.lightbox-caption { padding: .9rem 1.25rem; font-size: .82rem; color: var(--ink-muted); }
.lightbox-close {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: background .2s;
}
.lightbox-close svg { width: 18px; height: 18px; }
.lightbox-close:hover { background: rgba(255,255,255,.2); }
.lightbox-hint { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); font-size: .78rem; color: rgba(255,255,255,.45); }
.lightbox-hint kbd { background: rgba(255,255,255,.15); padding: .1rem .4rem; border-radius: 4px; font-family: var(--font-mono); }

/* ===========================================================
   UTILITY
   =========================================================== */
.sec-sep { width: 40px; height: 2px; background: var(--e2-dark); margin: 1.25rem 0; display: block; border: none; }
.divider { border: none; border-top: 1px solid var(--rule-soft); margin: 0; }
.hero-grid { display: grid; grid-template-columns: 1fr 480px; gap: clamp(2rem, 5vw, 5rem); align-items: center; }
@media (max-width: 1024px) { .hero-grid { grid-template-columns: 1fr; } .hero-stats { max-width: 520px; } }

/* ===========================================================
   MATH EQUATIONS (KaTeX)
   =========================================================== */
.math-block {
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  padding: 1.25rem 1.75rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  text-align: center;
}
.math-block .katex { font-size: 1.15em; }
.math-inline .katex { font-size: 1em; }
.math-block + p { margin-top: 0; }

/* ===========================================================
   CANVAS EXPLAIN PANEL
   =========================================================== */
#tree-explain {
  display: none;
  background: #0c1a30;
  border: 1px solid rgba(124,197,232,0.25);
  border-radius: 10px;
  padding: 1.1rem 1.4rem;
  margin-top: .75rem;
  font-size: .88rem;
  line-height: 1.6;
  transition: opacity .3s;
  opacity: 0;
}
#tree-explain.active { display: block; opacity: 1; }
.explain-rule { color: rgba(200,225,255,0.92); margin-bottom: .4rem; font-family: var(--font-mono); font-size: .82rem; }
.explain-label { font-size: .65rem; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: rgba(124,197,232,0.8); display: block; margin-bottom: .2rem; }
.explain-verdict { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; font-variation-settings: "opsz" 30; margin: .5rem 0; }
.explain-detail { color: rgba(201,220,248,0.88); font-size: .85rem; margin: 0; }

/* ===========================================================
   USE CASES PAGE
   =========================================================== */

/* SVG interactive tree */
.uc-tree-container {
  background: var(--e2-deep);
  border-radius: 16px;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  overflow-x: auto;
}
#uc-tree-svg-medical,
#uc-tree-svg-credit,
#uc-tree-svg-maint {
  display: block;
  width: 100%;
  height: auto;
}

/* SVG element styles (applied via JS class toggling) */
.tree-edge {
  stroke: rgba(74,111,165,0.4);
  stroke-width: 1.5;
  fill: none;
  transition: stroke .25s, stroke-width .25s;
}
.tree-edge.edge-active {
  stroke: rgba(124,197,232,0.9);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px rgba(124,197,232,0.6));
}

.tree-node-g .node-rect-internal {
  fill: rgba(22,50,100,0.85);
  stroke: rgba(100,150,220,0.5);
  stroke-width: 1.2;
  transition: fill .2s, filter .2s;
}
.tree-node-g:hover .node-rect-internal,
.tree-node-g.node-active .node-rect-internal {
  fill: rgba(40,80,150,0.95);
  stroke: rgba(124,197,232,0.9);
  stroke-width: 1.8;
  filter: drop-shadow(0 0 8px rgba(124,197,232,0.4));
}

.node-leaf-low { fill: rgba(18,80,50,0.85); stroke: rgba(60,200,100,0.6); stroke-width: 1.2; transition: filter .2s, stroke-width .2s; }
.node-leaf-high { fill: rgba(80,18,18,0.85); stroke: rgba(220,70,60,0.6); stroke-width: 1.2; transition: filter .2s, stroke-width .2s; }
.node-leaf-mod  { fill: rgba(90,60,10,0.85); stroke: rgba(230,160,40,0.6); stroke-width: 1.2; transition: filter .2s, stroke-width .2s; }

.leaf-node:hover .node-leaf-low,
.tree-node-g.node-active .node-leaf-low { filter: drop-shadow(0 0 8px rgba(60,200,100,0.5)); stroke-width: 2; }
.leaf-node:hover .node-leaf-high,
.tree-node-g.node-active .node-leaf-high { filter: drop-shadow(0 0 8px rgba(220,70,60,0.5)); stroke-width: 2; }
.leaf-node:hover .node-leaf-mod,
.tree-node-g.node-active .node-leaf-mod  { filter: drop-shadow(0 0 8px rgba(230,160,40,0.5)); stroke-width: 2; }

.node-text-main { fill: #d4e8f8; font-family: "Instrument Sans", sans-serif; font-size: 11px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.node-text-sub  { fill: rgba(180,210,240,0.65); font-family: "JetBrains Mono", monospace; font-size: 9px; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.node-text-leaf { fill: #ffffff; font-family: "Instrument Sans", sans-serif; font-size: 10.5px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.node-text-leaf-sub { font-size: 8px; font-weight: 400; fill: rgba(255,255,255,0.6); font-family: "JetBrains Mono", monospace; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.edge-label { fill: rgba(140,170,210,0.55); font-family: "Instrument Sans", sans-serif; font-size: 8px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.edge-label.active { fill: rgba(180,220,255,0.9); }

/* Profile buttons */
.profile-btn {
  padding: .55rem 1.1rem;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.12);
  color: rgba(201,216,244,.75);
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.profile-btn:hover { background: rgba(74,111,165,.3); border-color: rgba(124,197,232,.4); color: #fff; }
.profile-btn.active { background: var(--e2); border-color: var(--e2); color: #fff; }
.profile-btn.high-risk.active { background: rgba(180,50,40,.7); border-color: rgba(220,80,60,.7); }
.profile-btn.mod-risk.active  { background: rgba(150,100,20,.7); border-color: rgba(230,160,40,.7); }

/* Explain panel for use cases — targets all three IDs */
[id^="uc-explain-panel"] {
  background: #0c1a30;
  border: 1px solid rgba(124,197,232,0.22);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  min-height: 120px;
  transition: opacity .3s;
  opacity: 0;
  margin-top: 1rem;
}
[id^="uc-explain-panel"].active { opacity: 1; }
.uc-panel-label { font-size: .65rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: rgba(124,197,232,0.8); display: block; margin-bottom: .3rem; }
.uc-panel-rule { font-family: var(--font-mono); font-size: .84rem; color: rgba(200,225,255,0.92); margin-bottom: .75rem; }
.uc-panel-verdict {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  font-variation-settings: "opsz" 30;
  padding: .3rem .9rem;
  border-radius: 999px;
  border: 1px solid;
  margin-bottom: .75rem;
}
.uc-panel-detail { font-size: .88rem; color: rgba(201,220,248,0.88); margin: 0; line-height: 1.65; }

/* Case study cards */
.case-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: .28rem .7rem;
  border-radius: 999px;
  background: var(--e2-soft);
  color: var(--e2-deep);
  border: 1px solid rgba(74,111,165,.25);
  margin-bottom: 1rem;
  display: inline-flex;
}
.case-badge.amber { background: var(--amber-soft); color: var(--amber-dark); border-color: rgba(196,125,46,.3); }
.case-badge.slate { background: #eee8f8; color: #4a2a80; border-color: rgba(100,60,180,.25); }

/* Comparison table */
.compare-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: 1.5rem; }
.compare-table th {
  text-align: left;
  padding: .7rem 1rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--rule);
  background: var(--paper-warm);
}
.compare-table th:first-child { border-radius: 8px 0 0 0; }
.compare-table th:last-child { border-radius: 0 8px 0 0; }
.compare-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--rule-soft); color: var(--ink-soft); vertical-align: middle; }
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:hover td { background: var(--e2-tint); }
.compare-table td:first-child { font-weight: 700; color: var(--ink); }
.check { color: #22aa66; font-size: 1.1rem; }
.cross { color: #cc4433; font-size: 1.1rem; }
.partial { color: #cc8822; font-size: 1.1rem; }
.hl-row td { background: var(--e2-tint); border-left: 3px solid var(--e2-dark); }
.hl-row td:first-child { color: var(--e2-deep); }

/* Step annotation (use cases inline steps) */
.annotated-step {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1.5rem;
}
.annotated-step:last-child { margin-bottom: 0; }
.step-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--e2-deep);
  border: 2px solid var(--e2-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 700;
  color: #7cc5e8;
  flex-shrink: 0;
}
.step-dot.done { background: rgba(22,90,60,.6); border-color: rgba(60,200,100,.6); color: #80f0b0; }
.step-dot.warn { background: rgba(90,60,10,.6); border-color: rgba(230,160,40,.6); color: #ffd070; }

/* Viz label top of canvas */
#viz-label {
  font-family: var(--font-body);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(201,216,244,.45);
  margin-bottom: .75rem;
}


/* ===========================================================
   MOBILE OPTIMIZATIONS
   =========================================================== */

/* Prevent horizontal overflow globally */
html, body { overflow-x: hidden; }

/* Touch-friendly scroll on overflow containers */
.code-block,
.uc-tree-container,
.compare-wrap,
.docs-sidebar { -webkit-overflow-scrolling: touch; }

/* SVG trees — respect container width, horizontal scroll inside */
#uc-tree-svg-medical,
#uc-tree-svg-credit,
#uc-tree-svg-maint {
  display: block;
  min-width: 640px;
  height: auto;
}

/* ---- Grid-12 span overflow fix at tablet (960px) ---- */
@media (max-width: 960px) {
  .grid-12 > [style*="span 7"],
  .grid-12 > [style*="span 6"] { grid-column: span 6 !important; }
}

/* ---- Tablet (≤ 820px) ---- */
@media (max-width: 820px) {
  /* Docs layout stacks vertically (sidebar already handled) */
  .docs-layout { grid-template-columns: 1fr; }

  /* Scenario-tab bar: smaller text */
  .scenario-tab { font-size: .78rem; padding: .4rem .85rem; }

  /* Profile buttons: smaller */
  .profile-btn { font-size: .78rem; padding: .4rem .85rem; }

  /* Use-cases explorer header: stack vertically */
  #tree-explorer > .container > .flex,
  #credit-explorer > .container > .flex,
  #maint-explorer  > .container > .flex {
    flex-direction: column;
    align-items: flex-start;
  }
  #tree-explorer .profile-btn,
  #credit-explorer .profile-btn,
  #maint-explorer  .profile-btn { width: 100%; text-align: left; }

  /* Scroll hint on SVG containers */
  .uc-tree-container::after {
    content: "← scroll →";
    display: block;
    text-align: center;
    font-size: .7rem;
    color: rgba(201,216,244,.4);
    padding: .4rem 0 0;
    letter-spacing: .1em;
  }
}

/* ---- Mobile (≤ 640px) ---- */
@media (max-width: 640px) {
  /* Section spacing */
  section { padding: clamp(2.5rem, 7vw, 4rem) 0; }
  .hero   { padding-top: 5.5rem; padding-bottom: 2rem; }

  /* Force all grid-12 spans to full width */
  .grid-12 > * { grid-column: 1 / -1 !important; }

  /* Hero stats: keep 2×2 */
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .stat-num   { font-size: clamp(1.6rem, 7vw, 2.4rem); }

  /* Person cards: stack avatar above text */
  .person { flex-direction: column; gap: .85rem; }
  .person-avatar-placeholder { width: 56px; height: 56px; font-size: 1.1rem; }

  /* Demo controls: wrap tightly */
  .demo-controls { gap: .35rem; }
  .demo-btn { font-size: .72rem; padding: .38rem .65rem; }

  /* Module items: stack num + body vertically on very small */
  .module { gap: .75rem; }

  /* Step items */
  .step-item { gap: .85rem; }
  .step-badge { width: 30px; height: 30px; font-size: .7rem; flex-shrink: 0; }

  /* Cards */
  .card { padding: 1.1rem; }

  /* Citation box */
  .citation { padding: 1rem 1.1rem; font-size: .85rem; }

  /* Code blocks: allow horizontal scroll, no forced font shrink */
  .code-block { font-size: .78rem; padding: 1.1rem 1.25rem; }
  .code-block .copy-btn { font-size: .68rem; padding: .2rem .5rem; top: .5rem; right: .5rem; }

  /* Footer grid: single column */
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .footer-bottom { flex-direction: column; gap: .4rem; font-size: .75rem; }

  /* Nav: hide version badge to save space */
  .nav-brand .wordmark sup { display: none; }

  /* Hide secondary stat-sub on small */
  .stat-sub { font-size: .7rem; }

  /* Comparison table: smaller text */
  .compare-table th,
  .compare-table td { padding: .5rem .65rem; font-size: .8rem; }
}

/* ---- Small mobile (≤ 430px) ---- */
@media (max-width: 430px) {
  /* Hero headline tighter */
  .display-xl { font-size: clamp(2rem, 9vw, 3rem); line-height: 1.0; }
  .display-lg { font-size: clamp(1.7rem, 7.5vw, 2.4rem); }
  .display-md { font-size: clamp(1.4rem, 6.5vw, 2rem); }

  /* Lede text */
  .lede { font-size: 1rem; }

  /* Buttons wrap to full width */
  .btn { width: 100%; justify-content: center; }
  .flex[style*="flex-wrap: wrap"] { flex-direction: column; }

  /* Scenario tabs: single column */
  .scenario-tabs { flex-direction: column; }
  .scenario-tab  { width: 100%; text-align: left; border-radius: 8px; }

  /* Canvas explain panel */
  #tree-explain  { font-size: .8rem; padding: .85rem 1rem; }
  .explain-rule  { font-size: .75rem; }

  /* Use-cases explain panel */
  [id^="uc-explain-panel"] { padding: 1rem 1.1rem; }
  .uc-panel-rule            { font-size: .75rem; }
  .uc-panel-verdict         { font-size: 1rem; }
  .uc-panel-detail          { font-size: .82rem; }
}
