:root {
  /* Light Theme (Default) */
  --bg-color: #FFF8F0;
  --bg-gradient: linear-gradient(180deg, #FFFFFF 0%, #FFF8F0 100%);
  --text-primary: #3D3024;
  --text-muted: #6B5E50;
  --text-light: #9C8E80;
  --border-color: #F0E0CC;
  --border-light: #F7EDE0;
  --card-bg: #FFFFFF;
  --card-shadow: rgba(61,48,36,.05);
  --hero-gradient: linear-gradient(170deg, #FFF8F0 0%, #FFE8D0 50%, #FFDFC8 100%);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(61, 48, 36, 0.08);

  --cream: #FFF8F0;
  --sand: #F0E0CC;
  --sand-light: #F7EDE0;
  --peach: #FFDFC8;
  --peach-deep: #E8A87C;
  --gold: #D4915E;
  --gold-dark: #B87333;
  --brown: #3D3024;
  --brown-light: #6B5E50;
  --brown-muted: #9C8E80;
  --white: #FFFFFF;

  /* Accent Colors - Light */
  --blue: #4A7FBF;
  --blue-bg: #E8F0F8;
  --blue-light: #C8DCF0;
  --green: #5E9E6E;
  --green-bg: #E4F2E8;
  --green-light: #B8DCC0;
  --purple: #8B6EAF;
  --purple-bg: #EDE4F5;
  --purple-light: #D0BFE4;
  --orange: #D47B4A;
  --orange-bg: #FDF0E8;
  --coral: #C26B6B;
  --coral-bg: #FAE8E8;
  --rose: #B85E7E;
  --rose-bg: #F8E8EE;
  --amber: #C4963A;
  --amber-bg: #FBF3E0;
  --teal: #4A8E8E;
  --teal-bg: #E0F2F2;
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-color: #0F0D0B;
  --bg-gradient: linear-gradient(180deg, #1A1614 0%, #0F0D0B 100%);
  --text-primary: #F5E6D3;
  --text-muted: #C8B8A8;
  --text-light: #948677;
  --border-color: #2D241C;
  --border-light: #241D17;
  --card-bg: #1A1614;
  --card-shadow: rgba(0,0,0,0.6);
  --hero-gradient: linear-gradient(170deg, #0F0D0B 0%, #1A1614 50%, #241D17 100%);
  --glass-bg: rgba(26, 22, 20, 0.8);
  --glass-border: rgba(245, 230, 211, 0.1);

  --cream: #0F0D0B;
  --sand: #2D241C;
  --sand-light: #241D17;
  --peach: #3D3024;
  --peach-deep: #D4915E;
  --gold: #F0B080;
  --gold-dark: #D4915E;
  --brown: #F5E6D3;
  --brown-light: #C8B8A8;
  --brown-muted: #948677;
  --white: #F5E6D3;

  /* Vibrant Accents for Dark Mode */
  --blue: #60A5FA;
  --blue-bg: rgba(96, 165, 250, 0.15);
  --blue-light: rgba(96, 165, 250, 0.1);
  --green: #4ADE80;
  --green-bg: rgba(74, 222, 128, 0.15);
  --green-light: rgba(74, 222, 128, 0.1);
  --purple: #C084FC;
  --purple-bg: rgba(192, 132, 252, 0.15);
  --purple-light: rgba(192, 132, 252, 0.1);
  --orange: #FB923C;
  --orange-bg: rgba(251, 146, 60, 0.15);
  --coral: #F87171;
  --coral-bg: rgba(248, 113, 113, 0.15);
  --rose: #F472B6;
  --rose-bg: rgba(244, 114, 182, 0.15);
  --amber: #FBBF24;
  --amber-bg: rgba(251, 191, 36, 0.15);
  --amber-light: rgba(251, 191, 36, 0.1);
  --teal: #2DD4BF;
  --teal-bg: rgba(45, 212, 191, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-color);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.5;
  transition: background .4s, color .4s;
}

/* ======= Theme Toggle ======= */
.theme-toggle {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 99px;
  padding: 4px;
  display: flex;
  gap: 2px;
  box-shadow: 0 8px 32px var(--card-shadow);
  opacity: 0;
  animation: fadeIn 1s 1.5s forwards;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.theme-btn {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.theme-btn:hover { color: var(--gold); }
.theme-btn.active {
  background: var(--gold);
  color: white;
  box-shadow: 0 4px 12px rgba(212, 145, 94, 0.3);
}
.theme-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* ======= Hero ======= */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  background: var(--hero-gradient);
  padding: 40px;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -10%; left: -10%;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212,145,94,.15) 0%, transparent 70%);
  filter: blur(60px);
  animation: float 20s infinite alternate ease-in-out;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -5%; right: -5%;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,127,191,.12) 0%, transparent 70%);
  filter: blur(60px);
  animation: float 25s infinite alternate-reverse ease-in-out;
}
@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 40px) scale(1.1); }
}

