/* ============================================================
   BAYES LAB — DESIGN SYSTEM
   Google Material surfaces + Blender-style animated hero
   ============================================================ */

:root{
  --blue:#4285F4;   --blue-t:rgba(66,133,244,0.10);   --blue-d:#1A73E8;
  --red:#EA4335;    --red-t:rgba(234,67,53,0.10);     --red-d:#D93025;
  --yellow:#F9AB00; --yellow-t:rgba(249,171,0,0.12);  --yellow-d:#B06000;
  --green:#34A853;  --green-t:rgba(52,168,83,0.10);   --green-d:#188038;
  --bg:#F8F9FA;
  --surface:#FFFFFF;
  --outline:#DADCE0;
  --text:#202124;
  --text-2:#5F6368;
  --text-3:#80868B;
  --e1:0 1px 2px 0 rgba(60,64,67,.30),0 1px 3px 1px rgba(60,64,67,.15);
  --e2:0 1px 2px 0 rgba(60,64,67,.30),0 2px 6px 2px rgba(60,64,67,.15);
  --e3:0 6px 10px 0 rgba(60,64,67,.30),0 8px 24px 8px rgba(60,64,67,.20);
  --r-lg:22px; --r-md:12px; --r-sm:8px;
  --nav:72px;
  --hero-d1:#0b1020; --hero-d2:#1a1f3a; --hero-d3:#30366b;
}

*{box-sizing:border-box;}
html{scroll-behavior:smooth;}
body{margin:0;background:var(--bg);color:var(--text);font-family:'Roboto',Arial,sans-serif;font-size:16px;line-height:1.65;padding-top:var(--nav);-webkit-font-smoothing:antialiased;}
img{max-width:100%;}
a{color:var(--blue-d);text-decoration:none;}

h1,h2,h3,h4{font-weight:500;line-height:1.2;margin:0 0 .5em;color:var(--text);}
h1{font-weight:400;letter-spacing:-.5px;}
h2{font-weight:500;letter-spacing:-.2px;}
p{color:var(--text-2);max-width:70ch;}
.lede{font-size:1.1rem;max-width:60ch;color:var(--text-2);}
code,.mono,.num{font-family:'Roboto Mono',monospace;}
.wrap{max-width:1120px;margin:0 auto;padding:0 24px;}
.material-icons{vertical-align:middle;}

/* ---------- NAV ---------- */
header.nav{
  position:fixed;top:0;left:0;right:0;z-index:90;height:var(--nav);
  background:rgba(255,255,255,.9);backdrop-filter:blur(10px);
  border-bottom:1px solid var(--outline);
}
.nav-inner{max-width:1120px;margin:0 auto;padding:0 24px;height:100%;display:flex;align-items:center;gap:1.4rem;}
.brand{display:flex;align-items:center;gap:.6rem;font-weight:700;font-size:1.2rem;letter-spacing:-.5px;color:var(--text);}
.brand .lab{color:var(--text-3);font-weight:400;margin-left:.15rem;}
.brand-mark{width:34px;height:34px;border-radius:9px;display:grid;place-items:center;font-weight:700;color:#fff;
  background:linear-gradient(135deg,var(--blue),var(--red) 55%,var(--yellow) 110%);font-size:1rem;}
