/* ============================================================
   CRUMB — Failproof Sourdough Calculator
   Art direction: warm artisan bakery — cream, terracotta, deep umber
   Inspired by: hand-thrown ceramics, kraft paper, brick ovens
============================================================ */

/* ---------- TOKENS ---------- */
:root, [data-theme='light'] {
  /* Surfaces — warm cream */
  --color-bg: #f6efe1;
  --color-surface: #fbf6ea;
  --color-surface-2: #ffffff;
  --color-surface-offset: #ede4d0;
  --color-surface-offset-2: #e3d8bf;
  --color-divider: #d8caa9;
  --color-border: #c8b78e;

  /* Ink — deep umber */
  --color-text: #2a1f12;
  --color-text-muted: #6b5840;
  --color-text-faint: #a59070;
  --color-text-inverse: #fbf6ea;

  /* Primary accent — terracotta */
  --color-primary: #c5793a;
  --color-primary-hover: #a85e22;
  --color-primary-active: #804619;
  --color-primary-highlight: #f0d9bc;

  /* Secondary — deep crust */
  --color-secondary: #6b3819;
  --color-secondary-hover: #5a2d12;

  /* Sage / olive — for "passive" steps */
  --color-sage: #7a8a5c;
  --color-sage-light: #d8dec5;

  /* Sentiment */
  --color-success: #5a7a3c;
  --color-success-light: #d4e0c0;
  --color-warning: #c9871f;
  --color-warning-light: #f3e3c0;
  --color-error: #a13d20;
  --color-error-light: #f0d0c4;

  /* Type */
  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'Satoshi', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Type scale (fluid) */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-hero: clamp(2.75rem, 1rem + 6vw, 6rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(42, 31, 18, 0.05);
  --shadow-md: 0 4px 16px rgba(42, 31, 18, 0.08), 0 1px 3px rgba(42, 31, 18, 0.05);
  --shadow-lg: 0 12px 36px rgba(42, 31, 18, 0.12), 0 4px 12px rgba(42, 31, 18, 0.06);
  --shadow-xl: 0 24px 64px rgba(42, 31, 18, 0.18);
}

[data-theme='dark'] {
  --color-bg: #1a140c;
  --color-surface: #221a10;
  --color-surface-2: #2a1f12;
  --color-surface-offset: #2f2417;
  --color-surface-offset-2: #3a2d1c;
  --color-divider: #4a3a25;
  --color-border: #5a4830;

  --color-text: #f6efe1;
  --color-text-muted: #c0ad8a;
  --color-text-faint: #80704f;
  --color-text-inverse: #1a140c;

  --color-primary: #e69251;
  --color-primary-hover: #f4a766;
  --color-primary-active: #d57e3a;
  --color-primary-highlight: #4a2e16;

  --color-secondary: #d8a06d;
  --color-secondary-hover: #e8b07a;

  --color-sage: #9aaa78;
  --color-sage-light: #3a4528;

  --color-success: #88a060;
  --color-success-light: #2e3a1c;
  --color-warning: #e0a448;
  --color-warning-light: #3d2e0e;
  --color-error: #d8643f;
  --color-error-light: #3d1c10;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.7);
}

/* ---------- RESET / BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'ss02';
  /* Subtle paper texture via SVG */
  background-image:
    radial-gradient(at 10% 0%, rgba(197, 121, 58, 0.04) 0%, transparent 40%),
    radial-gradient(at 90% 100%, rgba(107, 56, 25, 0.03) 0%, transparent 40%);
  background-attachment: fixed;
}

a { color: var(--color-primary); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--color-primary-hover); }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- TYPOGRAPHY ---------- */
.display, h1.display {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-weight: 500;
  line-height: 0.96;
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--color-text);
}
.display em, .display i {
  font-style: italic;
  color: var(--color-primary);
  font-weight: 400;
}

h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1;
  margin: var(--space-3) 0 var(--space-4) 0;
  max-width: 18ch;
}

.section-sub {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 56ch;
  margin: 0 0 var(--space-12) 0;
}

