/* ============================================================
   Matter Tech — Website v3 design system
   Bold modern refresh of the green identity.
   Dark-first with a light theme, driven by [data-theme] tokens.
   ============================================================ */

:root {
  /* Brand */
  --green: #1f8f66;
  --green-bright: #27c08a;
  --green-deep: #0f5b41;
  --blue: #3f86a8;
  --gold: #c79a3e;
  --rose: #c96577;

  /* Type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", monospace;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.18s;
  --t-med: 0.4s;

  /* Layout */
  --maxw: 1200px;
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 76px;
}

/* ---- Dark theme (default) ---- */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1110;
  --bg-2: #0e1817;
  --surface: #111d1b;
  --surface-2: #162a26;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --ink: #eaf3ef;
  --ink-soft: #c3d3cd;
  --muted: #8aa39b;
  --accent: var(--green-bright);
  --accent-ink: #03130d;
  --glow: rgba(39, 192, 138, 0.45);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 10px 30px rgba(0, 0, 0, 0.35);
  --grid-line: rgba(39, 192, 138, 0.07);
  --hero-veil: linear-gradient(180deg, rgba(10, 17, 16, 0) 30%, rgba(10, 17, 16, 0.7) 100%);
}

/* ---- Light theme ---- */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8f5;
  --bg-2: #eef2ed;
  --surface: #ffffff;
  --surface-2: #f1f5f1;
  --line: rgba(15, 40, 32, 0.12);
  --line-strong: rgba(15, 40, 32, 0.22);
  --ink: #142019;
  --ink-soft: #2f4339;
  --muted: #5a6e64;
  --accent: var(--green);
  --accent-ink: #ffffff;
  --glow: rgba(31, 143, 102, 0.28);
  --shadow: 0 24px 60px rgba(20, 40, 32, 0.12);
  --shadow-sm: 0 12px 30px rgba(20, 40, 32, 0.08);
  --grid-line: rgba(31, 143, 102, 0.08);
  --hero-veil: linear-gradient(180deg, rgba(246, 248, 245, 0) 35%, rgba(246, 248, 245, 0.78) 100%);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease);
}

/* Ambient background grid + glow */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 75%);
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  top: -20%;
  left: 50%;
  width: 90vw;
  height: 60vh;
  transform: translateX(-50%);
  z-index: -2;
  background: radial-gradient(ellipse at center, var(--glow), transparent 70%);
  opacity: 0.5;
  filter: blur(40px);
  pointer-events: none;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-inline: clamp(20px, 5vw, 40px); }

/* skip link */
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 700;
}
.skip-link:focus { left: 12px; }

/* ============================================================
   Header / nav
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  min-height: var(--header-h);
  display: flex; align-items: center; gap: 24px;
  justify-content: space-between;
  padding: 12px clamp(20px, 5vw, 40px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand-link { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -0.02em; }
.brand-logo { height: 44px; width: 44px; object-fit: contain; border-radius: 10px; }
.brand-text { font-size: 1.12rem; }
.brand-text span { color: var(--muted); font-weight: 600; }
.header-signin { margin-right: auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 15px; border-radius: 999px; font-size: 0.85rem; line-height: 1.15; font-weight: 700; text-align: center; text-decoration: none; background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px var(--glow); transition: transform var(--t-fast); white-space: nowrap; }
.header-signin:hover { transform: translateY(-1px); }
@media (max-width: 560px) { .header-signin { padding: 7px 12px; } }

.nav-wrap { display: flex; align-items: center; gap: 10px; }
.site-nav { display: flex; align-items: center; gap: 2px; }
.site-nav a {
  position: relative; padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 0.93rem; font-weight: 600; color: var(--ink-soft);
  transition: color var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); background: var(--surface); }
.site-nav a.is-active { color: var(--ink); }
.site-nav a.is-active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px;
  background: var(--accent); border-radius: 2px;
}

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.icon-button:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.icon-button svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
[data-theme="light"] .theme-toggle .sun { display: block; }
[data-theme="light"] .theme-toggle .moon { display: none; }

.menu-button { display: none; flex-direction: column; gap: 4px; }
.menu-line { width: 18px; height: 2px; background: var(--ink); border-radius: 99px; transition: transform var(--t-fast); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px;
  padding: 13px 22px; border-radius: 99px; font-weight: 700; font-size: 0.96rem;
  line-height: 1.2; text-align: center; cursor: pointer; border: 1px solid transparent; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.btn:focus-visible { outline: 3px solid var(--glow); outline-offset: 3px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px var(--glow); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 34px var(--glow); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { transform: translateY(-2px); border-color: var(--accent); }
.btn-arrow svg { width: 16px; height: 16px; transition: transform var(--t-fast); }
.btn:hover .btn-arrow svg { transform: translateX(3px); }

/* ============================================================
   Typography helpers
   ============================================================ */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
  margin: 0 0 18px;
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--accent); opacity: 0.6; }

