/* ============================================================
   AI Capability OS — Marketing Site
   Design System: Capability Ledger (tokens mirror packages/ui/src/theme.css)
   Mobile-first: base rules target small screens; min-width queries layer
   up tablet (640px) and desktop (1024px) enhancements.
   ============================================================ */

:root {
  --bg: #0b1020;
  --surface: #11182a;
  --surface-raised: #172139;
  --surface-strong: #1d2944;
  --border: rgba(167, 181, 211, 0.22);
  --edge: rgba(167, 181, 211, 0.14);
  --fg: #f6f3e8;
  --fg-muted: #a8b2c7;
  --accent: #91a0ff;
  --accent-strong: #586ee8;
  --on-accent: #ffffff;
  --success: #58d7aa;
  --warning: #f2bd66;
  --danger: #ff7b83;
  --info: #7bc7ff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.32);
  --glow: 0 8px 24px rgba(88, 110, 232, 0.28);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;

  --touch-min: 44px;
  --header-h: 60px;
  --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-micro: 150ms;
  --dur-view: 240ms;

  --container: 1180px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f4ef;
  --surface: #fffefa;
  --surface-raised: #ffffff;
  --surface-strong: #e9edf7;
  --border: rgba(36, 59, 143, 0.2);
  --edge: rgba(36, 59, 143, 0.12);
  --fg: #161d2f;
  --fg-muted: #5f687b;
  --accent: #334fc2;
  --accent-strong: #243b8f;
  --on-accent: #ffffff;
  --success: #167a58;
  --warning: #8b5c08;
  --danger: #b4232d;
  --info: #176b99;
  --shadow-sm: 0 1px 2px rgba(24, 34, 61, 0.08);
  --shadow-md: 0 8px 28px rgba(24, 34, 61, 0.1);
  --shadow-lg: 0 20px 60px rgba(24, 34, 61, 0.14);
  --glow: 0 8px 24px rgba(36, 59, 143, 0.16);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f4ef;
    --surface: #fffefa;
    --surface-raised: #ffffff;
    --surface-strong: #e9edf7;
    --border: rgba(36, 59, 143, 0.2);
    --edge: rgba(36, 59, 143, 0.12);
    --fg: #161d2f;
    --fg-muted: #5f687b;
    --accent: #334fc2;
    --accent-strong: #243b8f;
    --on-accent: #ffffff;
    --success: #167a58;
    --warning: #8b5c08;
    --danger: #b4232d;
    --info: #176b99;
    --shadow-sm: 0 1px 2px rgba(24, 34, 61, 0.08);
    --shadow-md: 0 8px 28px rgba(24, 34, 61, 0.1);
    --shadow-lg: 0 20px 60px rgba(24, 34, 61, 0.14);
    --glow: 0 8px 24px rgba(36, 59, 143, 0.16);
    color-scheme: light;
  }
}

