/* ==========================================================================
   AI Media Buying Framework — Design System
   Shared across hub page + 7 content parts
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Variables & Reset
   -------------------------------------------------------------------------- */

:root {
  /* Colors — Primary */
  --blue: #2563eb;
  --blue-light: #3b82f6;
  --blue-dark: #1d4ed8;
  --blue-bg: #eff6ff;
  --blue-10: rgba(37, 99, 235, 0.1);

  /* Colors — Accents */
  --violet: #7c3aed;
  --violet-bg: #f5f3ff;
  --violet-10: rgba(124, 58, 237, 0.1);
  --green: #059669;
  --green-bg: #ecfdf5;
  --green-10: rgba(5, 150, 105, 0.1);
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-10: rgba(217, 119, 6, 0.1);
  --rose: #e11d48;
  --rose-bg: #fff1f2;
  --rose-10: rgba(225, 29, 72, 0.1);
  --cyan: #0891b2;
  --cyan-bg: #ecfeff;
  --cyan-10: rgba(8, 145, 178, 0.1);
  --gold: #ca8a04;
  --gold-bg: #fefce8;

  /* Neutrals */
  --bg: #fafafa;
  --white: #ffffff;
  --dark: #0f172a;
  --dark-2: #1e293b;
  --dark-3: #334155;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --text: #1e293b;
  --text-subtle: #64748b;
  --text-muted: #94a3b8;

  /* Typography */
  --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Layout */
  --sidebar-width: 280px;
  --topbar-height: 56px;
  --content-max: 780px;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--blue);
  color: var(--white);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}


/* --------------------------------------------------------------------------
   2. Password Gate
   -------------------------------------------------------------------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(37, 99, 235, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(124, 58, 237, 0.06) 0%, transparent 50%);
}

.gate.hidden {
  display: none;
}

.gate-box {
  width: 100%;
  max-width: 400px;
  padding: var(--space-2xl);
  text-align: center;
}

.gate-brand {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gray-500);
  margin-bottom: var(--space-xl);
}

.gate-lock {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(var(--blue), var(--violet), var(--cyan), var(--blue));
  animation: spin 3s linear infinite;
}

.gate-lock-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}

.gate h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: var(--space-sm);
}

.gate h1 span {
  background: linear-gradient(135deg, var(--blue), var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gate-sub {
  font-size: 0.9rem;
  color: var(--gray-400);
  margin-bottom: var(--space-xl);
  line-height: 1.5;
}

.gate-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--green);
  margin-bottom: var(--space-lg);
}

.gate-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 1.5s ease-in-out infinite;
}

.gate-row {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.gate-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--dark-3);
  border-radius: var(--radius-md);
  background: var(--dark-2);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.gate-input:focus {
  border-color: var(--blue);
}

.gate-input::placeholder {
  color: var(--gray-600);
}

.gate-btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--blue), var(--violet));
  color: var(--white);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}

.gate-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.gate-btn:active {
  transform: translateY(0);
}

.gate-err {
  color: var(--rose);
  font-size: 0.8rem;
  margin-top: var(--space-sm);
  min-height: 1.2em;
}

.gate-footer {
  margin-top: var(--space-2xl);
  font-size: 0.75rem;
  color: var(--gray-600);
  line-height: 1.5;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}


/* --------------------------------------------------------------------------
   3. App Layout
   -------------------------------------------------------------------------- */

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--dark);
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gray-500);
  margin-bottom: var(--space-xs);
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.3;
}

.sidebar-title span {
  color: var(--blue-light);
}

/* Table of Contents */
.toc {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) 0;
}

.toc::-webkit-scrollbar {
  width: 3px;
}

.toc::-webkit-scrollbar-thumb {
  background: var(--dark-3);
  border-radius: var(--radius-full);
}

.toc-group {
  margin-bottom: var(--space-md);
}

.toc-part {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray-500);
  padding: var(--space-sm) var(--space-lg);
  margin-bottom: var(--space-xs);
}