h1, h2, h3 { margin: 0 0 0.5em; letter-spacing: -0.03em; line-height: 1.05; font-weight: 800; }
h1 { font-size: clamp(2.6rem, 6vw, 5rem); }
h2 { font-size: clamp(1.9rem, 4vw, 3.2rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.45rem); letter-spacing: -0.01em; }
.lede { font-size: clamp(1.05rem, 1.7vw, 1.3rem); color: var(--ink-soft); max-width: 60ch; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.gradient-text {
  background: linear-gradient(120deg, var(--accent), var(--blue));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative;
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: clamp(28px, 5vw, 64px);
  align-items: center;
  padding: clamp(48px, 8vw, 110px) 0 clamp(40px, 6vw, 80px);
}
.hero-copy { max-width: 620px; }
.hero h1 { margin-bottom: 22px; }
.hero .lede { margin-bottom: 32px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; }

.hero-stats { display: flex; gap: 28px; margin-top: 44px; flex-wrap: wrap; }
.hero-stats div { display: grid; gap: 2px; }
.hero-stats strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.hero-stats span { font-size: 0.82rem; color: var(--muted); }

.hero-visual {
  position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow); aspect-ratio: 4 / 3; min-height: 360px;
}
.hero-visual canvas { display: block; width: 100%; height: 100%; }
[data-hero-h1], [data-hero-lede], [data-hero-stats] { transition: opacity 0.4s ease, transform 0.4s ease; }
[data-hero-h1].is-swapping, [data-hero-lede].is-swapping, [data-hero-stats].is-swapping { opacity: 0; transform: translateY(8px); }
.hero-slide { position: absolute; inset: 0; display: none; }
.hero-slide.is-active { display: block; }
.hero-demo { position: absolute; inset: 0; }
.visual-badge {
  position: absolute; left: 16px; bottom: 16px; z-index: 2;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 0.74rem; color: var(--ink);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(6px); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 99px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-bright); box-shadow: 0 0 0 0 var(--glow); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--glow); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ============================================================
   Sections
   ============================================================ */
section { position: relative; }
.section { padding: clamp(56px, 9vw, 120px) 0; }
.section-head { max-width: 720px; margin-bottom: clamp(36px, 5vw, 60px); }
.section-divider { border-top: 1px solid var(--line); }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ============================================================
   Cards / grids
   ============================================================ */
.card-grid { display: grid; gap: 20px; grid-template-columns: repeat(3, 1fr); }
.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px;
  transition: transform var(--t-med) var(--ease), border-color var(--t-med), box-shadow var(--t-med);
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent-bar, var(--accent)); opacity: 0; transition: opacity var(--t-med);
}
.card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.card:hover::before { opacity: 1; }
.card .card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 12px; margin-bottom: 18px;
  background: color-mix(in srgb, var(--accent-bar, var(--accent)) 16%, transparent);
  color: var(--accent-bar, var(--accent));
}
.card .card-icon svg { width: 22px; height: 22px; }
.card h3 { margin-bottom: 8px; }
.card p { color: var(--muted); margin: 0; font-size: 0.96rem; }
.card-sci { --accent-bar: var(--green-bright); }
.card-tech { --accent-bar: var(--blue); }
.card-soc { --accent-bar: var(--rose); }
.card-cal { --accent-bar: var(--gold); }