.nav-links{display:flex;gap:.15rem;flex-wrap:wrap;margin-left:auto;}
.nav-links a{font-size:.84rem;color:var(--text-2);padding:.42rem .7rem;border-radius:999px;font-weight:500;transition:background .15s,color .15s;}
.nav-links a:hover{background:var(--blue-t);color:var(--blue-d);}
.nav-links a.active{background:var(--blue);color:#fff;}
.nav-cta{display:grid;place-items:center;width:40px;height:40px;border-radius:50%;color:var(--text-2);transition:background .15s;}
.nav-cta:hover{background:var(--blue-t);}

/* ---------- HERO ---------- */
.hero{position:relative;overflow:hidden;color:#fff;
  background:radial-gradient(1200px 700px at 15% -10%,var(--hero-d3),transparent 60%),
             radial-gradient(1000px 600px at 110% 10%,var(--hero-d2),transparent 55%),
             linear-gradient(180deg,#0b0f1f,#12162b);
}
.hero-canvas{position:absolute;inset:0;width:100%;height:100%;}
.hero-inner{position:relative;z-index:2;max-width:1120px;margin:0 auto;padding:5.5rem 24px 6rem;display:grid;grid-template-columns:1.05fr .95fr;gap:3rem;align-items:center;}
@media(max-width:900px){.hero-inner{grid-template-columns:1fr;padding:3.5rem 24px 4.5rem;}}
.hero h1{font-size:clamp(2.2rem,5.5vw,3.9rem);color:#fff;font-weight:600;letter-spacing:-1px;margin-bottom:.9rem;}
.hero h1 .grad{background:linear-gradient(90deg,#8ab4f8,#f28b82,#fdd663);-webkit-background-clip:text;background-clip:text;color:transparent;}
.hero .lede{color:rgba(255,255,255,.82);font-size:1.15rem;max-width:52ch;}
.hero-cta{display:flex;gap:.7rem;flex-wrap:wrap;margin-top:1.8rem;}
.hero-chip{display:inline-flex;align-items:center;gap:.5rem;font-size:.8rem;color:rgba(255,255,255,.85);background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.14);padding:.45rem .9rem;border-radius:999px;margin-bottom:1.4rem;backdrop-filter:blur(6px);}
.hero-chip .dot{width:8px;height:8px;border-radius:50%;background:#81c995;box-shadow:0 0 10px #81c995;animation:pulse 1.7s ease-in-out infinite;}
@keyframes pulse{0%,100%{opacity:1;}50%{opacity:.4;}}

.hero-demo{background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.14);border-radius:var(--r-lg);padding:1.3rem;backdrop-filter:blur(8px);box-shadow:0 12px 40px rgba(0,0,0,.35);}
.hero-demo h3{color:#fff;display:flex;align-items:center;gap:.5rem;font-size:1rem;}
.hero-demo .demo-label{font-size:.74rem;color:rgba(255,255,255,.6);margin-bottom:.5rem;}
.demo-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:.7rem;margin-top:.9rem;}
.demo-stat{background:rgba(255,255,255,.07);border-radius:var(--r-sm);padding:.55rem .7rem;}
.demo-stat .l{font-size:.66rem;color:rgba(255,255,255,.6);}
.demo-stat .v{font-family:'Roboto Mono',monospace;font-size:1rem;color:#fff;font-weight:700;}

/* ---------- BUTTONS ---------- */
button{font-family:'Roboto',sans-serif;font-weight:500;font-size:.88rem;border:1px solid var(--blue);background:var(--blue);color:#fff;padding:.68rem 1.4rem;border-radius:999px;cursor:pointer;display:inline-flex;align-items:center;gap:.45rem;transition:box-shadow .15s,background .15s,transform .05s;}
button:hover{box-shadow:var(--e1);background:var(--blue-d);}
button:active{transform:translateY(1px);}
button.ghost{background:transparent;color:var(--blue-d);border:1px solid var(--outline);}
button.ghost:hover{background:var(--blue-t);border-color:var(--blue);}
button.on-dark{background:#fff;color:var(--blue-d);border-color:#fff;}
button.on-dark:hover{box-shadow:0 6px 20px rgba(0,0,0,.3);}
button.outline-dark{background:transparent;color:#fff;border:1px solid rgba(255,255,255,.4);}
button.outline-dark:hover{background:rgba(255,255,255,.12);border-color:#fff;}
button:disabled{opacity:.4;cursor:not-allowed;}
.btn-row{display:flex;gap:.6rem;flex-wrap:wrap;align-items:center;margin-top:1rem;}
.chip{display:inline-flex;align-items:center;gap:.45rem;font-size:.76rem;font-weight:500;padding:.34rem .85rem .34rem .65rem;border-radius:999px;margin-bottom:.8rem;}
.chip .material-icons{font-size:16px;}
.chip-blue{background:var(--blue-t);color:var(--blue-d);}
.chip-red{background:var(--red-t);color:var(--red-d);}
.chip-yellow{background:var(--yellow-t);color:var(--yellow-d);}
.chip-green{background:var(--green-t);color:var(--green-d);}
.chip-neutral{background:#EEF0F2;color:var(--text-2);}
.chip-purple{background:rgba(161,136,249,.14);color:#6f42c1;}

/* ---------- CARDS ---------- */
section.chapter{margin-top:4.2rem;}
.card{background:var(--surface);border-radius:var(--r-lg);box-shadow:var(--e1);padding:1.8rem 2rem;transition:box-shadow .2s,transform .2s;}
.card:hover{box-shadow:var(--e2);}
.card.flat{box-shadow:0 0 0 1px var(--outline);}
.card + .card{margin-top:1.2rem;}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:1.5rem;}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:1.3rem;}
@media(max-width:820px){.grid2{grid-template-columns:1fr;}.grid3{grid-template-columns:1fr;}}

/* ---------- CONTROLS ---------- */
.control{margin:1.05rem 0;}
.control label{display:flex;justify-content:space-between;font-size:.85rem;color:var(--text-2);margin-bottom:.4rem;font-weight:500;}
.control label .val{font-family:'Roboto Mono',monospace;color:var(--text);font-weight:700;}
input[type=range]{width:100%;accent-color:var(--blue);height:4px;cursor:pointer;}
input[type=number]{width:100%;font-family:'Roboto Mono',monospace;font-size:.95rem;border:1px solid var(--outline);border-radius:var(--r-sm);padding:.5rem .6rem;background:#fff;color:var(--text);}
input[type=number]:focus,input[type=range]:focus{outline:2px solid var(--blue);outline-offset:1px;}
select{width:100%;font-size:.92rem;border:1px solid var(--outline);border-radius:var(--r-sm);padding:.55rem .6rem;background:#fff;color:var(--text);}
textarea{width:100%;font-family:'Roboto Mono',monospace;font-size:.85rem;border:1px solid var(--outline);border-radius:var(--r-sm);padding:.6rem;background:#fff;color:var(--text);}

/* ---------- LEGEND / STATS ---------- */
.legend{display:flex;gap:1.3rem;flex-wrap:wrap;font-size:.82rem;color:var(--text-2);margin:.7rem 0 1rem;}
.legend span{display:inline-flex;align-items:center;gap:.4rem;}
.swatch{width:11px;height:11px;border-radius:3px;display:inline-block;}
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(135px,1fr));gap:.9rem;margin-top:1.2rem;}
.stat{border-radius:var(--r-md);padding:.75rem .9rem;background:#F1F3F4;transition:background .4s;}
.stat .label{font-size:.72rem;color:var(--text-3);font-weight:500;}
.stat .value{font-family:'Roboto Mono',monospace;font-size:1.18rem;color:var(--text);font-weight:700;margin-top:.15rem;word-break:break-word;}
.stat.hl{background:var(--blue-t);}
.stat.hl .value{color:var(--blue-d);}
.stat.hl-red{background:var(--red-t);}
.stat.hl-red .value{color:var(--red-d);}
.stat.hl-green{background:var(--green-t);}
.stat.hl-green .value{color:var(--green-d);}
.stat.flash{animation:flashHL .6s ease;}
@keyframes flashHL{0%{background:var(--yellow-t);}100%{}}

/* ---------- EQUATIONS ---------- */
.eqn-card{padding:1.6rem 1.9rem;}
.eqn-head{display:flex;align-items:center;gap:.5rem;font-size:.78rem;font-weight:600;color:var(--text-3);margin-bottom:.9rem;text-transform:uppercase;letter-spacing:.04em;}
.eqn{font-family:'Roboto Mono',monospace;font-size:clamp(1.02rem,2.1vw,1.3rem);display:flex;align-items:center;gap:.45rem;flex-wrap:wrap;color:var(--text);}
.frac{display:inline-flex;flex-direction:column;vertical-align:middle;text-align:center;margin:0 .25rem;}
.frac .num,.frac .den{padding:0 .3rem;}
.frac .num{border-bottom:1.5px solid var(--text);padding-bottom:.12rem;}
.frac .den{padding-top:.12rem;}
.eqn-note{font-size:.86rem;margin-top:.95rem;color:var(--text-2);}
.eqn-terms{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:1rem;margin-top:1.5rem;}
.eqn-term .tag{font-family:'Roboto Mono',monospace;font-size:.76rem;color:var(--blue-d);font-weight:700;}
.eqn-term p{font-size:.86rem;margin:.25rem 0 0;}

/* ---------- GLOSSARY ---------- */
.gloss{border-bottom:1px solid var(--outline);padding:1.15rem 0;display:grid;grid-template-columns:200px 1fr;gap:1.1rem;}
.gloss:last-child{border-bottom:none;}
.gloss .term{display:flex;align-items:flex-start;gap:.5rem;font-weight:500;}
.gloss .term .material-icons{color:var(--blue-d);font-size:19px;margin-top:.1rem;}
@media(max-width:640px){.gloss{grid-template-columns:1fr;}}

/* ---------- QUIZ ---------- */
.quiz{border-radius:var(--r-lg);padding:1.4rem 1.6rem;margin:1.6rem 0;background:#FEF7E0;border:1px solid #FDE293;}
.quiz .q-label{display:flex;align-items:center;gap:.4rem;font-size:.74rem;color:var(--yellow-d);font-weight:700;margin-bottom:.6rem;}
.quiz-opt{display:block;margin:.5rem 0;cursor:pointer;font-size:.92rem;color:var(--text);}
.quiz-opt input{margin-right:.55rem;accent-color:var(--yellow-d);}
.quiz-feedback{margin-top:.9rem;font-size:.88rem;padding:.75rem .95rem;border-radius:var(--r-sm);display:none;}
.quiz-feedback.correct{display:flex;gap:.5rem;background:var(--green-t);color:var(--green-d);}
.quiz-feedback.incorrect{display:flex;gap:.5rem;background:var(--red-t);color:var(--red-d);}

/* ---------- TABLES ---------- */
table{width:100%;border-collapse:collapse;font-size:.87rem;margin-top:1rem;}
th,td{text-align:left;padding:.6rem .65rem;border-bottom:1px solid var(--outline);}
th{font-size:.72rem;color:var(--text-3);font-weight:500;text-transform:uppercase;letter-spacing:.03em;}
tr.active-row td{background:var(--blue-t);font-weight:700;}

/* ---------- FEATURE GRID ---------- */
.feature-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:1.3rem;margin-top:1.2rem;}
.feature{background:var(--surface);border-radius:var(--r-lg);padding:1.6rem;box-shadow:var(--e1);transition:box-shadow .2s,transform .2s;display:block;color:var(--text);}
.feature:hover{box-shadow:var(--e2);transform:translateY(-3px);}
.feature .ic{width:46px;height:46px;border-radius:12px;display:grid;place-items:center;margin-bottom:1rem;}
.feature .ic .material-icons{font-size:24px;}
.feature h3{font-size:1.02rem;margin-bottom:.4rem;}
.feature p{font-size:.86rem;margin:0;}
.feature .go{margin-top:.9rem;font-size:.82rem;font-weight:500;color:var(--blue-d);display:flex;align-items:center;gap:.2rem;}

/* ---------- CODE ---------- */
pre.code{background:#0f1626;color:#d6e2ff;border-radius:var(--r-md);padding:1.3rem 1.4rem;overflow:auto;font-family:'Roboto Mono',monospace;font-size:.82rem;line-height:1.6;}
pre.code .c{color:#5c739e;}
pre.code .k{color:#82aaff;}
pre.code .f{color:#c792ea;}
.cite{font-size:.78rem;color:var(--text-3);font-style:italic;margin-top:.6rem;}

/* ---------- CALL OUTS ---------- */
.callout{border-left:4px solid var(--blue);background:var(--blue-t);border-radius:0 var(--r-sm) var(--r-sm) 0;padding:1rem 1.2rem;margin:1.3rem 0;}
.callout.warn{border-left-color:var(--yellow);background:var(--yellow-t);}
.callout.danger{border-left-color:var(--red);background:var(--red-t);}
.callout p{margin:0;font-size:.9rem;color:var(--text);}

/* ---------- TABS ---------- */
.tabs{display:flex;gap:.35rem;flex-wrap:wrap;border-bottom:1px solid var(--outline);margin-bottom:1.4rem;}
.tab{font-size:.85rem;font-weight:500;color:var(--text-2);padding:.6rem 1rem;border:none;background:transparent;border-radius:var(--r-sm) var(--r-sm) 0 0;cursor:pointer;border-bottom:2px solid transparent;}
.tab:hover{background:var(--blue-t);color:var(--blue-d);}
.tab.active{color:var(--blue-d);border-bottom-color:var(--blue);}
.tabpanel{display:none;}
.tabpanel.active{display:block;animation:fadein .25s ease;}
@keyframes fadein{from{opacity:0;transform:translateY(4px);}to{opacity:1;transform:none;}}

/* ---------- BADGE ---------- */
.badge{display:inline-block;font-size:.68rem;font-weight:700;padding:.2rem .55rem;border-radius:999px;letter-spacing:.03em;}
.badge.beta{background:rgba(161,136,249,.16);color:#6f42c1;}
.badge.exact{background:var(--green-t);color:var(--green-d);}
.badge.mc{background:var(--yellow-t);color:var(--yellow-d);}

/* ---------- STATS BAND ---------- */
.band{background:#fff;border-top:1px solid var(--outline);border-bottom:1px solid var(--outline);padding:2.6rem 0;}
.band-dark{background:#0f1626;color:#fff;}
.band-dark h2,.band-dark h3{color:#fff;}
.band .wrap h2{text-align:center;margin-bottom:1.5rem;}
.band-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:1.2rem;}
.band-stat{text-align:center;}
.band-stat .v{font-size:2.4rem;font-weight:700;font-family:'Roboto Mono',monospace;color:var(--blue);}
.band-stat .l{font-size:.8rem;color:var(--text-2);}
.band-dark .band-stat .v{color:#8ab4f8;}
.band-dark .band-stat .l{color:rgba(255,255,255,.7);}

/* ---------- NAV PAGINATION ---------- */
.pagination{display:flex;justify-content:space-between;gap:1rem;margin-top:3.5rem;}
.pg{flex:1;display:block;padding:1.2rem 1.4rem;border-radius:var(--r-md);background:var(--surface);box-shadow:var(--e1);transition:box-shadow .2s,transform .2s;}
.pg:hover{box-shadow:var(--e2);transform:translateY(-2px);}
.pg .dir{font-size:.7rem;color:var(--text-3);text-transform:uppercase;letter-spacing:.05em;}
.pg .t{font-weight:600;color:var(--text);margin-top:.2rem;}
.pg.next{text-align:right;}

footer.site{margin-top:5rem;padding:2.6rem 0 3.5rem;border-top:1px solid var(--outline);background:#fff;}
footer.site p{font-size:.84rem;color:var(--text-3);}
.foot-grid{display:grid;grid-template-columns:1.4fr 1fr 1fr;gap:2rem;}
@media(max-width:760px){.foot-grid{grid-template-columns:1fr;}}

/* responsive chart wrappers */
.chart-box{position:relative;width:100%;}
.three-box{width:100%;height:460px;border-radius:var(--r-md);background:linear-gradient(180deg,#EEF3FC,#F8F9FA);position:relative;overflow:hidden;cursor:grab;}
.three-box:active{cursor:grabbing;}
.three-hint{position:absolute;bottom:.7rem;left:.8rem;font-size:.72rem;color:var(--text-2);font-family:'Roboto Mono',monospace;background:rgba(255,255,255,.85);padding:.25rem .6rem;border-radius:999px;box-shadow:var(--e1);}
.axis-legend{position:absolute;top:.7rem;right:.8rem;font-size:.68rem;color:var(--text-2);font-family:'Roboto 
  Mono',monospace;background:rgba(255,255,255,.85);padding:.4rem 
  .6rem;border-radius:var(--r-sm);box-shadow:var(--e1);text-align:right;line-height:1.5;}

/* ---------- INDEX CHARTS ---------- */
.hero-charts{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin-top:1.1rem;}
.hero-charts .hc{background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.12);border-radius:var(--r-md);padding:.9rem .95rem;}
.hero-charts .hc h4{margin:0 0 .3rem;font-size:.8rem;color:#fff;display:flex;align-items:center;gap:.4rem;}
.hero-charts .hc h4 .material-icons{font-size:16px;color:#8ab4f8;}
.hero-charts .hc .cap{font-size:.66rem;color:rgba(255,255,255,.6);}
.chart-card{background:var(--surface);border-radius:var(--r-lg);box-shadow:var(--e1);padding:1.3rem 1.4rem 1.1rem;}
.chart-card h3{font-size:1rem;margin-bottom:.2rem;display:flex;align-items:center;gap:.5rem;}
.chart-card h3 .material-icons{color:var(--blue-d);font-size:20px;}
.chart-card .cap{font-size:.76rem;color:var(--text-3);margin-bottom:.8rem;}
.index-charts{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:1.4rem;margin-top:1.4rem;}
.index-charts .plot{position:relative;height:230px;}

/* ============================================================
   THEME TOGGLE (Blender-style) + DARK THEME
   ============================================================ */
.theme-toggle{display:inline-flex;align-items:center;gap:2px;padding:3px;
  border-radius:999px;background:#F1F3F4;border:1px solid var(--outline);}
.theme-toggle .tt-opt{border:none;background:transparent;cursor:pointer;padding:6px 7px;border-radius:999px;
  display:grid;place-items:center;color:var(--text-3);transition:background .15s,color .15s,box-shadow .15s;}
.theme-toggle .tt-opt:hover{color:var(--text);}
.theme-toggle .tt-opt.active{background:#fff;color:var(--text);box-shadow:var(--e1);}
.theme-toggle .tt-opt.active svg{stroke:var(--blue-d);}
[data-theme="dark"] .theme-toggle{background:var(--surface-2);border-color:var(--outline);}
[data-theme="dark"] .theme-toggle .tt-opt{color:var(--text-3);}
[data-theme="dark"] .theme-toggle .tt-opt:hover{color:var(--text);}
[data-theme="dark"] .theme-toggle .tt-opt.active{background:var(--surface);color:var(--text);box-shadow:var(--e2);}
[data-theme="dark"] .theme-toggle .tt-opt.active svg{stroke:#ffd04d;}

/* Progress color-scheme so native widgets match */
[data-theme="dark"]{color-scheme:dark;}

/* Blender-style dark palette (deep charcoal + amber accent) */
[data-theme="dark"]{
  --blue:#8ab4f8; --blue-t:rgba(138,180,248,.12); --blue-d:#8ab4f8;
  --red:#f28b82;  --red-t:rgba(242,139,130,.12);  --red-d:#f28b82;
  --yellow:#fdd663;--yellow-t:rgba(253,214,99,.12);--yellow-d:#fdd663;
  --green:#7bd88f;--green-t:rgba(123,216,143,.12);--green-d:#7bd88f;
  --bg:#1f1f1f;
  --surface:#2b2b2c;
  --surface-2:#333334;
  --outline:#4a4a4b;
  --text:#e8e8e8;
  --text-2:#b8b8b9;
  --text-3:#8f8f90;
  --e1:0 1px 3px 0 rgba(0,0,0,.55);
  --e2:0 2px 6px 2px rgba(0,0,0,.5);
  --e3:0 8px 24px 8px rgba(0,0,0,.55);
  --hero-d1:#141414; --hero-d2:#191919; --hero-d3:#2a2a2b;
}

[data-theme="dark"] body{background:var(--bg);color:var(--text);}
[data-theme="dark"] header.nav{background:rgba(32,32,33,.86);border-bottom-color:var(--outline);}
[data-theme="dark"] .nav-links a{color:var(--text-2);}
[data-theme="dark"] .nav-links a:hover{background:var(--blue-t);color:var(--blue-d);}
[data-theme="dark"] .nav-links a.active{background:var(--blue);color:#141414;}
[data-theme="dark"] .brand{color:var(--text);}
[data-theme="dark"] .brand .lab{color:var(--text-3);}

/* the hero stays dark in both themes (Blender keeps the viewport dark) */
[data-theme="dark"] .hero{background:radial-gradient(1200px 700px at 15% -10%,#2a2a2b,transparent 60%),
  radial-gradient(1000px 600px at 110% 10%,#191919,transparent 55%),
  linear-gradient(180deg,#141414,#1a1a1b);}

/* cards, bands, footers */
[data-theme="dark"] .card,[data-theme="dark"] .chart-card,
[data-theme="dark"] .feature,[data-theme="dark"] .pg{background:var(--surface);box-shadow:var(--e1);}
[data-theme="dark"] .card.flat,[data-theme="dark"] .feature{box-shadow:0 0 0 1px var(--outline);}
[data-theme="dark"] .feature:hover,[data-theme="dark"] .card:hover,[data-theme="dark"] .pg:hover{box-shadow:var(--e2);}
[data-theme="dark"] .band{background:var(--surface);border-top-color:var(--outline);border-bottom-color:var(--outline);}
[data-theme="dark"] footer.site{background:var(--surface);border-top-color:var(--outline);}

/* text on dark */
[data-theme="dark"] h1,[data-theme="dark"] h2,[data-theme="dark"] h3,[data-theme="dark"] h4,
[data-theme="dark"] .stat .value,[data-theme="dark"] .eqn,[data-theme="dark"] .gloss .term,
[data-theme="dark"] .pg .t{color:var(--text);}
[data-theme="dark"] p,[data-theme="dark"] .lede,[data-theme="dark"] .feature p,
[data-theme="dark"] .stat .label,[data-theme="dark"] .eqn-note,[data-theme="dark"] .cite,
[data-theme="dark"] .control label,[data-theme="dark"] .legend,[data-theme="dark"] .band-stat .l,
[data-theme="dark"] .three-hint,[data-theme="dark"] .axis-legend{color:var(--text-2);}
[data-theme="dark"] .chip-neutral{background:var(--surface-2);color:var(--text-2);}
[data-theme="dark"] .stat{background:var(--surface-2);}
[data-theme="dark"] .stat.hl{background:var(--blue-t);} [data-theme="dark"] .stat.hl .value{color:var(--blue-d);}
[data-theme="dark"] .stat.hl-red{background:var(--red-t);} [data-theme="dark"] .stat.hl-red .value{color:var(--red-d);}
[data-theme="dark"] .stat.hl-green{background:var(--green-t);} [data-theme="dark"] .stat.hl-green .value{color:var(--green-d);}

/* forms */
[data-theme="dark"] input[type=number],[data-theme="dark"] select,[data-theme="dark"] textarea,
[data-theme="dark"] .code{background:var(--surface-2);color:var(--text);border-color:var(--outline);}
[data-theme="dark"] input[type=number]:focus,[data-theme="dark"] select:focus,[data-theme="dark"] textarea:focus{outline-color:var(--blue);}

/* tables */
[data-theme="dark"] table td,[data-theme="dark"] table th,[data-theme="dark"] .gloss{border-bottom-color:var(--outline);}
[data-theme="dark"] tr.active-row td{background:var(--blue-t);}

/* quiz — darker amber */
[data-theme="dark"] .quiz{background:#3a3217;border-color:#5c5023;color:var(--text);}
[data-theme="dark"] .quiz .q-label{color:var(--yellow);}
[data-theme="dark"] .quiz-opt{color:var(--text);}

/* calls-out */
[data-theme="dark"] .callout{background:var(--surface-2);}
[data-theme="dark"] .callout p{color:var(--text);}

/* feature icons that used hard-coded light chips */
[data-theme="dark"] .feature .ic[style*="background:#EEF0F2"]{background:var(--surface-2)!important;color:var(--text-2);}

/* tabs */
[data-theme="dark"] .tabs{border-bottom-color:var(--outline);}
[data-theme="dark"] .tab{color:var(--text-2);}
[data-theme="dark"] .tab:hover{background:var(--blue-t);color:var(--blue-d);}
[data-theme="dark"] .tab.active{color:var(--blue-d);border-bottom-color:var(--blue);}

/* three-box + chart hints */
[data-theme="dark"] .three-box{background:linear-gradient(180deg,#262627,#1f1f1f);}
[data-theme="dark"] .three-hint,[data-theme="dark"] .axis-legend{background:rgba(43,43,44,.9);color:var(--text-2);}

/* band-dark stays near-black in both themes */
[data-theme="dark"] .band-dark{background:#141414;}

/* ============================================================
   MOBILE / RESPONSIVE
   Narrow-viewport refinements only. The desktop layout above is
   untouched — nothing is removed or hidden, content only reflows.
   ============================================================ */

/* Tablets & small laptops: let the nav grow instead of clipping */
@media(max-width:1024px){
  header.nav{height:auto;}
  .nav-inner{flex-wrap:wrap;row-gap:.35rem;padding:.5rem 20px;}
  body{padding-top:calc(var(--nav) + 26px);}
}

/* Phones: nav links become one swipeable strip, all still present */
@media(max-width:760px){
  .nav-inner{height:auto;padding:.55rem 16px;gap:.8rem;}
  .nav-links{order:5;width:100%;margin-left:0;flex-wrap:nowrap;overflow-x:auto;
    -webkit-overflow-scrolling:touch;scrollbar-width:thin;padding-bottom:2px;}
  .nav-links a{white-space:nowrap;padding:.5rem .85rem;font-size:.88rem;}
}

/* Phones: spacing + reflow without changing any content */
@media(max-width:600px){
  .wrap{padding:0 16px;}
  section.chapter{margin-top:3rem;}
  .card,.feature,.chart-card{min-width:0;}
  .grid2 > *,.grid3 > *{min-width:0;}
  .card{padding:1.3rem 1.2rem;border-radius:18px;}
  .eqn-card{padding:1.15rem 1rem;}
  .callout{padding:.9rem 1rem;}
  .stat{padding:.65rem .75rem;}
  footer.site{margin-top:4rem;padding:2rem 0 3rem;}
  .band{padding:2rem 0;}
  .pagination{flex-direction:column;gap:.8rem;margin-top:2.5rem;}
  .pg{padding:1rem 1.2rem;}
  .hero-inner{padding:3rem 16px 3.5rem;gap:2rem;}
  .hero-demo{padding:1rem;}
  .hero-charts{grid-template-columns:1fr;}
  .three-box{height:380px;}
  .tabs{overflow-x:auto;flex-wrap:nowrap;padding-bottom:.35rem;}
  .tab{white-space:nowrap;}
  table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;}
  pre.code{max-width:100%;padding:1rem 1.1rem;}
}

/* Small phones: read-friendly hero, CTA buttons fill thumb width */
@media(max-width:480px){
  .hero h1{font-size:2rem;letter-spacing:-.5px;}
  .hero-cta button{flex:1 1 220px;justify-content:center;}
  .demo-stats{gap:.5rem;}
  .demo-stat{padding:.5rem .55rem;}
}