.hero-overline {
  font-size: 14px; font-weight: 600;
  letter-spacing: 4px; text-transform: uppercase;
  color: var(--gold); margin-bottom: 24px;
  opacity: 0; animation: fadeUp .8s .2s forwards;
}
.hero h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(44px, 7vw, 92px);
  line-height: 1.05; color: var(--text-primary);
  margin-bottom: 16px;
  opacity: 0; animation: fadeUp .8s .4s forwards;
  letter-spacing: -1px;
}
.hero-subtitle {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(22px, 3.5vw, 36px);
  color: var(--text-muted); margin-bottom: 16px;
  opacity: 0; animation: fadeUp .8s .5s forwards;
}
.hero-sub {
  font-size: clamp(17px, 2.2vw, 22px);
  color: var(--text-light); max-width: 700px;
  line-height: 1.6; margin-bottom: 56px;
  opacity: 0; animation: fadeUp .8s .6s forwards;
}
.hero-tags {
  display: flex; gap: 14px; flex-wrap: wrap;
  justify-content: center;
  opacity: 0; animation: fadeUp .8s .8s forwards;
}
.tag {
  padding: 10px 24px; border-radius: 100px;
  font-size: 14px; font-weight: 600;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
  border: 1px solid transparent;
}
.tag:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  border-color: rgba(255,255,255,0.2);
}

.scroll-hint {
  position: absolute; bottom: 40px;
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  color: var(--text-light); font-size: 14px;
  opacity: 0; animation: fadeUp .8s 1.2s forwards;
}
.scroll-arrow {
  width: 24px; height: 24px;
  border-right: 2.5px solid var(--text-light);
  border-bottom: 2.5px solid var(--text-light);
  transform: rotate(45deg);
  animation: bounce 2s infinite;
}

/* ======= Scrolly ======= */
.scrolly-container {
  position: relative;
  display: flex;
  background: var(--bg-gradient);
}
.scrolly-diagram {
  position: sticky; top: 0;
  width: 62%; height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px 18px 12px 24px; z-index: 1;
  background: transparent;
}
.scrolly-text { width: 38%; position: relative; z-index: 2; }
.text-step {
  min-height: 100vh;
  display: flex; align-items: center;
  padding: 120px 64px 120px 40px;
}
.text-step-inner {
  opacity: 0; transform: translateY(30px);
  transition: opacity 1s cubic-bezier(.215,.61,.355,1),
              transform 1s cubic-bezier(.215,.61,.355,1);
  will-change: transform, opacity;
}
.text-step-inner.visible { opacity: 1; transform: translateY(0); }
.step-label {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 700;
  letter-spacing: 3px; text-transform: uppercase;
  margin-bottom: 20px;
}
.step-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.text-step h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.15; margin-bottom: 20px;
  color: var(--text-primary);
}
.text-step .desc {
  font-size: 17px; line-height: 1.75;
  color: var(--text-muted); margin-bottom: 20px;
}
.text-step .desc strong { color: var(--text-primary); }
.text-step .desc code {
  background: var(--sand-light); padding: 3px 8px;
  border-radius: 6px; color: var(--gold-dark);
  font-family: 'JetBrains Mono', monospace; font-size: 14px;
}
.callout {
  padding: 24px 28px; border-radius: 20px;
  font-size: 15px; line-height: 1.7; margin-top: 24px;
  border: 1px solid var(--border-light);
  background: var(--card-bg);
  box-shadow: 0 20px 40px var(--card-shadow);
}
.callout strong { display: block; margin-bottom: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; }

.risk-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4em; height: 1.4em; border-radius: 50%;
  background: var(--coral); color: white;
  font-family: 'DM Serif Display', serif;
  font-size: 0.85em; font-weight: 700;
  vertical-align: baseline; margin-right: 6px;
}

/* ======= Diagram ======= */
.diagram-svg {
  width: 100%; height: 100%;
  max-width: 1100px; max-height: 960px;
  filter: drop-shadow(0 30px 60px var(--card-shadow));
}
.diagram-svg text { font-family: 'DM Sans', sans-serif; transition: fill .4s; }
.diagram-svg .mono { font-family: 'JetBrains Mono', monospace; }
.diagram-svg .tiny { font-size: 10px; }
.diagram-svg .small { font-size: 11px; }
.diagram-svg .label { letter-spacing: 1.6px; font-weight: 800; }
.diagram-svg .layer {
  opacity: 0;
  transition: opacity .8s cubic-bezier(.23,1,.32,1);
}
.diagram-svg .layer.show { opacity: 1; }
.diagram-svg .layer.highlight { animation: layerPulse 1.5s ease-out; }
/* L4inner transform driven by scroll — no CSS transition needed */

