/*
  math_math Design System — Marble & Ink

  Inspired by Italian Calacatta marble, walnut ink, and 22-karat gold leaf.
  The user should feel they have opened a rare book, not launched a calculator.

  Every surface, typographic choice, and micro-interaction is designed to make
  mathematics feel like an act of quiet luxury, not clinical utility.
*/

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Cormorant+Garamond:wght@300;400;500;600&family=JetBrains+Mono:wght@300;400&display=swap');

/* ═══════════════════════════════════════════
   TOKENS — Derived from material origins
   ═══════════════════════════════════════════ */
:root {
  /* Marble surfaces */
  --bg:      #f5f0eb;
  --bg2:     #ede6de;
  --vein:    #ded5cc;
  --cream:   #faf7f3;

  /* Ink tones */
  --ink:       #1a1008;
  --ink-mid:   #3a2e20;
  --ink-light: #6b5d4e;
  --ink-faint: #9e8e7a;
  --ink-ghost: #c4b8a8;

  /* Gold — 22kt, appears ONLY on focus + CTA */
  --gold:       #8b6914;
  --gold-light: #c9a84c;
  --gold-faint: rgba(139,105,20,0.07);

  /* Status */
  --err:  #8b3a3a;
  --ok:   #2d5a3d;
  --info: #3a4a6b;

  /* Typography */
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --body:  'Cormorant Garamond', 'Palatino Linotype', Palatino, Georgia, serif;
  --mono:  'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

  /* Radii — soft, like eroded stone */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 14px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.3s;
}

/* ═══════════════════════════════════════════
   RESET
   ═══════════════════════════════════════════ */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box }
html { scroll-behavior: smooth }

body {
  font-family: var(--body);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--gold-faint); color: var(--ink) }
input:focus, textarea:focus, select:focus, button:focus { outline: none }
::-webkit-scrollbar { width: 4px }
::-webkit-scrollbar-thumb { background: var(--ink-ghost); border-radius: 4px }

/* ═══════════════════════════════════════════
   MARBLE BACKGROUND — layered, not a single image
   ═══════════════════════════════════════════ */
.marble-bg {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(222,213,204,.4), transparent 50%),
    radial-gradient(ellipse at 75% 60%, rgba(200,191,178,.3), transparent 45%),
    radial-gradient(ellipse at 50% 80%, rgba(210,200,190,.35), transparent 40%),
    radial-gradient(ellipse at 85% 15%, rgba(201,168,76,.04), transparent 30%),
    var(--bg);
}