/* ---------- Reset & Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(circle at 15% 8%, rgba(88, 110, 232, 0.16), transparent 45%),
    radial-gradient(circle at 85% 0%, rgba(88, 110, 232, 0.1), transparent 40%);
  pointer-events: none;
}
img, svg, canvas { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }

:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 3px solid color-mix(in oklab, var(--accent) 78%, white);
  outline-offset: 2px;
}
:where(a, button, [tabindex]) { scroll-margin-block: 5.5rem; }

@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;
    scroll-behavior: auto !important;
  }
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 1000;
  background: var(--accent-strong);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  transition: top var(--dur-micro) var(--ease-soft);
}
.skip-link:focus { top: 12px; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

.section { padding: 56px 0; }
.section-head { max-width: 640px; margin: 0 auto 32px; text-align: center; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: rgba(145, 160, 255, 0.12);
  border: 1px solid rgba(145, 160, 255, 0.25);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.section-head h2 { font-size: clamp(22px, 4vw, 30px); font-weight: 800; line-height: 1.3; }
.section-sub { margin-top: 10px; color: var(--fg-muted); font-size: 14px; line-height: 1.6; }

.accent-text {
  background: linear-gradient(135deg, var(--accent), var(--info));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch-min);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--dur-micro) var(--ease-soft), filter var(--dur-micro) var(--ease-soft), background var(--dur-micro);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff;
  box-shadow: var(--glow);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--fg);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--fg);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 15px; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

.icon-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--fg);
  cursor: pointer;
  font-size: 16px;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-micro), box-shadow var(--dur-micro);
}
.site-header.is-scrolled { border-bottom-color: var(--border); box-shadow: var(--shadow-sm); }
.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
}
.brand-mark { color: var(--accent); font-size: 18px; }
.primary-nav { display: none; gap: 22px; }
.primary-nav a {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 8px 0;
}
.primary-nav a:hover { color: var(--fg); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions .btn-primary { display: none; }
.nav-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--fg);
  font-size: 18px;
  cursor: pointer;
}

.mobile-nav {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  z-index: 190;
  background: var(--bg);
  padding: 20px;
  overflow-y: auto;
}
.mobile-nav[hidden] { display: none; }
.mobile-nav a {
  display: block;
  padding: 14px 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.mobile-nav .btn { margin-top: 20px; }

/* ---------- Hero ---------- */
.hero { padding: 40px 0 32px; }
.hero-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  gap: 32px;
}
.hero-copy h1 { font-size: clamp(28px, 6vw, 46px); font-weight: 800; line-height: 1.25; letter-spacing: -0.01em; }
.hero-sub { margin-top: 16px; font-size: 15px; color: var(--fg-muted); line-height: 1.65; max-width: 54ch; }
.hero-cta-row { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; }
.hero-cta-row .btn { width: 100%; }
.trust-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.trust-row li { font-size: 12px; color: var(--fg-muted); line-height: 1.5; }
.trust-row b { display: block; font-size: 19px; color: var(--accent); font-weight: 800; }

.hero-visual { display: flex; justify-content: center; }
.preview-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.preview-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong);
}
.preview-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.preview-title { margin-left: 6px; font-size: 12px; font-weight: 700; color: var(--fg-muted); }
.preview-body { padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
#heroRadarCanvas { width: 200px; height: 200px; }
.preview-stats { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.preview-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
}
.preview-stat-row .k { color: var(--fg-muted); }
.preview-stat-row .v { font-weight: 700; color: var(--success); }
.preview-stat-row .v.hash { font-family: var(--font-mono); font-size: 11px; }

/* ---------- Demo / Interactive Game Section ---------- */
.demo-section { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.challenge-picker { display: flex; flex-direction: column; gap: 10px; max-width: 720px; margin: 0 auto; }
.challenge-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--touch-min);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--fg);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.challenge-tab .ico { font-size: 18px; }
.challenge-tab.active { border-color: var(--accent); background: rgba(145, 160, 255, 0.1); color: var(--accent); }
.challenge-card {
  max-width: 720px;
  margin: 18px auto 0;
  padding: 22px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.challenge-card .cc-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--fg-muted); margin-bottom: 8px; }