.toc-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px var(--space-lg);
  color: var(--gray-400);
  text-decoration: none;
  font-size: 0.85rem;
  border-left: 2px solid transparent;
  transition: all 0.2s;
}

.toc-item:hover {
  color: var(--gray-200);
  background: rgba(255, 255, 255, 0.03);
}

.toc-item.active {
  color: var(--white);
  border-left-color: var(--blue);
  background: rgba(37, 99, 235, 0.08);
}

.toc-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--blue);
  min-width: 20px;
}

/* Sidebar Author */
.sidebar-author {
  padding: var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
  color: var(--gray-500);
  line-height: 1.5;
}

.sidebar-author strong {
  color: var(--gray-300);
  display: block;
}

/* Main Content Area */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-height);
  background: rgba(250, 250, 250, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 var(--space-xl);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: var(--space-sm);
  margin-right: var(--space-md);
  line-height: 1;
}

.current-section {
  font-size: 0.85rem;
  color: var(--text-subtle);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gray-200);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--violet));
  transition: width 0.3s ease;
}

/* Content */
.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl);
}


/* --------------------------------------------------------------------------
   4. Hero Section
   -------------------------------------------------------------------------- */

.hero {
  background: var(--dark);
  background-image:
    radial-gradient(ellipse at 30% 0%, rgba(37, 99, 235, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 100%, rgba(124, 58, 237, 0.08) 0%, transparent 50%);
  padding: var(--space-4xl) var(--space-xl);
  text-align: center;
  color: var(--white);
}

.hero-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--blue-light);
  border: 1px solid rgba(37, 99, 235, 0.3);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-lg);
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: var(--space-lg);
  color: var(--white);
}

.hero h1 span {
  background: linear-gradient(135deg, var(--blue-light), var(--violet), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-rule {
  width: 60px;
  height: 3px;
  background: var(--blue);
  margin: 0 auto var(--space-lg);
  border: none;
  border-radius: var(--radius-full);
}

.hero-lead {
  font-size: 1.1rem;
  color: var(--gray-400);
  max-width: 560px;
  margin: 0 auto var(--space-xl);
  line-height: 1.7;
}

.hero-meta {
  display: flex;
  justify-content: center;
  gap: var(--space-xl);
  flex-wrap: wrap;
}

.hero-meta span {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.hero-meta strong {
  color: var(--gray-300);
}


/* --------------------------------------------------------------------------
   5. Typography
   -------------------------------------------------------------------------- */

.section {
  padding: var(--space-3xl) 0;
}

.section + .section {
  border-top: 1px solid var(--gray-200);
}

/* Section Header */
.sh {
  margin-bottom: var(--space-xl);
}

.sh-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
}

.sh-label.blue   { color: var(--blue);   background: var(--blue-bg); }
.sh-label.green  { color: var(--green);  background: var(--green-bg); }
.sh-label.violet { color: var(--violet); background: var(--violet-bg); }
.sh-label.amber  { color: var(--amber);  background: var(--amber-bg); }
.sh-label.rose   { color: var(--rose);   background: var(--rose-bg); }
.sh-label.cyan   { color: var(--cyan);   background: var(--cyan-bg); }

.sh h2 {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-sm);
  line-height: 1.25;
}

.sh p {
  font-size: 1rem;
  color: var(--text-subtle);
  max-width: 600px;
}

h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  line-height: 1.3;
}

h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

p {
  margin-bottom: var(--space-md);
  line-height: 1.75;
}

ul, ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-lg);
}

li {
  margin-bottom: var(--space-sm);
  line-height: 1.65;
}

strong {
  font-weight: 600;
  color: var(--text);
}

a {
  color: var(--blue);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--blue-dark);
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--rose);
}

pre {
  background: var(--dark);
  color: var(--gray-300);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-lg);
  font-size: 0.85rem;
  line-height: 1.6;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
}

.code-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-500);
  margin-bottom: var(--space-sm);
}


/* --------------------------------------------------------------------------
   6. Callout Boxes
   -------------------------------------------------------------------------- */

.callout {
  border-left: 3px solid var(--gray-300);
  background: var(--gray-50);
  padding: var(--space-lg);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: var(--space-lg);
}