.kicker {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-primary);
  display: inline-block;
}
.kicker-credit {
  color: var(--color-text-muted);
  font-weight: 400;
  letter-spacing: 0.16em;
  margin-left: 0.4em;
}
.kicker-credit a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.18s ease;
}
.kicker-credit a:hover {
  color: var(--color-primary);
}
.built-with-love {
  margin-top: var(--space-3);
  font-style: italic;
  color: var(--color-text-muted);
}
.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}
.download-actions .btn-secondary {
  flex: 0 0 auto;
}

/* ---------- LAYOUT ---------- */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
}

main { display: block; }

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) clamp(1.25rem, 4vw, 3rem);
  background: rgba(246, 239, 225, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-divider);
}
[data-theme='dark'] .topbar { background: rgba(26, 20, 12, 0.85); }

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-primary);
}
.brand:hover { color: var(--color-primary-hover); }

.logo { width: 32px; height: 32px; flex-shrink: 0; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.nav { display: flex; align-items: center; gap: var(--space-6); }
.nav-link {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
}
.nav-link:hover { color: var(--color-text); }
@media (max-width: 640px) {
  .nav-link { display: none; }
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

/* ---------- HERO ---------- */
.hero {
  padding: clamp(3rem, 8vw, 6rem) clamp(1.25rem, 4vw, 3rem);
  background:
    radial-gradient(ellipse at 80% 20%, rgba(197, 121, 58, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 80%, rgba(107, 56, 25, 0.08) 0%, transparent 50%);
}
.hero-inner {
  max-width: 1180px;
  margin: 0 auto;
}
.hero .kicker { margin-bottom: var(--space-5); }
.hero h1.display {
  max-width: 16ch;
  margin-bottom: var(--space-6);
}
.lede {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 60ch;
  line-height: 1.5;
  margin-bottom: var(--space-10);
}

.hero-meta {
  display: flex;
  gap: var(--space-6);
  align-items: center;
  margin-bottom: var(--space-10);
  flex-wrap: wrap;
}
.meta-item { display: flex; flex-direction: column; gap: var(--space-1); }
.meta-num {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
  line-height: 1;
}
.meta-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.meta-divider {
  width: 1px;
  height: 40px;
  background: var(--color-divider);
}
@media (max-width: 540px) {
  .meta-divider { display: none; }
  .hero-meta { gap: var(--space-4); }
}

/* ---------- BUTTONS ---------- */
.cta-primary, .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-8);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-primary-hover);
}
.cta-primary:hover, .btn-primary:hover {
  background: var(--color-primary-hover);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-md);
}
.cta-primary:active, .btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  background: transparent;
  color: var(--color-text);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  border: 1px solid var(--color-border);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-secondary:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-text-muted);
}

/* ---------- WIZARD ---------- */
.wizard {
  padding: clamp(3rem, 6vw, 6rem) clamp(1.25rem, 4vw, 3rem);
  background: var(--color-surface);
  border-top: 1px solid var(--color-divider);
  border-bottom: 1px solid var(--color-divider);
}
.wizard-shell {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--space-12);
}
@media (max-width: 880px) {
  .wizard-shell { grid-template-columns: 1fr; gap: var(--space-8); }
}

.wizard-rail {
  position: sticky;
  top: 90px;
  align-self: start;
}
.rail-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  border-left: 2px solid var(--color-divider);
  padding-left: var(--space-5);
}
.rail-steps li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  position: relative;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: color 0.2s ease, transform 0.15s ease;
  cursor: default;
  outline: none;
  border-radius: 4px;
}
.rail-steps li.is-clickable {
  cursor: pointer;
}
.rail-steps li.is-clickable:hover {
  color: var(--color-text);
}
.rail-steps li.is-clickable:hover .rail-dot {
  border-color: var(--color-primary);
}
.rail-steps li:focus-visible {
  box-shadow: 0 0 0 2px var(--color-primary-highlight);
}
.rail-steps li.is-active {
  color: var(--color-text);
  font-weight: 600;
}
.rail-steps li.is-done { color: var(--color-text-muted); }
.rail-dot {
  position: absolute;
  left: -29px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-divider);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.rail-steps li.is-active .rail-dot {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-highlight);
}
.rail-steps li.is-done .rail-dot {
  background: var(--color-text-muted);
  border-color: var(--color-text-muted);
}