/* Feature split */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 5vw, 64px); align-items: center; }
.split.reverse > :first-child { order: 2; }

/* spec list */
.spec-list { display: grid; gap: 2px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.spec-list > div { display: grid; grid-template-columns: 150px 1fr; gap: 18px; padding: 18px 22px; }
.spec-list > div + div { border-top: 1px solid var(--line); }
.spec-list strong { font-size: 0.95rem; }
.spec-list span { color: var(--muted); font-size: 0.94rem; }

/* ============================================================
   Interactive demo panel
   ============================================================ */
.demo-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.demo-stage { position: relative; aspect-ratio: 16 / 10; background: var(--bg-2); }
.demo-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.demo-hint {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--line); padding: 6px 11px; border-radius: 99px; backdrop-filter: blur(6px);
}
.demo-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px;
  padding: 16px 20px; border-top: 1px solid var(--line);
}
.demo-controls .control { display: grid; gap: 6px; min-width: 140px; }
.demo-controls label { font-size: 0.78rem; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; }
.demo-controls label var { font-family: var(--font-mono); font-style: normal; color: var(--accent); }
.demo-controls .btn { padding: 9px 16px; font-size: 0.86rem; }
.demo-readout { margin-left: auto; font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.demo-readout b { color: var(--ink); }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 99px; background: var(--line-strong); cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 2px solid var(--surface); border-radius: 50%; background: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; padding: 3px; gap: 2px; background: var(--bg-2); }
.seg button { border: 0; background: transparent; padding: 7px 13px; border-radius: 99px; font-size: 0.82rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.is-active { background: var(--accent); color: var(--accent-ink); }

/* ============================================================
   Carousel (kept, restyled)
   ============================================================ */
.carousel { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-sm); background: var(--surface); }
.carousel-track { display: grid; }
.carousel-slide { grid-area: 1 / 1; position: relative; opacity: 0; transition: opacity 0.9s var(--ease); aspect-ratio: 16/10; }
.carousel-slide.is-active { opacity: 1; }
.carousel-slide img { width: 100%; height: 100%; object-fit: cover; }
.carousel-slide figcaption {
  position: absolute; left: 16px; bottom: 16px;
  font-size: 0.85rem; font-weight: 600; color: #fff;
  background: rgba(8, 16, 14, 0.7); padding: 8px 13px; border-radius: 99px; backdrop-filter: blur(4px);
}
.carousel-dots { position: absolute; bottom: 16px; right: 16px; display: flex; gap: 7px; }
.carousel-dot { width: 24px; height: 6px; border: 0; padding: 0; border-radius: 99px; background: rgba(255,255,255,0.4); cursor: pointer; transition: background var(--t-fast); }
.carousel-dot.is-active { background: var(--green-bright); }

/* ============================================================
   CTA banner
   ============================================================ */
.cta {
  position: relative; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(36px, 6vw, 64px); text-align: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--green-deep) 55%, var(--surface)), var(--surface));
}
.cta h2 { margin-bottom: 14px; }
.cta .lede { margin: 0 auto 28px; }
.cta .hero-actions { justify-content: center; }

/* ============================================================
   Forms
   ============================================================ */
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(24px, 4vw, 36px); box-shadow: var(--shadow-sm); display: grid; gap: 18px; }
.form-row { display: grid; gap: 8px; }
.form-row.two { grid-template-columns: 1fr 1fr; gap: 18px; }
label.field { display: grid; gap: 8px; font-size: 0.86rem; font-weight: 600; }
input[type="text"], input[type="email"], input[type="url"], input[type="password"], select, textarea {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; min-height: 46px; width: 100%; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.form-note { font-size: 0.82rem; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; }
.form-status { min-height: 1.4em; font-size: 0.9rem; font-weight: 600; color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: 7px; font-size: 0.76rem; font-weight: 600;
  padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); background: var(--bg-2);
}
.badge.green { color: var(--green-bright); border-color: color-mix(in srgb, var(--green-bright) 40%, transparent); }