.callout-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Variants */
.callout.tip {
  border-left-color: var(--blue);
  background: var(--blue-bg);
}
.callout.tip .callout-title { color: var(--blue); }

.callout.success {
  border-left-color: var(--green);
  background: var(--green-bg);
}
.callout.success .callout-title { color: var(--green); }

.callout.warning {
  border-left-color: var(--amber);
  background: var(--amber-bg);
}
.callout.warning .callout-title { color: var(--amber); }

.callout.danger {
  border-left-color: var(--rose);
  background: var(--rose-bg);
}
.callout.danger .callout-title { color: var(--rose); }

.callout.insight {
  border-left-color: var(--violet);
  background: var(--violet-bg);
}
.callout.insight .callout-title { color: var(--violet); }

.callout.real-talk {
  border-left-color: var(--gold);
  background: var(--gold-bg);
}
.callout.real-talk .callout-title { color: var(--gold); }


/* --------------------------------------------------------------------------
   7. Step Cards
   -------------------------------------------------------------------------- */

.step-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  transition: box-shadow 0.2s;
}

.step-card:hover {
  box-shadow: var(--shadow-sm);
}

.step-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: var(--space-xs);
}

.step-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.step-desc {
  font-size: 0.9rem;
  color: var(--text-subtle);
  line-height: 1.65;
}

.step-desc:last-child {
  margin-bottom: 0;
}


/* --------------------------------------------------------------------------
   8. Sandbox — Interactive Demo Container
   -------------------------------------------------------------------------- */

.sandbox {
  background: var(--dark);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-lg);
}

.sandbox-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sandbox-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.sandbox-dot.red    { background: #ef4444; }
.sandbox-dot.yellow { background: #eab308; }
.sandbox-dot.green  { background: #22c55e; }

.sandbox-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--gray-500);
  flex: 1;
  margin-left: var(--space-sm);
}

.sandbox-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.sandbox-badge.before {
  color: var(--rose);
  background: rgba(225, 29, 72, 0.15);
}

.sandbox-badge.after {
  color: var(--green);
  background: rgba(5, 150, 105, 0.15);
}

.sandbox-badge.live {
  color: var(--blue-light);
  background: rgba(37, 99, 235, 0.15);
}

.sandbox-body {
  padding: var(--space-lg);
}

.sandbox-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.sandbox-half {
  padding: var(--space-lg);
}

.sandbox-half + .sandbox-half {
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.sandbox-half-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-md);
}

.sandbox-half-label.old { color: var(--rose); }
.sandbox-half-label.new { color: var(--green); }

/* Sandbox Content Elements */
.sb-line {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.8;
}

.sb-line .prompt { color: var(--blue-light); }
.sb-line .cmd    { color: var(--white); }
.sb-line .out    { color: #34d399; }
.sb-line .err    { color: #f87171; }

.sb-comment {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--gray-600);
  font-style: italic;
  line-height: 1.6;
  margin-bottom: var(--space-sm);
}

.sb-highlight {
  color: #fbbf24;
  font-weight: 700;
}

.sb-block {
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.sb-result {
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin-top: var(--space-md);
}

.sb-result.win {
  border: 1px dashed rgba(5, 150, 105, 0.4);
  background: rgba(5, 150, 105, 0.06);
}

.sb-result.lose {
  border: 1px dashed rgba(225, 29, 72, 0.4);
  background: rgba(225, 29, 72, 0.06);
}

.sb-metric {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
}

.sb-metric.good    { color: #34d399; }
.sb-metric.bad     { color: #f87171; }
.sb-metric.neutral { color: var(--gray-400); }

/* Animated Sandbox */
.sandbox-animated {
  position: relative;
}

.sandbox-animated .sandbox-replay {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--gray-400);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 2;
}

.sandbox-animated .sandbox-replay:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
}

.sandbox-animated.complete .sandbox-replay {
  opacity: 1;
}

.sandbox-animated.idle .sandbox-body {
  opacity: 0.4;
}

.sandbox-animated.playing .sandbox-body {
  opacity: 1;
  transition: opacity 0.3s;
}

.sandbox-animated.complete .sandbox-body {
  opacity: 1;
}

/* Typed Text Effect */
.sb-typed {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--white);
  display: inline;
}

.sb-typed .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--blue-light);
  margin-left: 1px;
  vertical-align: text-bottom;
  animation: cursor-blink 0.8s step-end infinite;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* Counter Animation */