.challenge-card .cc-meta span { background: var(--surface-strong); padding: 3px 9px; border-radius: 999px; }
.challenge-card h3 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.challenge-card p { color: var(--fg-muted); font-size: 13px; line-height: 1.6; }
.cc-concepts { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.cc-concepts span { font-size: 11px; background: rgba(145, 160, 255, 0.14); color: var(--accent); padding: 4px 10px; border-radius: 999px; }
.challenge-card .btn { margin-top: 6px; width: 100%; }
.demo-note { text-align: center; font-size: 12px; color: var(--fg-muted); margin-top: 16px; }

/* ---------- Feature sections ---------- */
.feature-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.feature-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
}
.feature-card .f-icon { font-size: 26px; margin-bottom: 10px; }
.feature-card h3 { font-size: 17px; font-weight: 800; margin-bottom: 8px; }
.feature-card p.f-desc { color: var(--fg-muted); font-size: 13px; line-height: 1.6; }
.feature-card details { margin-top: 14px; }
.feature-card summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}
.feature-card summary::-webkit-details-marker { display: none; }
.feature-card summary::after { content: "+"; margin-left: auto; font-size: 16px; }
.feature-card details[open] summary::after { content: "−"; }
.feature-card .f-detail { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.feature-card .f-detail ul { display: flex; flex-direction: column; gap: 8px; }
.feature-card .f-detail li { font-size: 12.5px; color: var(--fg-muted); line-height: 1.55; display: flex; gap: 8px; }
.feature-card .f-detail li b { color: var(--fg); }
.feature-card .f-spec { margin-top: 10px; font-size: 11px; color: var(--fg-muted); line-height: 1.6; background: var(--surface); border: 1px solid var(--edge); border-radius: var(--radius-sm); padding: 10px 12px; }

/* ---------- Compare section ---------- */
.compare-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.compare-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; }
.compare-old { font-size: 12px; font-weight: 700; color: var(--fg-muted); }
.compare-old b { display: block; font-size: 14px; color: var(--fg); font-weight: 800; margin-top: 4px; }
.compare-flaw { margin-top: 10px; font-size: 12.5px; color: var(--danger); line-height: 1.55; }
.compare-new { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.compare-new-badge { display: inline-block; font-size: 10px; font-weight: 800; color: var(--success); background: rgba(88, 215, 170, 0.14); padding: 3px 9px; border-radius: 999px; margin-bottom: 6px; }
.compare-new p { font-size: 13px; line-height: 1.6; }

/* ---------- Courses gallery ---------- */
.domain-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.domain-tabs::-webkit-scrollbar { display: none; }
.d-tab {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 9px 16px;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.d-tab.active { border-color: var(--accent); background: rgba(145, 160, 255, 0.12); color: var(--accent); }
.course-grid { display: grid; gap: 14px; grid-template-columns: 1fr; margin-top: 20px; }
.course-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.course-card .lc-top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--fg-muted); }
.course-card .lc-badge { background: var(--surface-strong); padding: 3px 8px; border-radius: 6px; font-weight: 700; }
.course-card h4 { font-size: 15px; font-weight: 800; line-height: 1.4; }
.course-card .lc-sub { font-size: 12.5px; color: var(--fg-muted); line-height: 1.5; flex: 1; }
.course-card .lc-concepts { display: flex; gap: 6px; flex-wrap: wrap; }
.course-card .lc-concepts span { font-size: 10.5px; background: var(--surface); border: 1px solid var(--edge); color: var(--fg-muted); padding: 3px 8px; border-radius: 999px; }
.course-card .btn { margin-top: 4px; }
.gallery-more { text-align: center; margin-top: 20px; }