/* job rows */
.job { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color var(--t-fast), transform var(--t-fast); }
.job:hover { border-color: var(--line-strong); transform: translateX(4px); }
.job .job-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* timeline */
.timeline { display: grid; gap: 0; }
.timeline .step { display: grid; grid-template-columns: auto 1fr; gap: 20px; padding-bottom: 28px; }
.timeline .dot { position: relative; width: 14px; }
.timeline .dot::before { content: ""; position: absolute; top: 4px; left: 0; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.timeline .dot::after { content: ""; position: absolute; top: 20px; left: 6px; bottom: -10px; width: 2px; background: var(--line); }
.timeline .step:last-child .dot::after { display: none; }
.timeline .step h3 { margin-bottom: 4px; }
.timeline .step p { color: var(--muted); margin: 0; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; padding: clamp(48px, 6vw, 72px) 0 36px; }
.footer-brand .brand-link { margin-bottom: 14px; }
.footer-brand p { color: var(--muted); font-size: 0.92rem; max-width: 32ch; }
.footer-col h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 14px; }
.footer-col a { display: block; color: var(--ink-soft); font-size: 0.92rem; padding: 5px 0; transition: color var(--t-fast); }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 22px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.84rem; }

/* download page */
.download-page { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 80px 0; }
.download-page .card-icon { margin: 0 auto 20px; width: 60px; height: 60px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 940px) {
  .hero { grid-template-columns: 1fr; }
  .hero-visual { order: -1; min-height: 300px; }
  .split, .split.reverse > :first-child { grid-template-columns: 1fr; order: 0; }
  .card-grid, .card-grid.cols-2, .card-grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .site-nav, .desktop-only { display: none; }
  .menu-button { display: inline-flex; }
  .site-nav.is-open {
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    position: absolute; top: calc(var(--header-h) - 4px); right: clamp(20px, 5vw, 40px);
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
    padding: 10px; min-width: 220px; box-shadow: var(--shadow);
  }
  .demo-readout { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .card-grid, .card-grid.cols-2, .card-grid.cols-4, .footer-grid, .form-row.two { grid-template-columns: 1fr; }
  .hero-stats { gap: 20px; }
  .job { flex-direction: column; align-items: flex-start; }
  .spec-list > div { grid-template-columns: 1fr; gap: 4px; }
}

/* ============================================================
   Ambient page chrome: scroll progress, gutter grid/meta/glyphs,
   section rail. Decorative; gutters appear only on wide viewports.
   ============================================================ */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--green-deep), var(--green-bright));
  box-shadow: 0 0 10px var(--glow); z-index: 100; transition: width 0.08s linear;
}