.marble-vein-1 {
  position: fixed; inset: 0; z-index: 0;
  opacity: .12; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg width='800' height='800' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 400Q200 350 400 420T800 380' fill='none' stroke='%23c4b8a8' stroke-width='1'/%3E%3Cpath d='M0 200Q300 180 500 230T800 200' fill='none' stroke='%23c4b8a8' stroke-width='0.7'/%3E%3Cpath d='M0 600Q250 560 450 620T800 580' fill='none' stroke='%23c4b8a8' stroke-width='0.8'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}

.marble-vein-2 {
  position: fixed; inset: 0; z-index: 0;
  opacity: .06; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg width='600' height='600' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M100 0Q120 200 300 300T500 600' fill='none' stroke='%23b0a594' stroke-width='1.2'/%3E%3Cpath d='M300 0Q280 150 200 300T100 600' fill='none' stroke='%23b0a594' stroke-width='0.6'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}

/* ═══════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════ */
.page {
  position: relative; z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
}

.page-wide {
  position: relative; z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ═══════════════════════════════════════════
   TYPOGRAPHY — Hand-composed mathematical journal
   ═══════════════════════════════════════════ */

/* Serif headlines — Playfair Display */
.h-serif {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
}

.h-hero  { font-size: clamp(2rem, 5vw, 2.8rem) }
.h-xl    { font-size: clamp(1.6rem, 3.5vw, 2.2rem) }
.h-lg    { font-size: 1.4rem }
.h-md    { font-size: 1.1rem }

/* Body text — Cormorant Garamond */
.t-body  { font-family: var(--body); font-weight: 400; color: var(--ink-mid) }
.t-light { font-family: var(--body); font-weight: 300; color: var(--ink-light) }

/* Mono — expressions and data */
.t-mono  { font-family: var(--mono); font-weight: 400; color: var(--ink-mid); letter-spacing: -0.01em }

/* Labels — uppercase whisper */
.t-label {
  font-family: var(--body);
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Values — the statement (serif, large) */
.t-value {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
}

/* Accent text — gold, only for emphasis */
.t-gold { color: var(--gold) }

/* Faint text */
.t-faint { color: var(--ink-faint) }
.t-ghost { color: var(--ink-ghost) }

/* ═══════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 0 24px;
  border-bottom: 0.5px solid var(--vein);
}

.brand {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-dot {
  color: var(--gold);
}

/* ═══════════════════════════════════════════
   NAV PILLS — minimal, recessed
   ═══════════════════════════════════════════ */
.nav-pills {
  display: flex;
  gap: 4px;
  background: var(--bg2);
  border-radius: 10px;
  padding: 3px;
}

.nav-pill {
  font-family: var(--body);
  font-size: 14px;
  font-weight: 400;
  color: var(--ink-faint);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 7px 18px;
  cursor: pointer;
  transition: all var(--dur) ease;
  letter-spacing: 0.03em;
}

.nav-pill:hover { color: var(--ink-light) }

.nav-pill.active {
  color: var(--ink);
  background: var(--cream);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(26,16,8,.08);
}

/* ═══════════════════════════════════════════
   HERO INPUT — underline, centered, large
   ═══════════════════════════════════════════ */
.hero-section {
  padding: 80px 0 40px;
  text-align: center;
}

.hero-prompt {
  font-family: var(--body);
  font-size: 15px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 32px;
  font-weight: 400;
}

.hero-input-wrap {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}

.hero-input {
  width: 100%;
  font-family: var(--body);
  font-size: 32px;
  font-weight: 300;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--vein);
  padding: 12px 0;
  text-align: center;
  letter-spacing: 0.01em;
  caret-color: var(--gold);
  transition: border-color var(--dur);
}

.hero-input:focus { border-bottom-color: var(--gold-light) }
.hero-input::placeholder { color: var(--ink-ghost) }

/* Expanding gold underline */
.hero-underline {
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 0%;
  height: 1.5px;
  background: var(--gold-light);
  transition: width 0.4s var(--ease);
}

.hero-input:focus ~ .hero-underline { width: 100% }

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  font-family: var(--body);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all var(--dur) ease;
}

.btn:disabled { opacity: .5; cursor: wait }

/* Ghost button — the default */
.btn-ghost {
  color: var(--ink-light);
  background: transparent;
  border: 1px solid var(--vein);
  border-radius: 24px;
  padding: 10px 32px;
}

.btn-ghost:hover {
  border-color: var(--ink-light);
  color: var(--ink);
}

/* Solid button — ink bg */
.btn-solid {
  color: var(--cream);
  background: var(--ink);
  border: none;
  border-radius: 10px;
  padding: 14px 48px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.btn-solid:hover { opacity: .85 }

/* Gold CTA */
.btn-gold {
  color: var(--gold);
  background: var(--gold-faint);
  border: 1px solid rgba(139,105,20,.15);
  border-radius: 10px;
  padding: 14px 0;
  text-align: center;
  width: 100%;
  letter-spacing: 0.06em;
}

.btn-gold:hover { background: rgba(139,105,20,.12) }

/* Small pill button */
.btn-pill {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
  background: transparent;
  border: 0.5px solid var(--vein);
  border-radius: 20px;
  padding: 8px 16px;
  letter-spacing: 0.01em;
}

.btn-pill:hover {
  color: var(--ink);
  border-color: var(--ink-ghost);
}

.btn-pill.active {
  color: var(--cream);
  background: var(--ink);
  border-color: var(--ink);
}

/* ═══════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════ */
.input {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink);
  background: var(--cream);
  border: 0.5px solid var(--vein);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  caret-color: var(--gold);
  transition: border-color var(--dur);
}

.input:focus { border-color: var(--gold-light) }
.input::placeholder { color: var(--ink-ghost) }

.input-sm { padding: 8px 12px; font-size: 13px }

.select {
  font-family: var(--body);
  font-size: 14px;
  color: var(--ink);
  background: var(--cream);
  border: 0.5px solid var(--vein);
  border-radius: var(--r-sm);
  padding: 10px 32px 10px 14px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%239e8e7a'%3E%3Cpath d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--dur);
}

.select:focus { border-color: var(--gold-light) }

/* ═══════════════════════════════════════════
   CARDS — cream surface, vein border
   ═══════════════════════════════════════════ */
.card {
  background: var(--cream);
  border: 0.5px solid var(--vein);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--dur);
}

.card:hover { border-color: var(--ink-ghost) }

.card-body { padding: 24px }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 18px 24px;
  border-bottom: none;
}