/* ======= Post-scrolly sections ======= */
.section {
  min-height: auto;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 140px 60px 120px;
  background: var(--bg-color);
}
.section-inner {
  max-width: 1280px; width: 100%;
  opacity: 0; transform: translateY(60px);
  transition: opacity 1s cubic-bezier(.23,1,.32,1),
              transform 1s cubic-bezier(.23,1,.32,1);
}
.section-inner.visible { opacity: 1; transform: translateY(0); }
.section-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(36px, 5vw, 60px);
  line-height: 1.1; margin-bottom: 16px;
  color: var(--text-primary);
}
.section-subtitle {
  font-size: clamp(17px, 2vw, 22px);
  color: var(--text-muted); max-width: 750px;
  line-height: 1.6; margin-bottom: 56px;
}
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 32px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.grid-2x2 { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }

.info-card {
  background: var(--card-bg); border-radius: 24px; padding: 36px;
  border: 1px solid var(--border-light);
  box-shadow: 0 24px 48px var(--card-shadow);
  transition: all .4s cubic-bezier(0.4, 0, 0.2, 1);
}
.info-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 32px 64px var(--card-shadow);
  border-color: var(--gold);
}
.card-mark {
  display: inline-block;
  margin-bottom: 16px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--border-light);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--gold);
}
.info-card h3 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 24px; margin-bottom: 12px;
  color: var(--text-primary);
  line-height: 1.2;
}
.info-card .items {
  font-size: 15px; line-height: 1.7;
  color: var(--text-muted); margin-top: 18px;
}
.info-card .items div { padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.info-card .items div:last-child { border-bottom: none; }

.eval-item {
  display: flex; align-items: flex-start; gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-light);
}
.eval-num {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Serif Display', serif;
  font-size: 19px; color: white; flex-shrink: 0;
  box-shadow: 0 8px 16px var(--card-shadow);
}
.eval-content h3 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 20px; margin-bottom: 4px;
  color: var(--text-primary);
}
.eval-content p { font-size: 15px; color: var(--text-muted); line-height: 1.5; }

.compare-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 40px;
}
.compare-card {
  padding: 28px;
  border-radius: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  box-shadow: 0 16px 32px var(--card-shadow);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-muted);
}
.compare-card strong {
  display: block;
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 18px;
  font-family: 'DM Serif Display', serif;
}

.layer-bar {
  display: flex; align-items: center;
  padding: 18px 28px; border-radius: 16px;
  border-left: 6px solid; background: var(--card-bg);
  box-shadow: 0 10px 20px var(--card-shadow);
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
  margin-bottom: 12px;
}
.layer-bar:hover {
  transform: translateX(12px);
  box-shadow: 0 15px 30px var(--card-shadow);
}
.layer-bar .ln { font-weight: 700; font-size: 16px; min-width: 220px; color: var(--text-primary); }
.layer-bar .ld { font-size: 14px; color: var(--text-muted); }

.nav-dots {
  position: fixed; right: 28px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  z-index: 100;
}
.nav-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border-color); cursor: pointer;
  border: 2px solid transparent; padding: 0;
  flex-shrink: 0;
}
.nav-dot:hover { background: var(--gold); transform: scale(1.3); }
.nav-dot.active { background: var(--gold); transform: scale(1.4); border-color: var(--card-bg); box-shadow: 0 0 8px rgba(212,145,94,.4); }

/* Fancy nav pills for scrolly step groups */
.nav-pill {
  display: flex; flex-direction: column;
  border-radius: 99px; overflow: hidden;
  background: var(--border-color);
  gap: 1px; padding: 1px;
  flex-shrink: 0;
}
.nav-pill-seg {
  width: 8px; height: 8px;
  background: var(--border-light);
  cursor: pointer; border: none; padding: 0;
  position: relative;
}
.nav-pill-seg:first-child { border-radius: 99px 99px 0 0; }
.nav-pill-seg:last-child { border-radius: 0 0 99px 99px; }
.nav-pill-seg:only-child { border-radius: 99px; }
.nav-pill-seg:hover { background: var(--gold); }
.nav-pill-seg.active {
  background: var(--gold);
  height: 14px;
  box-shadow: 0 0 6px rgba(212,145,94,.5);
}
.nav-pill.group-active {
  box-shadow: 0 0 10px rgba(212,145,94,.25);
}