/* ---------- Final CTA band ---------- */
.final-cta { text-align: center; }
.final-cta-card {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px;
  background: linear-gradient(160deg, var(--surface-strong), var(--surface-raised));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.final-cta-card h2 { font-size: clamp(20px, 4vw, 28px); font-weight: 800; }
.final-cta-card p { margin-top: 10px; color: var(--fg-muted); font-size: 14px; }
.final-cta-card .btn { margin-top: 22px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 40px 0 max(24px, env(safe-area-inset-bottom)); background: var(--surface); }
.footer-grid { display: grid; gap: 28px; grid-template-columns: 1fr; margin-bottom: 28px; }
.footer-col h5 { font-size: 12px; font-weight: 800; color: var(--fg-muted); letter-spacing: 0.04em; margin-bottom: 12px; }
.footer-col a, .footer-col p { display: block; font-size: 13px; color: var(--fg-muted); text-decoration: none; margin-bottom: 8px; line-height: 1.6; }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { display: flex; flex-direction: column; gap: 10px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--fg-muted); }
.footer-bottom .link-row { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-bottom button { background: none; border: none; padding: 0; color: var(--fg-muted); font-size: 12px; text-decoration: underline; cursor: pointer; }

.privacy-section { padding-top: 24px; border-top: 1px solid var(--border); margin-top: 12px; }
.privacy-section h3 { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.privacy-section h4 { font-size: 13px; font-weight: 800; margin: 16px 0 6px; }
.privacy-section p, .privacy-section li { font-size: 12.5px; color: var(--fg-muted); line-height: 1.7; }
.privacy-section ul { padding-left: 18px; list-style: disc; }

/* ---------- Waitlist Dialog ---------- */
.game-dialog { border: none; padding: 0; border-radius: var(--radius-lg); background: var(--surface-raised); color: var(--fg); box-shadow: var(--shadow-lg); width: min(440px, calc(100vw - 32px)); max-height: min(88vh, 88dvh); overflow-y: auto; }
.game-dialog::backdrop { background: rgba(4, 6, 16, 0.7); backdrop-filter: blur(2px); }
.dialog-content { padding: 26px 22px; position: relative; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--fg-muted); font-size: 15px; cursor: pointer; }
.dialog-close:hover { color: var(--fg); border-color: var(--accent); }
.dialog-badge { display: inline-block; font-size: 11px; font-weight: 800; color: var(--accent); background: rgba(145, 160, 255, 0.14); padding: 4px 10px; border-radius: 999px; margin-bottom: 12px; }
.dialog-content h3 { font-size: 19px; font-weight: 800; line-height: 1.35; }
.dialog-sub { font-size: 13px; color: var(--fg-muted); margin: 8px 0 20px; line-height: 1.6; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; color: var(--fg-muted); }
.field {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
}
.field:focus { border-color: var(--accent); }
.consent-check { display: flex; align-items: flex-start; gap: 10px; font-size: 12px; color: var(--fg-muted); line-height: 1.5; margin: 16px 0; }
.consent-check input { margin-top: 3px; width: 16px; height: 16px; flex-shrink: 0; }
.consent-check a { color: var(--accent); text-decoration: underline; }
.cf-turnstile-wrap { margin: 14px 0; display: flex; justify-content: center; }
.form-status { margin-top: 12px; font-size: 13px; text-align: center; min-height: 18px; }
.form-status.ok { color: var(--success); }
.form-status.err { color: var(--danger); }

/* ---------- Consent bar ---------- */
.consent-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.consent-bar[hidden] { display: none; }
.consent-bar p { font-size: 12.5px; color: var(--fg-muted); line-height: 1.55; }
.consent-bar p a { color: var(--accent); }
.consent-actions { display: flex; gap: 8px; }
.consent-actions .btn { flex: 1; }

/* ---------- Sticky mobile CTA bar ---------- */
.mobile-cta-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 220;
  padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform var(--dur-view) var(--ease-soft);
}
.mobile-cta-bar.is-visible { transform: translateY(0); }
.mobile-cta-bar .btn { width: 100%; }