@media (max-width: 880px) {
  .wizard-rail { position: static; }
  .rail-steps {
    flex-direction: row;
    border-left: none;
    border-top: 2px solid var(--color-divider);
    padding-left: 0;
    padding-top: var(--space-5);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .rail-steps::-webkit-scrollbar { display: none; }
  .rail-steps li {
    flex-shrink: 0;
    padding-right: var(--space-4);
  }
  .rail-dot {
    left: 50%;
    top: -7px;
    transform: translateX(-50%);
  }
  .rail-text { white-space: nowrap; }
}

.wizard-stage {
  background: var(--color-surface-2);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-divider);
  padding: clamp(1.5rem, 4vw, 3rem);
  box-shadow: var(--shadow-md);
  min-height: 500px;
  min-width: 0;
  max-width: 100%;
}
.wizard-shell > * { min-width: 0; }

.step { display: none; animation: fadeIn 0.4s ease; }
.step.is-active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-header { margin-bottom: var(--space-8); }
.step-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-primary);
  display: block;
  margin-bottom: var(--space-3);
}
.step-header h2 {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  margin-bottom: var(--space-3);
  letter-spacing: -0.02em;
}
.step-sub {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin: 0;
  max-width: 60ch;
}

.step-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-divider);
  justify-content: space-between;
}
.step-actions:has(> :only-child) { justify-content: flex-end; }

/* ---------- FORM FIELDS ---------- */
.field { margin-bottom: var(--space-6); }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
@media (max-width: 540px) {
  .field-row { grid-template-columns: 1fr; }
}

.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
.field-label .hint {
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: var(--text-xs);
}

.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}
.input::placeholder { color: var(--color-text-faint); }
select.input { cursor: pointer; }

.field-help {
  display: block;
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  line-height: 1.5;
}

.quiet-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
  align-items: center;
}
.quiet-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
}
.quiet-toggle input { width: 16px; height: 16px; accent-color: var(--color-primary); cursor: pointer; }
.quiet-times {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}
.quiet-times.is-disabled { opacity: 0.4; pointer-events: none; }
.quiet-time-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.quiet-time-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.input-time { width: auto; min-width: 110px; }

/* ---------- ARCHETYPE GRID ---------- */
.archetype-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}
@media (max-width: 540px) {
  .archetype-grid { grid-template-columns: 1fr 1fr; gap: var(--space-2); }
  .archetype-card { padding: var(--space-3); }
  .archetype-title { font-size: var(--text-sm); }
}
.archetype-card {
  text-align: left;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  cursor: pointer;
}
.archetype-card:hover {
  border-color: var(--color-text-muted);
  background: var(--color-surface-offset);
}
.archetype-card.is-selected {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
  box-shadow: 0 0 0 3px var(--color-primary-highlight), var(--shadow-sm);
}
.archetype-emoji { font-size: 1.6rem; margin-bottom: var(--space-1); }
.archetype-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--color-text);
  letter-spacing: -0.01em;
}
.archetype-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ---------- BUDGET / TEMP / SKILL CARDS ---------- */
.budget-grid, .temp-grid, .skill-grid {
  display: grid;
  gap: var(--space-3);
}
.budget-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.temp-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.skill-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
@media (max-width: 540px) {
  .budget-grid, .skill-grid { grid-template-columns: 1fr; }
  .temp-grid { grid-template-columns: 1fr 1fr; }
  .budget-card, .skill-card, .temp-card { padding: var(--space-3); }
}

.budget-card, .temp-card, .skill-card, .levain-card {
  text-align: left;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  cursor: pointer;
}
.budget-card:hover, .temp-card:hover, .skill-card:hover, .levain-card:hover {
  border-color: var(--color-text-muted);
  background: var(--color-surface-offset);
}
.budget-card.is-selected, .temp-card.is-selected, .skill-card.is-selected, .levain-card.is-selected {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}

/* Levain question — simpler 2-column choice on step 1 */
.levain-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
@media (max-width: 540px) {
  .levain-grid { grid-template-columns: 1fr; }
}
.levain-icon { font-size: 1.4rem; }
.levain-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--color-text);
}
.levain-detail {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}
.budget-icon { font-size: 1.4rem; }
.budget-title, .skill-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--color-text);
}
.budget-time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.budget-detail, .skill-detail {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.temp-card { align-items: center; text-align: center; padding: var(--space-4) var(--space-3); }
.temp-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-text);
  letter-spacing: -0.02em;
}
.temp-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
}