/* Result card — centered answer */
.result-answer {
  text-align: center;
  padding: 48px 28px 40px;
  position: relative;
}

/* Gold rule between question and answer */
.result-gold-rule {
  display: block;
  width: 60px;
  height: 1px;
  margin: 0 auto 0;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
}

/* Answer shimmer animation on reveal */
@keyframes goldShimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

@keyframes answerReveal {
  0%   { opacity: 0; transform: translateY(12px) scale(0.97); filter: blur(4px); }
  60%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.result-answer .t-value {
  animation: answerReveal 0.7s cubic-bezier(0.23, 1, 0.32, 1) both;
}

.answer-shimmer {
  background: linear-gradient(
    90deg,
    var(--ink) 0%,
    var(--ink) 40%,
    var(--gold-light) 50%,
    var(--ink) 60%,
    var(--ink) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: goldShimmer 2s ease-in-out 0.3s 1 both;
}

/* Domain badge — wax seal style */
.badge-seal {
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.06em;
  text-transform: capitalize;
  color: var(--gold);
  background: radial-gradient(ellipse at center, rgba(139,105,20,0.10) 0%, rgba(139,105,20,0.04) 70%, transparent 100%);
  border: 1.5px solid rgba(139,105,20,0.25);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 2px rgba(139,105,20,0.08), 0 1px 3px rgba(26,16,8,0.06);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   BADGES — minimal, typographic
   ═══════════════════════════════════════════ */
.badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 14px;
  border: 0.5px solid var(--vein);
  color: var(--ink-faint);
}

.badge-gold {
  color: var(--gold);
  border-color: rgba(139,105,20,.2);
  background: var(--gold-faint);
}

.badge-time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-ghost);
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════
   STEPS — mathematical derivation display
   ═══════════════════════════════════════════ */
.steps-section { padding: 24px 0 }

/* Legacy step-row kept for plot analysis panel */
.step-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--vein);
}

.step-row:last-child { border-bottom: none }

.step-label {
  font-family: var(--body);
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.step-value {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink-mid);
  text-align: right;
  margin-left: 16px;
  word-break: break-word;
}

/* Steps toggle — refined */
.steps-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 16px 28px;
  background: transparent;
  border: none;
  border-top: 0.5px solid var(--vein);
  color: var(--ink-faint);
  font-family: var(--body);
  font-size: 13px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--dur), background var(--dur);
}

.steps-toggle:hover { color: var(--ink-light); background: rgba(139,105,20,0.02) }
.steps-toggle .arrow {
  font-size: 9px;
  transition: transform 0.3s var(--ease);
  color: var(--gold);
}
.steps-toggle.open .arrow { transform: rotate(90deg) }