/* ---------- Toast ---------- */
#toast-container { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 420px); }
.toast {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.ok { border-color: rgba(88, 215, 170, 0.4); }
.toast.err { border-color: rgba(255, 123, 131, 0.4); }
.toast .btn { flex-shrink: 0; }

/* ---------- Lesson modal ---------- */
.lesson-modal { position: fixed; inset: 0; z-index: 300; background: rgba(4, 6, 16, 0.78); display: flex; align-items: center; justify-content: center; padding: 0; }
.lesson-modal[hidden] { display: none; }
.lesson-modal-dialog { width: 100%; height: 100%; background: var(--bg); }
.lesson-modal-dialog iframe { width: 100%; height: 100%; border: none; display: block; }

/* ============================================================
   Tablet (>= 640px)
   ============================================================ */
@media (min-width: 640px) {
  .hero-cta-row { flex-direction: row; }
  .hero-cta-row .btn { width: auto; }
  .trust-row { grid-template-columns: repeat(4, 1fr); }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .compare-grid { grid-template-columns: repeat(2, 1fr); }
  .course-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-bottom { flex-direction: row; align-items: center; justify-content: space-between; }
  .challenge-picker { flex-direction: row; }
  .challenge-tab { flex-direction: column; align-items: flex-start; }
  .lesson-modal { padding: 24px; }
  .lesson-modal-dialog { max-width: 880px; max-height: 720px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
}

/* ============================================================
   Desktop (>= 1024px)
   ============================================================ */
@media (min-width: 1024px) {
  .section { padding: 88px 0; }
  .primary-nav { display: flex; }
  .header-actions .btn-primary { display: inline-flex; }
  .nav-toggle { display: none; }
  .mobile-cta-bar { display: none; }

  .hero { padding: 72px 0 60px; }
  .hero-inner { grid-template-columns: 1.05fr 0.95fr; align-items: center; gap: 48px; }
  .hero-copy h1 { max-width: 16ch; }
  .hero-visual { justify-content: flex-end; }

  .feature-grid { grid-template-columns: repeat(3, 1fr); }
  .compare-grid { grid-template-columns: repeat(2, 1fr); }
  .course-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1280px) {
  .course-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   PRODUCT TOUR GAME
   ============================================================ */

.tour-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.tour-frame {
  max-width: 840px;
  margin: 0 auto;
}

/* --- Stage Rail --- */
.tour-rail {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
  padding: 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tour-rail::-webkit-scrollbar { display: none; }

.tr-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.tr-dot {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  transition: all 0.35s var(--ease-soft);
  position: relative;
  z-index: 2;
}
.tr-stage.active .tr-dot {
  border-color: var(--accent);
  background: rgba(145,160,255,0.15);
  box-shadow: 0 0 0 4px rgba(145,160,255,0.15), 0 0 20px rgba(145,160,255,0.3);
  animation: trPulse 2.2s ease-in-out infinite;
}
.tr-stage.done .tr-dot {
  border-color: var(--success);
  background: rgba(88,215,170,0.12);
  box-shadow: 0 0 12px rgba(88,215,170,0.2);
}
@keyframes trPulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(145,160,255,0.12), 0 0 16px rgba(145,160,255,0.22); }
  50%      { box-shadow: 0 0 0 7px rgba(145,160,255,0.08), 0 0 28px rgba(145,160,255,0.4); }
}

.tr-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--fg-muted);
  text-align: center;
  white-space: nowrap;
  padding: 0 2px;
}
.tr-stage.active .tr-label { color: var(--accent); }
.tr-stage.done .tr-label { color: var(--success); }

.tr-connector {
  flex: 1;
  height: 2px;
  min-width: 32px;
  max-width: 80px;
  background: var(--border);
  margin-top: 22px; /* vertically align with dot center */
  align-self: flex-start;
  transition: background 0.6s ease;
}
.tr-connector.done { background: var(--success); }

/* --- Stage Area --- */
.tour-stage-area {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 320px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.tour-stage-area.ts-out {
  opacity: 0;
  transform: translateX(-18px);
}
.tour-stage-area.ts-in {
  opacity: 0;
  transform: translateX(18px);
}

/* Stage header */
.ts-header { margin-bottom: 18px; }
.ts-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 800;
  color: var(--accent);
  background: rgba(145,160,255,0.13);
  border: 1px solid rgba(145,160,255,0.22);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.ts-title { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.ts-sub { font-size: 12.5px; color: var(--fg-muted); line-height: 1.55; }

/* --- Stage 0: Compile --- */
.compile-upload-zone {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 16px 0 20px;
}
.upload-file {
  width: 90px;
  height: 80px;
  border-radius: var(--radius-md);
  border: 2px dashed rgba(167,181,211,0.35);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s var(--ease-soft);
  font-size: 10px;
  font-weight: 700;
  color: var(--fg-muted);
  user-select: none;
}
.upload-file:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(145,160,255,0.07);
  transform: translateY(-2px);
}
.upload-file.uploaded {
  border-color: var(--success);
  border-style: solid;
  background: rgba(88,215,170,0.08);
  color: var(--success);
}
.upload-file .uf-icon { font-size: 24px; }
.upload-file .uf-name { font-size: 9px; font-family: var(--font-mono); text-align: center; }

.pipeline-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}
.pipeline-stage {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.28s ease, transform 0.28s ease, border-color 0.3s ease, background 0.3s ease;
}
.pipeline-stage.ps-visible { opacity: 1; transform: translateX(0); }
.pipeline-stage.ps-done {
  border-color: rgba(88,215,170,0.35);
  background: rgba(88,215,170,0.05);
}
.ps-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.ps-text { flex: 1; color: var(--fg-muted); }
.ps-text b { color: var(--fg); }
.ps-bar { width: 60px; height: 3px; background: var(--border); border-radius: 99px; overflow: hidden; flex-shrink: 0; }
.ps-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); width: 0; border-radius: 99px; transition: width 0.55s ease; }