/* ---------- ADVANCED TOGGLE ---------- */
.advanced {
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-divider);
}
.advanced summary {
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before {
  content: '+';
  font-family: var(--font-mono);
  color: var(--color-primary);
  font-weight: 700;
}
.advanced[open] summary::before { content: '−'; }
.advanced-body { margin-top: var(--space-4); }
.advanced-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0;
}

/* ============================================================
   PLAN OUTPUT
============================================================ */
.plan {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.plan-hero {
  background: linear-gradient(135deg, var(--color-primary-highlight) 0%, var(--color-surface) 100%);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  border: 1px solid var(--color-primary);
}
[data-theme='dark'] .plan-hero {
  background: linear-gradient(135deg, var(--color-primary-highlight) 0%, var(--color-surface-offset) 100%);
}
.plan-hero-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-primary);
  font-weight: 700;
  margin-bottom: var(--space-2);
  display: block;
}
.plan-hero h2 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
  letter-spacing: -0.02em;
}
.plan-hero-summary {
  color: var(--color-text);
  font-size: var(--text-base);
  line-height: 1.5;
  margin-bottom: var(--space-5);
  max-width: 60ch;
}

.plan-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-4);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-primary);
  border-color: rgba(197, 121, 58, 0.3);
}
.plan-stat { display: flex; flex-direction: column; gap: var(--space-1); }
.plan-stat-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-text);
  letter-spacing: -0.02em;
  line-height: 1;
}
.plan-stat-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}

/* ---------- WINDOW CALLOUT (start → finish) ---------- */
.window-callout {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.window-callout-ok {
  border-color: var(--color-divider);
}
.window-callout-tight {
  border-color: var(--color-warning);
  background: var(--color-warning-light);
}
.window-callout-warn {
  border-color: var(--color-error);
  background: var(--color-error-light);
}
.window-rail {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}
.window-point {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 180px;
}
.window-point-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}
.window-point-time {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.1;
}
.window-point-end .window-point-time {
  color: var(--color-primary);
}
.window-point-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: 2px;
}
.window-arrow {
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.window-summary {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--color-text);
}
.window-summary strong { color: var(--color-text); }
@media (max-width: 540px) {
  .window-rail { gap: var(--space-3); }
  .window-arrow { display: none; }
  .window-point-time { font-size: var(--text-lg); }
}

/* ---------- SUGGESTION CALLOUT ---------- */
.suggestion-callout {
  background: var(--color-surface-2);
  border: 1px dashed var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.suggestion-body strong {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-base);
  color: var(--color-primary);
  margin-bottom: var(--space-1);
}
.suggestion-body p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--color-text);
}
.btn-link {
  align-self: flex-start;
  background: var(--color-primary);
  color: var(--color-on-primary, #fff);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.btn-link:hover { filter: brightness(0.93); }

/* ---------- WARNINGS ---------- */
.warnings { display: flex; flex-direction: column; gap: var(--space-2); }
.warning {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
  border: 1px solid;
}
.warning-medium {
  background: var(--color-warning-light);
  border-color: var(--color-warning);
  color: var(--color-text);
}
.warning-high {
  background: var(--color-error-light);
  border-color: var(--color-error);
  color: var(--color-text);
}
.warning-icon { flex-shrink: 0; font-size: 1.1rem; }

/* ---------- FORMULA TABLE ---------- */
.section-block {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.section-block h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-1);
}
.section-block-sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-5) 0;
}

.formula-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.formula-table th, .formula-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-divider);
}
.formula-table th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  font-weight: 600;
}
.formula-table td {
  color: var(--color-text);
}
.formula-table .col-amount {
  font-family: var(--font-mono);
  text-align: right;
  font-weight: 500;
}
.formula-table .col-pct {
  font-family: var(--font-mono);
  text-align: right;
  color: var(--color-text-muted);
}
.formula-table tr:last-child td { border-bottom: none; }
.formula-table .total-row td {
  font-weight: 700;
  border-top: 2px solid var(--color-text);
  border-bottom: none;
  padding-top: var(--space-4);
}
@media (max-width: 540px) {
  .formula-table th, .formula-table td { padding: var(--space-2) var(--space-2); font-size: var(--text-xs); }
  .formula-table th { font-size: 0.65rem; }
}