.sb-counter {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--white);
  display: inline-block;
  transition: transform 0.15s ease;
}

.sb-counter.counting {
  transform: scale(1.08);
}

/* Progress Track */
.sb-progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: var(--space-sm) 0;
}

.sb-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* Card Slide */
.sb-card-slide {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.sb-card-slide.visible {
  transform: translateY(0);
  opacity: 1;
}

/* Notification Slide-in */
.sb-notification {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--gray-300);
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.sb-notification.show {
  transform: translateX(0);
  opacity: 1;
  animation: slideInRight 0.4s ease forwards;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Fade Sequence */
.sb-fade-seq {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.sb-fade-seq.visible {
  opacity: 1;
}

/* Pulse Highlight */
.sb-pulse {
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.3); }
  70%  { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* Morph / Crossfade Container */
.sb-morph-container {
  position: relative;
  overflow: hidden;
}

.sb-morph-before,
.sb-morph-after {
  transition: opacity 0.5s ease;
}

.sb-morph-before {
  opacity: 1;
}

.sb-morph-after {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.sb-morph-container.morphed .sb-morph-before {
  opacity: 0;
}

.sb-morph-container.morphed .sb-morph-after {
  opacity: 1;
}

/* Flow Line */
.sb-flow-line {
  border-left: 2px dashed rgba(255, 255, 255, 0.1);
  margin-left: var(--space-md);
  padding-left: var(--space-md);
  padding-top: var(--space-sm);
  padding-bottom: var(--space-sm);
  position: relative;
}

.sb-flow-line::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}

.sb-flow-line::after {
  content: '';
  position: absolute;
  left: -5px;
  bottom: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}


/* --------------------------------------------------------------------------
   9. Feature Grid
   -------------------------------------------------------------------------- */

.feat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.feat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.feat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gray-300);
}

.feat-card:hover {
  box-shadow: var(--shadow-md);
}

.feat-card.c-blue::before   { background: var(--blue); }
.feat-card.c-violet::before { background: var(--violet); }
.feat-card.c-green::before  { background: var(--green); }
.feat-card.c-amber::before  { background: var(--amber); }
.feat-card.c-rose::before   { background: var(--rose); }
.feat-card.c-cyan::before   { background: var(--cyan); }

.feat-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.feat-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.feat-desc {
  font-size: 0.85rem;
  color: var(--text-subtle);
  line-height: 1.6;
}


/* --------------------------------------------------------------------------
   10. Misc Components
   -------------------------------------------------------------------------- */

/* Checklist */
.checklist {
  list-style: none;
  padding-left: 0;
  margin-bottom: var(--space-lg);
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
}

.check-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  margin-top: 2px;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--space-lg);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--space-xl) + 3px);
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid var(--bg);
}

.timeline-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.timeline-desc {
  font-size: 0.85rem;
  color: var(--text-subtle);
  line-height: 1.6;
}

/* Compare Table */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  font-size: 0.9rem;
}

.compare-table th {
  text-align: left;
  padding: 12px var(--space-md);
  background: var(--gray-100);
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--gray-200);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.compare-table td {
  padding: 12px var(--space-md);
  border-bottom: 1px solid var(--gray-200);
  color: var(--text-subtle);
}

.compare-table tr:nth-child(even) td {
  background: var(--gray-50);
}

.compare-table tr:hover td {
  background: var(--blue-bg);
}

/* CTA Banner */
.cta-banner {
  background: linear-gradient(135deg, var(--dark), var(--dark-2));
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  text-align: center;
  margin: var(--space-2xl) 0;
}

.cta-banner h3 {
  color: var(--white);
  margin-top: 0;
  margin-bottom: var(--space-sm);
}