/* Steps body — smooth expand */
.steps-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s var(--ease), padding 0.3s var(--ease);
  padding: 0 28px;
}
.steps-body.open {
  max-height: 2000px;
  padding: 8px 28px 28px;
}

/* Derivation layout — proof style */
.derivation {
  position: relative;
  padding-left: 40px;
}

/* Vertical proof line */
.derivation::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(to bottom, var(--vein), rgba(139,105,20,0.2), var(--vein));
}

/* Individual derivation step */
.deriv-step {
  position: relative;
  padding: 12px 0;
  opacity: 0;
  transform: translateY(8px);
}

.steps-body.open .deriv-step {
  animation: stepFadeIn 0.4s ease-out forwards;
}

@keyframes stepFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

/* Step number — marginal annotation */
.deriv-num {
  position: absolute;
  left: -40px;
  top: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--vein);
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-faint);
  z-index: 1;
}

/* Step content */
.deriv-label {
  font-family: var(--body);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-light);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.deriv-detail {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-mid);
  line-height: 1.6;
  word-break: break-word;
}

/* Theorem / formula step — highlighted box */
.deriv-step.is-theorem {
  background: linear-gradient(135deg, rgba(139,105,20,0.04) 0%, rgba(222,213,204,0.3) 100%);
  border: 0.5px solid rgba(139,105,20,0.15);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin: 8px 0;
}

.deriv-step.is-theorem .deriv-num {
  background: var(--gold-faint);
  border-color: rgba(139,105,20,0.3);
  color: var(--gold);
}

.deriv-step.is-theorem .deriv-label {
  color: var(--gold);
  font-style: italic;
}

/* Verification step — gold checkmark */
.deriv-step.is-verify .deriv-detail .gold-check {
  color: var(--gold);
  font-weight: 600;
}

/* Final answer step — tombstone */
.deriv-step.is-final {
  padding-bottom: 4px;
}

.deriv-step.is-final .deriv-num {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--cream);
}

.deriv-step.is-final .deriv-detail {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.deriv-tombstone {
  display: inline-block;
  margin-left: 8px;
  font-size: 14px;
  color: var(--gold);
}

/* Connector between steps */
.deriv-step + .deriv-step {
  margin-top: 2px;
}

/* ═══════════════════════════════════════════
   EXAMPLE CHIPS
   ═══════════════════════════════════════════ */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
  background: transparent;
  border: 0.5px solid var(--vein);
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.01em;
}

.chip:hover {
  color: var(--ink);
  background: var(--gold-faint);
  border-color: var(--ink-ghost);
}

/* ═══════════════════════════════════════════
   FORM ROWS
   ═══════════════════════════════════════════ */
.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.form-row:last-child { margin-bottom: 0 }

.form-label {
  font-family: var(--body);
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-width: 80px;
  flex-shrink: 0;
}

.form-hint {
  font-size: 12px;
  color: var(--ink-ghost);
  font-family: var(--body);
}

/* ═══════════════════════════════════════════
   TOGGLE SWITCH
   ═══════════════════════════════════════════ */
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer }
.toggle input { display: none }
.toggle-track {
  width: 36px; height: 20px; background: var(--vein);
  border-radius: 10px; position: relative; transition: background .2s;
}
.toggle-track::after {
  content: ''; width: 14px; height: 14px; background: var(--cream);
  border-radius: 50%; position: absolute; top: 3px; left: 3px;
  transition: all .2s var(--ease);
}
.toggle input:checked + .toggle-track { background: var(--ink) }
.toggle input:checked + .toggle-track::after { left: 19px }
.toggle-label { font-family: var(--body); font-size: 14px; color: var(--ink-light) }

/* ═══════════════════════════════════════════
   PLOT / CANVAS
   ═══════════════════════════════════════════ */
.plot-wrap {
  background: var(--cream);
  border: 0.5px solid var(--vein);
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
}

.plot-wrap canvas { display: block; width: 100% }