/* ---------- SCHEDULE ---------- */
.schedule {
  display: flex;
  flex-direction: column;
}
.schedule-step {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--space-5);
  padding: var(--space-5) 0;
  border-bottom: 1px dashed var(--color-divider);
  position: relative;
}
.schedule-step:last-child { border-bottom: none; }
.step-time {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-items: flex-start;
}
.step-time-text {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.step-duration {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.step-tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: var(--space-2);
}
.step-tag-active {
  background: var(--color-primary-highlight);
  color: var(--color-primary-active);
}
[data-theme='dark'] .step-tag-active {
  color: var(--color-primary);
}
.step-tag-passive {
  background: var(--color-sage-light);
  color: var(--color-sage);
}

.step-body {
  padding-left: var(--space-5);
  border-left: 2px solid var(--color-divider);
}
.schedule-step.is-active-step .step-body { border-left-color: var(--color-primary); }
.schedule-step.is-passive .step-body { border-left-color: var(--color-sage); border-left-style: dashed; }

.step-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text);
  letter-spacing: -0.01em;
}
.step-description {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.55;
  margin-bottom: var(--space-3);
}
.step-cue {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-sage);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.cue-icon { color: var(--color-sage); flex-shrink: 0; font-weight: 700; }
.step-cue + .step-cue { margin-top: var(--space-2); }
.step-cue-next { border-left-color: var(--color-primary); }
.step-cue-next .cue-icon { color: var(--color-primary); }

@media (max-width: 640px) {
  .schedule-step {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .step-body {
    padding-left: var(--space-4);
  }
}

/* ---------- REASONING ---------- */
.reasoning {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.reasoning ul {
  margin: var(--space-3) 0 0 0;
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.reasoning li {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--color-text);
}
.reasoning li strong {
  color: var(--color-primary);
  font-family: var(--font-display);
  font-weight: 600;
}

/* ============================================================
   HOW IT WORKS
============================================================ */
.how {
  padding: clamp(4rem, 8vw, 8rem) 0;
}
.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-10);
}
.how-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.how-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}
.how-num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: var(--space-3);
}
.how-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-3);
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.how-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.55;
  margin: 0;
}

/* ============================================================
   DATA SECTION
============================================================ */
.data {
  padding: clamp(4rem, 8vw, 8rem) 0;
  background: var(--color-surface-offset);
  border-top: 1px solid var(--color-divider);
  border-bottom: 1px solid var(--color-divider);
}
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-8);
}
.data-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: border-color 0.2s ease;
}
.data-card:hover { border-color: var(--color-primary); }
.data-stat {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.03em;
  line-height: 0.95;
  margin-bottom: var(--space-2);
}
.data-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text);
  font-weight: 600;
  margin-bottom: var(--space-3);
}
.data-detail {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.data-source {
  margin-top: var(--space-10);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.7;
  padding-top: var(--space-6);
  border-top: 1px dashed var(--color-divider);
}
.data-source a { color: var(--color-text-muted); text-decoration: underline; text-underline-offset: 2px; }
.data-source a:hover { color: var(--color-primary); }

/* ============================================================
   FOOTER
============================================================ */
.footer {
  padding: var(--space-8) 0;
  background: var(--color-bg);
}
.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.footer-brand {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-text);
}
.footer-meta { font-family: var(--font-mono); }

