/* ============================================================
   CalculusKitzo — design system
   ============================================================ */
:root {
  --bg: #0b1023;
  --bg-2: #131a3a;
  --panel: #1a2350;
  --panel-2: #161d42;
  --line: rgba(148, 163, 216, 0.16);
  --line-strong: rgba(148, 163, 216, 0.32);
  --ink: #eef1ff;
  --muted: #9aa6d0;
  --faint: #5b678f;
  --violet: #8b5cf6;
  --cyan: #22d3ee;
  --amber: #fbbf24;
  --rose: #fb7185;
  --emerald: #34d399;
  --grad: linear-gradient(120deg, #8b5cf6 0%, #22d3ee 55%, #34d399 110%);
  --grad-warm: linear-gradient(120deg, #fbbf24, #fb7185);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }

.container { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(11, 16, 35, 0.82);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0; }
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.25rem; color: var(--ink); letter-spacing: 0.2px; }
.brand:hover { text-decoration: none; }
.brand-badge { width: 36px; height: 36px; }
.brand span em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-links { display: flex; align-items: center; gap: 1.1rem; list-style: none; margin: 0; padding: 0; }
.nav-links a { color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line-strong); color: var(--ink); border-radius: 8px; padding: 0.4rem 0.6rem; font-size: 1.1rem; cursor: pointer; }
.user-chip { font-size: 0.8rem; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.7rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; border: 0; border-radius: 12px; padding: 0.75rem 1.4rem; font: 700 1rem/1 var(--font); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, filter .15s ease; text-decoration: none; }
.btn:hover { transform: translateY(-2px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--grad); color: #081026; box-shadow: 0 10px 30px rgba(34, 211, 238, 0.25); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
.btn-ghost:hover { border-color: var(--cyan); color: var(--cyan); }
.btn-small { padding: 0.5rem 0.9rem; font-size: 0.85rem; border-radius: 9px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero-grid-bg {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(139, 92, 246, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 92, 246, 0.14) 1px, transparent 1px),
    linear-gradient(rgba(34, 211, 238, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.05) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  mask-image: radial-gradient(ellipse 90% 80% at 60% 40%, black 40%, transparent 75%);
}
.hero-glow { position: absolute; width: 560px; height: 560px; border-radius: 50%; filter: blur(140px); opacity: 0.35; pointer-events: none; }
.hero-glow.violet { background: #6d28d9; top: -180px; left: -160px; }
.hero-glow.cyan { background: #0e7490; bottom: -220px; right: -140px; }
.hero-inner { position: relative; display: grid; grid-template-columns: 1.05fr 1fr; gap: 2rem; align-items: center; padding: 3.5rem 0 3rem; min-height: 560px; }
.kicker { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--cyan); background: rgba(34, 211, 238, 0.08); border: 1px solid rgba(34, 211, 238, 0.35); border-radius: 999px; padding: 0.35rem 0.9rem; }
h1.hero-title { font-size: clamp(2.6rem, 5.4vw, 4rem); line-height: 1.02; font-weight: 900; letter-spacing: -1.5px; margin: 1.1rem 0 1rem; }
h1.hero-title .grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--muted); font-size: 1.15rem; max-width: 34rem; margin: 0 0 1.6rem; }
.hero-cta { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 1.6rem; margin-top: 1.6rem; color: var(--muted); font-size: 0.85rem; }
.hero-stats b { display: block; font-size: 1.35rem; color: var(--ink); }
.hero-visual { position: relative; }
#hero-canvas { width: 100%; height: auto; display: block; }
.hero-visual figcaption { position: absolute; bottom: 0.4rem; left: 0.4rem; font-size: 0.7rem; color: var(--faint); font-family: var(--mono); }

/* ---------- sections ---------- */
section { padding: 4rem 0; }
.section-head { text-align: center; margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); letter-spacing: -0.5px; margin: 0.6rem 0 0.4rem; }
.section-head p { color: var(--muted); margin: 0; }
.eyebrow { font-size: 0.75rem; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: var(--violet); }

/* ---------- chapter grid ---------- */
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 1rem; }
.chapter-card {
  position: relative; display: flex; flex-direction: column; gap: 0.4rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.1rem 0.9rem; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  color: inherit; text-decoration: none;
}
a.chapter-card:hover { transform: translateY(-4px); border-color: rgba(34, 211, 238, 0.45); box-shadow: var(--shadow); text-decoration: none; }
.chapter-num { font-family: var(--mono); font-size: 0.75rem; color: var(--cyan); letter-spacing: 1px; }
.chapter-card h3 { margin: 0; font-size: 1.02rem; line-height: 1.35; }
.chapter-card .blurb { color: var(--muted); font-size: 0.82rem; line-height: 1.5; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.35rem; }
.pill { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; border-radius: 999px; padding: 0.18rem 0.55rem; border: 1px solid; }
.pill-starter { color: var(--emerald); border-color: rgba(52, 211, 153, 0.4); }
.pill-core { color: var(--cyan); border-color: rgba(34, 211, 238, 0.4); }
.pill-advanced { color: var(--amber); border-color: rgba(251, 191, 36, 0.4); }
.badge-full { font-size: 0.68rem; font-weight: 800; color: #081026; background: var(--grad); border-radius: 999px; padding: 0.18rem 0.55rem; }
.badge-soon { font-size: 0.68rem; color: var(--faint); border: 1px dashed var(--line-strong); border-radius: 999px; padding: 0.18rem 0.55rem; }
.progress-track { height: 6px; border-radius: 4px; background: rgba(148, 163, 216, 0.14); overflow: hidden; }
.progress-fill { height: 100%; background: var(--grad); width: 0%; transition: width .4s ease; }

/* ---------- features ---------- */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.feature { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; }
.feature .icon { font-size: 1.6rem; }
.feature h3 { margin: 0.5rem 0 0.35rem; font-size: 1.05rem; }
.feature p { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* ---------- FAQ ---------- */
.faq { max-width: 820px; margin-inline: auto; }
.faq details { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem 1.25rem; margin-bottom: 0.7rem; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq p { color: var(--muted); margin: 0.6rem 0 0; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 2.5rem 0 2rem; color: var(--muted); font-size: 0.85rem; background: #0a0e20; }
.footer-grid { display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--cyan); text-decoration: none; }
.footer small { display: block; margin-top: 1.4rem; color: var(--faint); }

/* ---------- chapter player ---------- */
.chapter-hero { border-bottom: 1px solid var(--line); background: radial-gradient(ellipse 70% 90% at 30% 0%, rgba(139, 92, 246, 0.22), transparent), var(--bg-2); padding: 2rem 0 1.6rem; }
.crumbs { font-size: 0.8rem; color: var(--muted); font-family: var(--mono); }
.crumbs a { color: var(--muted); }
.chapter-hero h1 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); margin: 0.4rem 0 0.5rem; letter-spacing: -0.6px; }
.chapter-meta { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.player { display: grid; grid-template-columns: 1fr 380px; gap: 1.5rem; padding: 2rem 0; align-items: start; }
.prose h2 { margin-top: 1.8rem; font-size: 1.35rem; letter-spacing: -0.3px; }
.prose p { color: #cdd4f6; }
.prose strong { color: var(--ink); }
.key-idea, .watch-out, .example-box, .formula-sheet { border-radius: var(--radius-sm); padding: 0.9rem 1.1rem; margin: 1rem 0; border: 1px solid; }
.key-idea { background: rgba(34, 211, 238, 0.07); border-color: rgba(34, 211, 238, 0.35); }
.watch-out { background: rgba(251, 191, 36, 0.07); border-color: rgba(251, 191, 36, 0.4); }
.example-box { background: rgba(139, 92, 246, 0.08); border-color: rgba(139, 92, 246, 0.4); }
.key-idea .tag { color: var(--cyan); } .watch-out .tag { color: var(--amber); } .example-box .tag { color: #c4b5fd; }
.tag { font-size: 0.72rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; display: block; margin-bottom: 0.35rem; }
.formula-sheet { background: var(--panel-2); border-color: var(--line-strong); font-family: var(--mono); font-size: 0.88rem; line-height: 2; }
.side-panel { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 76px; }
.panel { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.panel h2 { font-size: 0.78rem; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); margin: 0 0 0.6rem; font-family: var(--font); }
.grapher-wrap { background: #0d1330; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); overflow: hidden; }
.grapher-wrap canvas { width: 100%; height: 320px; display: block; touch-action: none; cursor: crosshair; }
.grapher-controls { display: flex; gap: 0.4rem; margin-top: 0.6rem; flex-wrap: wrap; }
.grapher-controls input { flex: 1; min-width: 140px; background: var(--bg); border: 1px solid var(--line-strong); color: var(--ink); border-radius: 8px; padding: 0.5rem 0.6rem; font-family: var(--mono); }
.probe-readout { font-family: var(--mono); font-size: 0.82rem; color: var(--amber); min-height: 1.4em; margin-top: 0.5rem; }
.probe-readout div { color: var(--cyan); font-size: 0.85em; letter-spacing: 0.02em; }
.viz-toolbar { display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; margin-top: 0.6rem; font-size: 0.8rem; }
.viz-toolbar label { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; color: var(--muted); font-family: var(--mono); }
.viz-toolbar input { accent-color: var(--cyan); }
.viz-preset { background: var(--bg); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px; padding: 0.4rem 0.5rem; font-family: var(--mono); font-size: 0.8rem; max-width: 100%; }
.viz-sliders { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.6rem; }
.viz-slider { display: grid; grid-template-columns: 5.6rem 1fr 3.2rem; align-items: center; gap: 0.5rem; font-size: 0.76rem; font-family: var(--mono); color: var(--muted); }
.viz-slider input[type="range"] { width: 100%; accent-color: var(--violet); }
.viz-slider-value { text-align: right; color: var(--amber); }
.viz-speed { display: inline-flex; gap: 0.25rem; align-items: center; }
.viz-speed button { font-family: var(--mono); padding: 0.3rem 0.55rem; }
.viz-speed button[aria-pressed="true"] { background: rgba(139, 92, 246, 0.25); border-color: var(--violet); color: var(--ink); }
.viz-note { margin-top: 0.6rem; }
.grapher-wrap canvas { height: 340px; }
@media (min-width: 1024px) {
  .viz-panel { margin-inline: -0.4rem; }
}
.chapter-nav { display: flex; justify-content: space-between; gap: 1rem; margin: 1rem 0 3rem; }
.topics-list { margin: 0; padding-left: 1.1rem; color: #cdd4f6; columns: 2; gap: 1.5rem; }
.topics-list li { margin-bottom: 0.3rem; break-inside: avoid; }
.coming-soon-box { text-align: center; padding: 2.5rem 1.5rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }

/* ---------- exercises ---------- */
.exercise-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.exercise-prompt { font-size: 1rem; margin-bottom: 0.7rem; }
.exercise-prompt em { color: var(--cyan); font-family: var(--mono); font-style: normal; }
.exercise-input input[type=text] { width: 100%; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; padding: 0.65rem 0.75rem; color: var(--ink); font-family: var(--mono); font-size: 1rem; }
.option { display: flex; align-items: center; gap: 0.6rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem 0.7rem; margin-bottom: 0.4rem; cursor: pointer; transition: border-color .15s ease; }
.static-options { list-style: none; margin: 0 0 0.6rem; padding: 0; display: grid; gap: 0.4rem; }
.static-options li { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem 0.7rem; color: #cdd4f6; }
.static-options strong { color: var(--cyan); font-family: var(--mono); }
.option:hover { border-color: var(--cyan); }
.option input { accent-color: var(--violet); }
.option-key { font-family: var(--mono); font-size: 0.75rem; color: var(--faint); border: 1px solid var(--line-strong); border-radius: 6px; padding: 0.1rem 0.4rem; }
.exercise-actions { display: flex; gap: 0.5rem; margin-top: 0.65rem; }
.exercise-feedback { margin-top: 0.6rem; font-weight: 700; font-size: 0.92rem; }
.exercise-feedback.ok { color: var(--emerald); }
.exercise-feedback.bad { color: var(--rose); }
.exercise-feedback.neutral { color: var(--amber); }
.exercise-hint { margin-top: 0.5rem; font-size: 0.88rem; color: var(--amber); background: rgba(251, 191, 36, 0.06); border-left: 3px solid var(--amber); padding: 0.5rem 0.75rem; border-radius: 6px; }
.exercise-explain { margin-top: 0.5rem; font-size: 0.9rem; color: #cdd4f6; background: rgba(139, 92, 246, 0.09); border-left: 3px solid var(--violet); padding: 0.55rem 0.75rem; border-radius: 6px; }
.exercise-summary .summary-inner { display: flex; align-items: center; gap: 1.2rem; background: var(--panel); border: 1px solid rgba(52, 211, 153, 0.35); padding: 1.1rem 1.4rem; border-radius: var(--radius-sm); }
.summary-score { font-size: 3rem; font-weight: 900; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.summary-score span { font-size: 1.4rem; }
.summary-text p { margin: 0.2rem 0 0; color: var(--muted); }

/* ---------- forms & auth ---------- */
.auth-wrap { max-width: 460px; margin: 4rem auto; }
.panel-card { background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow); }
.panel-card h1 { font-size: 1.5rem; margin: 0 0 0.25rem; letter-spacing: -0.4px; }
.panel-card .sub { color: var(--muted); margin: 0 0 1.2rem; font-size: 0.95rem; }
label.field { display: block; font-size: 0.82rem; font-weight: 700; color: var(--muted); margin: 0.9rem 0 0.35rem; }
input.field-input { width: 100%; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; padding: 0.75rem 0.85rem; color: var(--ink); font-size: 1rem; }
input.code-input { letter-spacing: 0.5em; font-family: var(--mono); font-size: 1.5rem; text-align: center; }
.form-note { font-size: 0.78rem; color: var(--faint); margin-top: 0.8rem; }
.dev-code-note { font-family: var(--mono); color: var(--amber); background: rgba(251, 191, 36, 0.08); border: 1px dashed rgba(251, 191, 36, 0.45); padding: 0.5rem 0.75rem; border-radius: 8px; margin-top: 0.8rem; font-size: 0.85rem; }
.error-text { color: var(--rose); font-size: 0.88rem; min-height: 1.4em; margin-top: 0.6rem; }

/* ---------- dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: 340px 1fr; gap: 1.5rem; padding: 2rem 0; align-items: start; }
.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.stat-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-top: 1rem; }
.stat-tile { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.8rem; text-align: center; }
.stat-tile b { display: block; font-size: 1.5rem; }
.stat-tile span { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }
.progress-list { display: flex; flex-direction: column; gap: 0.55rem; }
.progress-row { display: grid; grid-template-columns: 2fr 1.4fr auto; gap: 0.8rem; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.65rem 0.9rem; font-size: 0.88rem; }
.status-dot { font-weight: 800; font-size: 0.72rem; letter-spacing: 0.8px; text-transform: uppercase; }
.status-dot.completed { color: var(--emerald); }
.status-dot.in_progress { color: var(--amber); }

/* ---------- toast ---------- */
.ckz-toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translate(-50%, 16px); opacity: 0; z-index: 100; background: var(--panel); border: 1px solid var(--cyan); color: var(--ink); padding: 0.7rem 1.1rem; border-radius: 10px; font-size: 0.9rem; transition: all .25s ease; pointer-events: none; max-width: 90vw; }
.ckz-toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .player { grid-template-columns: 1fr; }
  .side-panel { position: static; order: -1; }
  .dash-grid { grid-template-columns: 1fr; }
  .topics-list { columns: 1; }
}
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 100%; right: 1rem; flex-direction: column; align-items: flex-start; background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 0.9rem; min-width: 220px; box-shadow: var(--shadow); }
  .nav-links.open { display: flex; }
  .hero-inner { grid-template-columns: 1fr; min-height: auto; padding-top: 2.5rem; }
  .hero-visual { order: -1; max-width: 420px; margin-inline: auto; }
  .hero-stats { flex-wrap: wrap; gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