.gate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--fg-muted);
  margin: 10px 0 4px;
}
.gate-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.gate-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}
.gate-dot.pass {
  background: var(--success);
  box-shadow: 0 0 4px rgba(88,215,170,0.5);
}
.compile-result-bar {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  padding: 10px 14px;
  background: rgba(88,215,170,0.08);
  border: 1px solid rgba(88,215,170,0.25);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--success);
  font-weight: 700;
  display: none;
}

/* --- Stage 1: Socratic --- */
.soc-game { display: flex; flex-direction: column; gap: 14px; }

.soc-chat-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
}
.soc-bubble {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: bubblePop 0.3s var(--ease-soft);
}
@keyframes bubblePop {
  from { opacity: 0; transform: scale(0.95) translateY(5px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.soc-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-raised); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.soc-msg {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
  padding: 9px 13px;
  font-size: 12.5px;
  line-height: 1.55;
  flex: 1;
}
.soc-bubble.user-bubble .soc-avatar {
  order: 2;
  background: rgba(145,160,255,0.12);
  border-color: rgba(145,160,255,0.3);
}
.soc-bubble.user-bubble .soc-msg {
  border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
  background: rgba(145,160,255,0.08);
  border-color: rgba(145,160,255,0.2);
}

.soc-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.soc-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg); font-size: 13px; text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
  line-height: 1.45;
}
.soc-opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(145,160,255,0.07);
}
.soc-opt.correct { background: rgba(88,215,170,0.1); border-color: var(--success); color: var(--success); }
.soc-opt.wrong   { background: rgba(255,123,131,0.1); border-color: var(--danger); color: var(--danger); }
.soc-opt-letter { font-weight: 800; color: var(--accent); width: 18px; flex-shrink: 0; font-size: 12px; }