/* ============================================================
   FOCUS STYLES
============================================================ */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   PRINT STYLES — clean recipe printout
============================================================ */
@media print {
  /* Force light-theme palette for print regardless of current theme.
     Without this, dark-mode users get dark-on-white text in saved PDFs. */
  :root, [data-theme="dark"], html[data-theme="dark"] {
    --color-bg: #ffffff !important;
    --color-surface: #ffffff !important;
    --color-surface-2: #ffffff !important;
    --color-surface-offset: #f6efe1 !important;
    --color-surface-offset-2: #ede4d0 !important;
    --color-border: #c8b78e !important;
    --color-text: #1f1710 !important;
    --color-text-muted: #4a3d28 !important;
    --color-text-faint: #6b5840 !important;
    --color-primary: #a85e22 !important;
    --color-primary-hover: #804619 !important;
    --color-primary-active: #804619 !important;
    --color-primary-highlight: #f0d9bc !important;
  }

  /* Ensure backgrounds/colors actually print (Chrome strips them by default). */
  *, *::before, *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  @page {
    size: A4;
    margin: 14mm 12mm;
  }

  html, body {
    background: #ffffff !important;
    color: var(--color-text) !important;
    font-size: 10.5pt;
    line-height: 1.45;
  }

  /* Hide all UI chrome that doesn't belong on paper. */
  .topbar,
  .hero,
  .how,
  .data,
  .footer,
  .wizard-rail,
  .wizard-stage > .step-header + .step-actions,
  .step-actions,
  .advanced,
  .download-actions,
  .window-callout-warn,
  .window-callout-tight .window-rail-fill,
  .suggestion-callout,
  button,
  [data-back],
  [data-next],
  [data-restart],
  [data-adjust] {
    display: none !important;
  }

  /* Hide every wizard step except the active plan step. */
  .step:not(.is-active) { display: none !important; }

  .wizard, .wizard-shell, .wizard-stage, .step.is-active {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    border: none !important;
    grid-template-columns: 1fr !important;
  }

  /* Plan card: tighten and remove decorative shadows. */
  .plan, .plan-hero, .window-callout, .section-block {
    background: #ffffff !important;
    box-shadow: none !important;
    border: 1px solid var(--color-border) !important;
    margin-bottom: 10pt !important;
    padding: 10pt 12pt !important;
  }
  .plan-hero, .window-callout {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  /* Allow long sections (schedule, sanity check) to break across pages
     so we don't waste a half-page of whitespace. Individual items inside
     are still protected via their own break-inside: avoid below. */

  .plan-hero h2 {
    font-size: 16pt !important;
    line-height: 1.2 !important;
    margin: 4pt 0 6pt 0 !important;
  }
  .plan-hero-summary { margin: 0 0 8pt 0 !important; }
  .plan-hero-eyebrow { color: var(--color-primary) !important; font-size: 8pt !important; }

  /* Stat row: keep on one line; ensure the orange numbers print orange. */
  .plan-stats {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 6pt !important;
    border-top: 1px solid var(--color-border) !important;
    padding-top: 8pt !important;
  }
  .plan-stat-num { font-size: 13pt !important; color: var(--color-text) !important; }
  .plan-stat-label { font-size: 7.5pt !important; color: var(--color-text-muted) !important; }

  /* Window callout: keep the orange dates legible. */
  .window-callout { border-color: var(--color-primary) !important; }
  .window-point-time { color: var(--color-text) !important; }
  .window-point-finish .window-point-time { color: var(--color-primary) !important; }

  /* Section headings */
  h2, h3, h4 {
    color: var(--color-text) !important;
    page-break-after: avoid;
    break-after: avoid;
  }

  /* Schedule timeline: don't split a single step across pages. */
  .timeline, .schedule { display: block !important; }
  .timeline-item, .schedule-item, .schedule-step, .step-row, .step-card {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-bottom: 6pt !important;
  }
  .timeline-item *, .schedule-step * { color: var(--color-text) !important; }
  .step-tag-active, .step-tag-passive {
    color: var(--color-text) !important;
    background: var(--color-surface-offset) !important;
  }

  /* Reasoning bullets — let them flow; only protect against splitting
     a single bullet's text across pages. */
  .reasoning-list li, .section-block ul li {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 3pt !important;
  }
  /* Sanity check is short — keep the entire list on the page that holds
     its heading, rather than orphaning a single bullet. */
  .section-block ul {
    page-break-inside: auto;
    break-inside: auto;
  }
  /* Avoid an orphan heading: keep the H3 with its first content. */
  .section-block h3 + p, .section-block h3 + .section-block-sub {
    page-break-before: avoid;
    break-before: avoid;
  }

  /* Formula table */
  table { width: 100% !important; border-collapse: collapse !important; }
  th, td { padding: 4pt 6pt !important; color: var(--color-text) !important; }

  /* Strip link decoration on print */
  a, a:visited { color: var(--color-text) !important; text-decoration: none !important; }
}