.cta-banner p {
  color: var(--gray-400);
  max-width: 480px;
  margin: 0 auto var(--space-lg);
}

.cta-banner a {
  display: inline-block;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  color: var(--white);
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.15s;
}

.cta-banner a:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  text-decoration: none;
}


/* --------------------------------------------------------------------------
   11. Part Navigation
   -------------------------------------------------------------------------- */

.part-nav {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-top: 1px solid var(--gray-200);
  padding-top: var(--space-xl);
  margin-top: var(--space-3xl);
  gap: var(--space-lg);
}

.part-nav-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  transition: transform 0.15s;
}

.part-nav-link:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.part-nav-link.prev {
  text-align: left;
}

.part-nav-link.next {
  text-align: right;
  margin-left: auto;
}

.part-nav-label {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.part-nav-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  transition: color 0.2s;
}

.part-nav-link:hover .part-nav-title {
  color: var(--blue);
}

.part-nav-link.next .part-nav-title {
  color: var(--blue);
}

.part-nav-link.next:hover .part-nav-title {
  color: var(--blue-dark);
}


/* --------------------------------------------------------------------------
   12. Breadcrumb
   -------------------------------------------------------------------------- */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--text-subtle);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover {
  color: var(--blue);
  text-decoration: none;
}

.breadcrumb .sep {
  color: var(--gray-300);
  font-size: 0.7rem;
}

.breadcrumb .current {
  color: var(--text);
  font-weight: 600;
}


/* --------------------------------------------------------------------------
   13. Hub Page Cards
   -------------------------------------------------------------------------- */

.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.hub-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.2s, box-shadow 0.2s;
}

.hub-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gray-300);
}

.hub-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}

.hub-card.c-blue::before   { background: var(--blue); }
.hub-card.c-violet::before { background: var(--violet); }
.hub-card.c-green::before  { background: var(--green); }
.hub-card.c-amber::before  { background: var(--amber); }
.hub-card.c-rose::before   { background: var(--rose); }
.hub-card.c-cyan::before   { background: var(--cyan); }

.hub-num {
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--gray-200);
  line-height: 1;
  margin-bottom: var(--space-sm);
}

.hub-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.hub-desc {
  font-size: 0.85rem;
  color: var(--text-subtle);
  line-height: 1.6;
  margin-bottom: var(--space-md);
}

.hub-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hub-meta .difficulty {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--text-subtle);
}

.hub-progress {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--green);
  margin-left: auto;
}

.hub-progress .checkmark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
}


/* --------------------------------------------------------------------------
   14. Scroll Reveal
   -------------------------------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}


/* --------------------------------------------------------------------------
   15. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
  }

  .sidebar.open ~ .sidebar-overlay {
    display: block;
  }

  .menu-toggle {
    display: flex;
  }

  .main {
    margin-left: 0;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero-meta {
    gap: var(--space-md);
  }

  .content {
    padding: var(--space-lg) var(--space-md);
  }

  .feat-grid {
    grid-template-columns: 1fr;
  }

  .hub-grid {
    grid-template-columns: 1fr;
  }

  .sandbox-split {
    grid-template-columns: 1fr;
  }

  .sandbox-half + .sandbox-half {
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .sh h2 {
    font-size: 1.4rem;
  }

  .hero {
    padding: var(--space-2xl) var(--space-md);
  }

  .part-nav {
    flex-direction: column;
    gap: var(--space-md);
  }

  .part-nav-link.next {
    text-align: left;
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.6rem;
  }

  .sh h2 {
    font-size: 1.2rem;
  }

  h3 {
    font-size: 1.1rem;
  }

  .gate h1 {
    font-size: 1.3rem;
  }

  .gate-box {
    padding: var(--space-lg);
  }

  .gate-row {
    flex-direction: column;
  }

  .hub-num {
    font-size: 1.8rem;
  }

  .topbar {
    padding: 0 var(--space-md);
  }

  .compare-table {
    font-size: 0.8rem;
  }

  .compare-table th,
  .compare-table td {
    padding: 8px var(--space-sm);
  }
}