/* ═══════════════════════════════════════════
   GRID LAYOUTS
   ═══════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px }

@media (max-width: 600px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr }
}

/* ═══════════════════════════════════════════
   METRIC CARDS — evaluation points
   ═══════════════════════════════════════════ */
.metric-card {
  background: var(--cream);
  border: 0.5px solid var(--vein);
  border-radius: 10px;
  padding: 14px 16px;
}

.metric-label-sm {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.metric-value-sm {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
}

/* ═══════════════════════════════════════════
   OUTPUT PANEL — mono results
   ═══════════════════════════════════════════ */
.output-panel {
  background: var(--cream);
  border: 0.5px solid var(--vein);
  border-radius: var(--r-md);
  padding: 20px 24px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-mid);
  line-height: 1.7;
  white-space: pre-wrap;
}

.output-panel .ok  { color: var(--ok) }
.output-panel .err { color: var(--err) }
.output-panel .hl  { color: var(--gold) }

/* ═══════════════════════════════════════════
   LOADING — golden ink trace
   ═══════════════════════════════════════════ */
.loading {
  text-align: center;
  padding: 44px 28px;
  color: var(--ink-faint);
  font-family: var(--body);
  font-size: 14px;
  letter-spacing: 0.08em;
  position: relative;
  overflow: hidden;
}

/* Golden trace line */
.ink-trace {
  display: block;
  width: 100%;
  height: 1px;
  margin: 0 auto 18px;
  position: relative;
  background: var(--vein);
  border-radius: 1px;
  overflow: hidden;
}

.ink-trace::after {
  content: '';
  position: absolute;
  left: -40%;
  top: 0;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--gold-light), var(--gold), var(--gold-light), transparent);
  animation: traceSlide 1.4s ease-in-out infinite;
}

@keyframes traceSlide {
  0%   { left: -40%; }
  100% { left: 100%; }
}

.loading-text {
  font-family: var(--body);
  font-size: 14px;
  color: var(--ink-faint);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  animation: loadPulse 2s ease-in-out infinite;
}

@keyframes loadPulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* Legacy dot loader kept for generate tab */
.dot-loader { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px }
.dot-loader span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--ink-ghost);
  animation: dotPulse 1.2s ease-in-out infinite;
}
.dot-loader span:nth-child(2) { animation-delay: .2s }
.dot-loader span:nth-child(3) { animation-delay: .4s }

/* ═══════════════════════════════════════════
   ANIMATIONS — ink and paper metaphors
   ═══════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px) }
  to   { opacity: 1; transform: translateY(0) }
}

@keyframes inkWash {
  from { opacity: 0; clip-path: inset(0 100% 0 0) }
  to   { opacity: 1; clip-path: inset(0 0 0 0) }
}

@keyframes letterIn {
  from { opacity: 0; transform: translateY(8px) rotate(-2deg) }
  to   { opacity: 1; transform: translateY(0) rotate(0) }
}

@keyframes dotPulse {
  0%, 100% { opacity: .2 }
  50% { opacity: .8 }
}

@keyframes shimmer {
  0% { background-position: 200% 0 }
  100% { background-position: -200% 0 }
}

.animate-in { animation: fadeUp 0.5s ease-out both }
.animate-ink { animation: inkWash 0.7s ease-out }
.delay-1 { animation-delay: .05s }
.delay-2 { animation-delay: .1s }
.delay-3 { animation-delay: .15s }
.delay-4 { animation-delay: .2s }

/* ═══════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════ */
.footer {
  text-align: center;
  padding: 48px 0 24px;
  border-top: 0.5px solid var(--vein);
  margin-top: 48px;
}

.footer-text {
  font-family: var(--body);
  font-size: 12px;
  color: var(--ink-ghost);
  letter-spacing: 0.08em;
}

/* ═══════════════════════════════════════════
   NAV LINKS — to other pages
   ═══════════════════════════════════════════ */
.nav-links {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 20px 0;
}