.gutter {
  position: fixed; top: 0; bottom: 0; width: calc((100vw - var(--maxw)) / 2);
  z-index: -1; pointer-events: none; display: none; overflow: hidden;
}
.gutter-left { left: 0; }
.gutter-right { right: 0; }
.gutter::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 38px 38px; opacity: 0.5;
}
.gutter-left::before  { -webkit-mask-image: linear-gradient(90deg, transparent, #000 72%); mask-image: linear-gradient(90deg, transparent, #000 72%); }
.gutter-right::before { -webkit-mask-image: linear-gradient(90deg, #000 28%, transparent); mask-image: linear-gradient(90deg, #000 28%, transparent); }
.gutter-meta {
  position: absolute; bottom: 32px; writing-mode: vertical-rl;
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--muted); opacity: 0.85;
}
.gutter-left .gutter-meta  { left: 26px; transform: rotate(180deg); }
.gutter-right .gutter-meta { right: 26px; }
.gutter-glyph { position: absolute; color: var(--accent); opacity: 0.14; }
.gutter-left .gutter-glyph  { left: 22px; }
.gutter-right .gutter-glyph { right: 22px; }

.site-rail {
  position: fixed; top: 50%; transform: translateY(-50%);
  right: max(14px, calc((100vw - var(--maxw)) / 2 - 28px));
  z-index: 40; display: none; flex-direction: column; gap: 13px;
}
.site-rail button {
  width: 10px; height: 10px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 1px solid var(--line-strong); background: transparent; position: relative;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.site-rail button:hover { border-color: var(--accent); }
.site-rail button.is-active {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.site-rail button::after {
  content: attr(data-label); position: absolute; right: 20px; top: 50%;
  transform: translateY(-50%); white-space: nowrap; font-family: var(--font-mono);
  font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 88%, transparent); padding: 3px 8px;
  border-radius: 6px; border: 1px solid var(--line); opacity: 0; transition: opacity var(--t-fast);
}
.site-rail button:hover::after, .site-rail button.is-active::after { opacity: 1; }

@media (min-width: 1240px) { .gutter { display: block; } }
@media (prefers-reduced-motion: reduce) { .scroll-progress { transition: none; } }

/* ============================================================
   Theory panels: gutter tabs, slide-over drawer, theory hub page
   ============================================================ */
.theory-tabs {
  position: fixed; top: calc(var(--header-h) + 16px); bottom: 22px;
  z-index: 42; display: none; flex-direction: column; gap: 12px;
  align-items: center; justify-content: flex-start;
  max-height: calc(100vh - var(--header-h) - 38px); overflow-y: auto; scrollbar-width: none;
}
.theory-tabs::-webkit-scrollbar { display: none; }
.theory-tabs.left  { left: 18px; }
.theory-tabs.right { right: 18px; }
.theory-tab {
  width: 50px; height: 50px; flex: none; display: grid; place-items: center; cursor: pointer;
  border-radius: 13px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 72%, transparent);
  color: var(--muted); position: relative; transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.theory-tab:hover { color: var(--accent); border-color: var(--accent); background: var(--surface); transform: translateY(-1px); }
.theory-tab svg { width: 25px; height: 25px; }
.theory-tab::after {
  content: attr(data-label); position: absolute; white-space: nowrap; z-index: 3;
  font-family: var(--font-mono); font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); padding: 4px 9px; border-radius: 7px; top: 50%; transform: translateY(-50%);
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast);
}
.theory-tabs.left  .theory-tab::after { left: 60px; }
.theory-tabs.right .theory-tab::after { right: 60px; }
.theory-tab:hover::after { opacity: 1; }
.theory-tabs-label {
  writing-mode: vertical-rl; transform: rotate(180deg); align-self: center;
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--muted); opacity: 0.7; margin-bottom: 4px;
}

.theory-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px); opacity: 0; visibility: hidden; transition: opacity var(--t-med);
}
.theory-backdrop.is-open { opacity: 1; visibility: visible; }
.theory-drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 100%); z-index: 91;
  background: var(--bg-2); border-left: 1px solid var(--line-strong); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform var(--t-med) var(--ease);
  display: flex; flex-direction: column; overflow: hidden;
}
.theory-drawer.is-open { transform: translateX(0); }
.theory-drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 24px 14px; border-bottom: 1px solid var(--line);
}
.theory-drawer-head .eyebrow { margin-bottom: 6px; }
.theory-drawer-head h2 { font-size: 1.5rem; line-height: 1.15; }
.theory-close {
  flex: none; width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 1.1rem;
}
.theory-close:hover { border-color: var(--accent); color: var(--accent); }
.theory-body { padding: 20px 24px 40px; overflow-y: auto; }

.theory-body p { color: var(--ink-soft); margin-bottom: 14px; }
.theory-math {
  margin: 14px 0; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); overflow-x: auto;
}
.theory-math > div { margin: 6px 0; color: var(--ink); }
.theory-graph {
  width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); display: block; margin: 8px 0 6px;
}
.theory-caption { font-size: 0.8rem; color: var(--muted); margin-bottom: 16px; }
.theory-cite {
  font-size: 0.82rem; color: var(--muted); border-top: 1px solid var(--line);
  padding-top: 14px; margin-top: 8px;
}
.theory-note {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
}

/* Theory hub page entries */
.theory-entry { padding: clamp(28px,4vw,48px) 0; border-top: 1px solid var(--line); }
.theory-entry:first-of-type { border-top: 0; }
.theory-entry .split { align-items: start; }

@media (min-width: 1360px) { .theory-tabs { display: flex; } }

/* honeypot (spam trap): visually hidden, off-screen, not focusable */
.hp-field { position: absolute !important; left: -9999px !important; top: auto; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