.soc-scaffold-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: none; border: none; padding: 4px 0; cursor: pointer;
}
.soc-scaffold-hint {
  background: var(--surface);
  border: 1px solid rgba(145,160,255,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px; color: var(--fg-muted); line-height: 1.55;
  display: none;
}
.soc-scaffold-hint.open {
  display: block;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Stage 2: Passport --- */
.passport-stage {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.passport-neo-card {
  width: 100%; max-width: 420px;
  background: linear-gradient(150deg, var(--surface-strong) 0%, var(--surface-raised) 60%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow:
    0 24px 60px rgba(0,0,0,0.4),
    0 0 40px rgba(88,110,232,0.1),
    inset 0 1px 0 rgba(255,255,255,0.04);
  position: relative; overflow: hidden;
}
.passport-neo-card::before {
  content: '';
  position: absolute; top: -40%; right: -25%;
  width: 70%; height: 80%;
  background: radial-gradient(ellipse, rgba(88,110,232,0.18), transparent 70%);
  pointer-events: none;
}
.pnc-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.pnc-brand { font-size: 10px; font-weight: 800; color: var(--accent); letter-spacing: 0.05em; }
.pnc-seal { font-size: 26px; opacity: 0; transition: opacity 0.4s ease; }
.pnc-seal.signed {
  opacity: 1;
  animation: sealSpin 0.5s var(--ease-soft);
}
@keyframes sealSpin {
  from { transform: scale(0) rotate(-30deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.pnc-name { font-size: 15px; font-weight: 800; margin-bottom: 12px; }

.pnc-skills {
  display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px;
}
.pnc-skill-row { display: flex; align-items: center; gap: 10px; font-size: 11px; }
.pnc-skill-name { width: 58px; color: var(--fg-muted); flex-shrink: 0; }
.pnc-skill-bar { flex: 1; height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.pnc-skill-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  border-radius: 99px;
  width: 0; transition: width 0.9s var(--ease-soft);
}
.pnc-skill-val { font-size: 10px; color: var(--accent); font-weight: 700; width: 28px; text-align: right; }

.pnc-hash {
  font-family: var(--font-mono);
  font-size: 9.5px; color: var(--success);
  background: rgba(88,215,170,0.07);
  border: 1px solid rgba(88,215,170,0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  word-break: break-all; line-height: 1.5;
  min-height: 40px;
}
.pnc-hash-label { font-size: 9px; font-weight: 800; color: var(--fg-muted); margin-bottom: 6px; letter-spacing: 0.04em; }

/* Radar canvas */
#tourRadarCanvas { margin: 0 auto 12px; display: block; }

/* Stage 2 action button */
.passport-sign-wrap {
  display: flex; justify-content: center;
}

/* --- Stage 3: Enterprise --- */
.enterprise-stage { display: flex; flex-direction: column; gap: 14px; }

.ent-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ent-panel-header {
  background: var(--surface-strong);
  padding: 10px 16px;
  font-size: 11px; font-weight: 800; color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.ent-panel-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
}
.ent-panel-dot:nth-child(2) { background: var(--warning); }
.ent-panel-dot:nth-child(3) { background: var(--success); }

.ent-candidate-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
}
.ent-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.ent-cand-info { flex: 1; }
.ent-cand-name { font-size: 14px; font-weight: 800; }
.ent-cand-meta { font-size: 11px; color: var(--fg-muted); margin-top: 2px; }
.ent-status-badge {
  font-size: 10px; font-weight: 800; padding: 4px 10px;
  border-radius: 999px; border: 1px solid; white-space: nowrap;
}
.ent-status-badge.pending  { color: var(--warning); border-color: rgba(242,189,102,0.4); background: rgba(242,189,102,0.1); }
.ent-status-badge.scanning { color: var(--info);    border-color: rgba(123,199,255,0.4); background: rgba(123,199,255,0.1); }
.ent-status-badge.verified { color: var(--success); border-color: rgba(88,215,170,0.4);  background: rgba(88,215,170,0.1); }

.ent-scan-bar {
  height: 2px; background: var(--border);
  margin: 0 16px 0;
  border-radius: 99px; overflow: hidden;
  display: none;
}
.ent-scan-bar.active { display: block; }
.ent-scan-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--info), var(--success));
  width: 0; border-radius: 99px;
  transition: width 0.9s ease;
}

.ent-result {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: none;
}
.ent-result.visible { display: block; animation: slideDown 0.3s ease; }
.ent-result-title { font-size: 13px; font-weight: 800; color: var(--success); margin-bottom: 10px; }
.ent-claims { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ent-claim-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-muted); }
.ent-claim-check { color: var(--success); font-size: 13px; }
.ent-privacy-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: var(--success);
  background: rgba(88,215,170,0.07);
  border: 1px solid rgba(88,215,170,0.2);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}

/* --- Tour Complete --- */
.tour-complete {
  text-align: center; padding: 24px 12px;
  animation: fadeUp 0.45s var(--ease-soft);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tc-icon { font-size: 50px; line-height: 1; margin-bottom: 12px; }
.tc-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.tc-sub { font-size: 13px; color: var(--fg-muted); margin-bottom: 22px; line-height: 1.6; max-width: 42ch; margin-left: auto; margin-right: auto; }
.tc-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- Courses preview section on landing page ---- */
.courses-preview-section { }
.courses-preview-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 24px;
}
.courses-preview-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--fg);
  transition: all 0.2s var(--ease-soft);
}
.courses-preview-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.cpt-icon { font-size: 26px; flex-shrink: 0; }
.cpt-info { display: flex; flex-direction: column; gap: 2px; }
.cpt-name { font-size: 13px; font-weight: 800; }
.cpt-count { font-size: 11px; color: var(--fg-muted); }

@media (min-width: 640px) {
  .courses-preview-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .courses-preview-grid { grid-template-columns: repeat(6, 1fr); }
}