/* ======= Footer ======= */
.footer {
  text-align: center; padding: 40px 24px 48px;
  background: var(--bg-gradient);
  border-top: 1px solid var(--border-light);
}
.footer a { color: var(--gold); text-decoration: none; font-weight: 600; transition: color .2s; }
.footer a:hover { color: var(--gold-dark); text-decoration: underline; }
.share-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 28px; border-radius: 12px;
  color: #FFFFFF !important; text-decoration: none; font-size: 14px; font-weight: 700;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px var(--card-shadow);
  border: 1px solid rgba(255,255,255,0.1);
}
.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--card-shadow);
  filter: brightness(1.1);
  text-decoration: none;
  color: #FFFFFF !important;
}
.share-btn.linkedin { background: #0077b5; }
.share-btn.x { background: #000000; }
[data-theme="dark"] .share-btn.x { background: #24292e; border-color: rgba(255,255,255,0.05); }

/* Refined Dark Mode Gradient Overrides (merged into main dark block above) */
.footer-credit {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass-bg);
  font-size: 14px;
  color: var(--text-muted);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-top: 20px;
  box-shadow: 0 10px 30px var(--card-shadow);
}
.footer-credit a {
  color: var(--text-primary);
}
.footer-plus {
  color: var(--gold);
  font-weight: 700;
}

/* ======= Animations ======= */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bounce {
  0%,20%,50%,80%,100% { transform: rotate(45deg) translateY(0); }
  40%  { transform: rotate(45deg) translateY(-10px); }
  60%  { transform: rotate(45deg) translateY(-5px); }
}
@keyframes layerPulse {
  0%   { filter: brightness(1) saturate(1); }
  30%  { filter: brightness(1.3) saturate(1.2) drop-shadow(0 0 15px var(--gold)); }
  100% { filter: brightness(1) saturate(1); }
}

/* ======= Version & Credits ======= */
.hero-version {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.2em;
  font-weight: 400;
  color: var(--text-light);
  opacity: 0.4;
  vertical-align: baseline;
  letter-spacing: 0.5px;
}
.hero-version-mobile {
  display: none;
  position: absolute;
  top: 16px;
  left: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-light);
  opacity: 0.4;
  letter-spacing: 1px;
}
.version-badge {
  position: fixed;
  bottom: 16px;
  right: 16px;
  font-size: 11px;
  color: var(--text-light);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 90;
  letter-spacing: 1px;
}
.version-badge.show {
  opacity: 0.4;
}
.footer-credits {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 8px;
}
.footer-version {
  font-size: 12px;
  color: var(--text-light);
  opacity: 0.5;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

/* ======= Accessibility ======= */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ======= Mobile ======= */
@media (max-width: 900px) {
  .theme-toggle {
    position: absolute;
    top: 16px; right: 16px;
    z-index: 2;
  }
  .hero { position: relative; }
  .hero {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0 24px 64px;
    padding-top: max(60px, 15vh);
    justify-content: flex-start;
  }
  .hero::before, .hero::after { display: none; }
  .hero h1 { font-size: clamp(36px, 10vw, 56px); margin-bottom: 12px; }
  .hero-version { display: none; }
  .hero-version-mobile { display: block; }
  .hero-subtitle { font-size: clamp(18px, 5vw, 26px); margin-bottom: 12px; }
  .hero-sub { font-size: 16px; margin-bottom: 32px; }
  .hero-overline { margin-bottom: 20px; font-size: 12px; }
  .hero-tags { gap: 10px; }
  .tag { padding: 8px 18px; font-size: 13px; }

  .scrolly-container { flex-direction: column; }
  .scrolly-diagram {
    position: sticky;
    top: 0;
    width: 100%;
    height: 38vh;
    min-height: 240px;
    padding: 4px 6px 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    overflow: hidden;
  }
  .scrolly-diagram .diagram-svg {
    max-height: none;
    width: 100%;
    height: 100%;
  }
  .scrolly-text { width: 100%; }
  .text-step { min-height: 65vh; padding: 40px 24px; scroll-margin-top: 48vh; }
  .text-step h2 { font-size: 28px; }

  .section { padding: 100px 24px 80px; min-height: auto; }
  .grid-3, .grid-4, .grid-2x2, .compare-band { grid-template-columns: 1fr; gap: 24px; }
  
  .eval-item { gap: 16px; padding: 14px 0; }
  .eval-num { width: 32px; height: 32px; font-size: 15px; }
  .eval-content h3 { font-size: 17px; margin-bottom: 2px; }
  .eval-content p { font-size: 14px; line-height: 1.4; }

  .layer-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .layer-bar .ln { min-width: 0; }
  .nav-dots { display: none; }
}