.nav-link {
  font-family: var(--body);
  font-size: 13px;
  color: var(--ink-faint);
  text-decoration: none;
  letter-spacing: 0.06em;
  transition: color var(--dur);
  padding: 4px 0;
  border-bottom: 0.5px solid transparent;
}

.nav-link:hover {
  color: var(--ink);
  border-bottom-color: var(--vein);
}

/* ═══════════════════════════════════════════
   REVEAL ANIMATION — for generated answers
   ═══════════════════════════════════════════ */
.answer-blur {
  filter: blur(8px);
  transition: filter 0.3s;
  cursor: pointer;
  user-select: none;
}

.answer-blur.shown { filter: none }

/* ═══════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════ */
.mt-sm { margin-top: 12px }
.mt-md { margin-top: 24px }
.mt-lg { margin-top: 40px }
.mb-sm { margin-bottom: 12px }
.mb-md { margin-bottom: 24px }
.mb-lg { margin-bottom: 40px }
.flex { display: flex }
.flex-center { display: flex; align-items: center; justify-content: center }
.gap-sm { gap: 8px }
.gap-md { gap: 12px }
.text-center { text-align: center }

/* ═══════════════════════════════════════════
   CAPABILITY CATALOG — rare book index
   ═══════════════════════════════════════════ */
.catalog {
  max-width: 660px;
  margin: 0 auto;
}

/* Chapter heading — "Explore the engine" */
.catalog-heading {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 36px;
  justify-content: center;
}

.catalog-heading-rule {
  flex: 1;
  max-width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
}

.catalog-heading-text {
  font-family: var(--body);
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-faint);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Domain accordion */
.cat-domain {
  margin-bottom: 8px;
  border: 0.5px solid var(--vein);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--cream);
  transition: border-color var(--dur);
}

.cat-domain:hover { border-color: var(--ink-ghost) }

.cat-domain-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--dur);
}

.cat-domain-toggle:hover { background: rgba(139,105,20,0.02) }

.cat-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.02em;
  font-style: italic;
}

.cat-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-ghost);
  font-style: normal;
}

.cat-arrow {
  font-size: 10px;
  color: var(--ink-ghost);
  transition: transform 0.3s var(--ease);
}

.cat-domain.open .cat-arrow { transform: rotate(90deg) }

.cat-items-wrap {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s var(--ease);
}

.cat-domain.open .cat-items-wrap {
  max-height: 4000px;
}

.cat-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 0 12px 12px;
}

@media (max-width: 600px) {
  .cat-items { grid-template-columns: 1fr; }
}

/* Sub-category headers within a domain */
.cat-subheader {
  grid-column: 1 / -1;
  font-family: var(--body);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 10px 8px 4px;
  border-bottom: 0.5px solid var(--vein);
  margin-top: 4px;
}

.cat-subheader:first-child { margin-top: 0 }

.cat-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 9px 12px;
  border: 0.5px solid transparent;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: left;
  width: 100%;
  line-height: 1.4;
}

.cat-item:hover {
  background: var(--gold-faint);
  border-color: var(--ink-ghost);
}

.cat-expr {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-mid);
  transition: color 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-item:hover .cat-expr { color: var(--ink) }

.cat-hint {
  font-family: var(--body);
  font-size: 13px;
  font-weight: 500;
  font-style: italic;
  color: var(--ink-ghost);
  margin-left: 10px;
  flex-shrink: 0;
  transition: color 0.2s;
  white-space: nowrap;
}

.cat-item:hover .cat-hint { color: var(--gold) }

/* Show more link */
.cat-show-more {
  grid-column: 1 / -1;
  text-align: center;
  padding: 8px;
}

.cat-show-more-btn {
  font-family: var(--body);
  font-size: 13px;
  color: var(--ink-faint);
  background: none;
  border: none;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color var(--dur);
  padding: 4px 12px;
}

.cat-show-more-btn:hover { color: var(--gold) }

.cat-item.cat-hidden { display: none }
.cat-domain.show-all .cat-item.cat-hidden { display: flex }
