/* =====================================================================
   Gaussienne — design tokens
   Light theme by default; dark theme via [data-theme="dark"] or system pref.
   ===================================================================== */

:root {
  /* --- Light theme (default) --- */
  --bg: #f5f9ff;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #eef4fc;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-border: rgba(37, 99, 235, 0.22);
  --accent-fg: #ffffff;
  --accent-rgb: 37, 99, 235;
  --shadow-color: 15, 23, 42;

  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.1);
  --success-border: rgba(21, 128, 61, 0.3);
  --error: #dc2626;
  --error-soft: rgba(220, 38, 38, 0.08);
  --error-border: rgba(220, 38, 38, 0.3);
  --warning: #b45309;
  --warning-soft: rgba(180, 83, 9, 0.08);
  --warning-border: rgba(180, 83, 9, 0.3);

  --header-bg: rgba(245, 249, 255, 0.85);
  --hero-glow: radial-gradient(
    ellipse 1200px 600px at 50% -240px,
    rgba(37, 99, 235, 0.08),
    transparent
  );
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-md: 0 4px 16px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 16px 48px rgb(15 23 42 / 0.1);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.15);

  /* Type */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
  --display: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --container-pad: clamp(20px, 4vw, 56px);
  --content-max: 1280px;
  --reading-max: 880px;
}

/* --- Dark theme --- */
:root[data-theme="dark"] {
  --bg: #0a1428;
  --bg-elevated: #0f1f3a;
  --bg-card: #112442;
  --bg-subtle: #0d1b34;

  --border: #1e3658;
  --border-strong: #2e4d75;

  --text: #e6edf7;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.12);
  --accent-border: rgba(96, 165, 250, 0.3);
  --accent-fg: #0a1428;
  --accent-rgb: 96, 165, 250;
  --shadow-color: 0, 0, 0;

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --success-border: rgba(74, 222, 128, 0.35);
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, 0.1);
  --error-border: rgba(248, 113, 113, 0.35);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --warning-border: rgba(251, 191, 36, 0.35);

  --header-bg: rgba(10, 20, 40, 0.85);
  --hero-glow: radial-gradient(
    ellipse 1200px 600px at 50% -240px,
    rgba(96, 165, 250, 0.1),
    transparent
  );
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 8px 24px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.45);
  --ring: 0 0 0 3px rgba(96, 165, 250, 0.22);
}

/* Honor system pref when no explicit override is set. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1428;
    --bg-elevated: #0f1f3a;
    --bg-card: #112442;
    --bg-subtle: #0d1b34;

    --border: #1e3658;
    --border-strong: #2e4d75;

    --text: #e6edf7;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --accent: #60a5fa;
    --accent-strong: #93c5fd;
    --accent-soft: rgba(96, 165, 250, 0.12);
    --accent-border: rgba(96, 165, 250, 0.3);
    --accent-fg: #0a1428;

    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.12);
    --success-border: rgba(74, 222, 128, 0.35);
    --error: #f87171;
    --error-soft: rgba(248, 113, 113, 0.1);
    --error-border: rgba(248, 113, 113, 0.35);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --warning-border: rgba(251, 191, 36, 0.35);

    --header-bg: rgba(10, 20, 40, 0.85);
    --hero-glow: radial-gradient(
      ellipse 1200px 600px at 50% -240px,
      rgba(96, 165, 250, 0.1),
      transparent
    );
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 8px 24px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 16px 48px rgb(0 0 0 / 0.45);
    --ring: 0 0 0 3px rgba(96, 165, 250, 0.22);
  }
}

/* =====================================================================
   Base
   ===================================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
}

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    var(--hero-glow),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* Container — fluid and full-width by default. */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--container-pad);
}

/* =====================================================================
   Header
   ===================================================================== */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.brand-mark {
  font-size: 26px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}

.brand-name {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Stepper */
.stepper {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 6px;
  align-items: center;
  counter-reset: step;
  flex-wrap: wrap;
  justify-content: center;
}

.stepper li {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
  padding: 6px 12px 6px 30px;
  border-radius: 999px;
  position: relative;
  transition: color 200ms, background 200ms;
  counter-increment: step;
  white-space: nowrap;
}

.stepper li::before {
  content: counter(step);
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 200ms, border-color 200ms, color 200ms;
}

.stepper li.done {
  color: var(--text-muted);
}

.stepper li.done::before {
  content: "✓";
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.stepper li.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.stepper li.active::before {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    color 200ms cubic-bezier(0.4, 0, 0.2, 1),
    background 200ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 200ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 160ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow:
    0 4px 10px rgb(var(--shadow-color) / 0.06),
    0 0 0 3px var(--accent-soft);
}

.theme-toggle:active {
  transform: translateY(0) rotate(-15deg);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.theme-icon {
  width: 18px;
  height: 18px;
  transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover .theme-icon {
  transform: rotate(20deg);
}

.theme-icon-sun {
  display: none;
}

.theme-icon-moon {
  display: inline-block;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: inline-block;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun {
    display: inline-block;
  }
  :root:not([data-theme="light"]) .theme-icon-moon {
    display: none;
  }
}

@media (max-width: 860px) {
  .stepper li {
    font-size: 0;
    padding: 6px 6px 6px 22px;
    width: 28px;
  }
}

/* =====================================================================
   Step containers
   ===================================================================== */

.step {
  padding: 56px 0 80px;
  animation: stepIn 240ms ease-out;
}

.step.hidden {
  display: none;
}

.step-header {
  margin-bottom: 36px;
  max-width: var(--reading-max);
}

.step-header h1 {
  font-family: var(--display);
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 700;
  line-height: 1.1;
  margin: 0 0 14px;
  letter-spacing: -0.025em;
  color: var(--text);
}

.lede {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
  max-width: 720px;
}

.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  gap: 16px;
}

@keyframes stepIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================================================================
   Cards
   ===================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.badge.optional {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-strong);
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 18px;
}

.small {
  font-size: 13px;
}

/* =====================================================================
   Forms
   ===================================================================== */

textarea,
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  transition: border-color 120ms, box-shadow 120ms;
}

textarea {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
}

textarea:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

textarea::placeholder,
input[type="text"]::placeholder {
  color: var(--text-dim);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

/* =====================================================================
   Step 1 — upload grid + dropzones
   ===================================================================== */

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.upload-grid > .card {
  margin-bottom: 0;
  transition:
    transform 220ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 220ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.upload-grid > .card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.upload-area {
  position: relative;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 36px 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  cursor: pointer;
  text-align: center;
  transition:
    border-color 200ms cubic-bezier(0.4, 0, 0.2, 1),
    background 200ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.dropzone:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.upload-area.dragover .dropzone {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.dropzone-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  margin-bottom: 8px;
  flex-shrink: 0;
  transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
}

.dropzone:hover .dropzone-icon,
.upload-area.dragover .dropzone-icon {
  transform: translateY(-3px) scale(1.06);
}

.dropzone-primary {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.dropzone-secondary {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* File list */
.file-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.file-list:empty {
  display: none;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13.5px;
  transition: border-color 120ms;
}

.file-item:hover {
  border-color: var(--border-strong);
}

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}

.file-size {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.file-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 120ms, background 120ms;
}

.file-remove:hover {
  color: var(--error);
  background: var(--error-soft);
}

/* Paste-text disclosure (legacy) */
.paste-toggle {
  margin-top: 14px;
}

.paste-toggle summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 0;
  user-select: none;
  list-style: none;
}

.paste-toggle summary::-webkit-details-marker {
  display: none;
}

.paste-toggle summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
  transition: transform 120ms;
}

.paste-toggle[open] summary::before {
  transform: rotate(90deg);
}

.paste-toggle summary:hover {
  color: var(--text);
}

.paste-toggle textarea {
  margin-top: 10px;
}

/* =====================================================================
   Buttons
   ===================================================================== */

.action-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 32px 0;
}

.btn {
  --btn-ease: cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: -0.005em;
  white-space: nowrap;
  user-select: none;
  transition:
    background 200ms var(--btn-ease),
    border-color 200ms var(--btn-ease),
    color 200ms var(--btn-ease),
    transform 140ms var(--btn-ease),
    box-shadow 200ms var(--btn-ease);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* Primary — solid accent + inner highlight, lift + ring on hover */
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.18),
    0 1px 2px rgb(var(--shadow-color) / 0.08);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.22),
    0 8px 18px rgb(var(--accent-rgb) / 0.32),
    0 0 0 4px var(--accent-soft);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.12),
    0 1px 2px rgb(var(--shadow-color) / 0.1);
}

/* Ghost — secondary, fills with accent on hover */
.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow:
    0 4px 12px rgb(var(--shadow-color) / 0.06),
    0 0 0 3px var(--accent-soft);
}

.btn-ghost:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-lg {
  padding: 14px 32px;
  font-size: 15.5px;
  border-radius: var(--radius);
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  gap: 4px;
}

/* Animated direction arrows — opt in via data-arrow="next" or "prev" */
.btn[data-arrow]::before,
.btn[data-arrow]::after {
  display: inline-block;
  font-weight: 600;
  line-height: 1;
  transition: transform 240ms var(--btn-ease);
  will-change: transform;
}

.btn[data-arrow="next"]::after {
  content: "→";
  margin-left: 4px;
}

.btn[data-arrow="prev"]::before {
  content: "←";
  margin-right: 4px;
}

.btn[data-arrow="next"]:hover:not(:disabled)::after {
  transform: translateX(4px);
}

.btn[data-arrow="prev"]:hover:not(:disabled)::before {
  transform: translateX(-4px);
}

.btn[data-arrow]:active:not(:disabled)::after,
.btn[data-arrow]:active:not(:disabled)::before {
  transform: translateX(0);
}

/* Status block */
.status {
  margin: -16px 0 32px;
  padding: 14px 18px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: opacity 120ms;
  display: none;
}

.status:not(:empty) {
  display: block;
}

.status[data-kind="loading"] {
  color: var(--text);
  border-left-color: var(--accent);
}

.status[data-kind="error"] {
  color: var(--error);
  border-left-color: var(--error);
  background: var(--error-soft);
}

.status[data-kind="success"] {
  color: var(--success);
  border-left-color: var(--success);
}

/* Spinner */
.btn.loading {
  cursor: wait;
}

.btn.loading > * {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.spinner {
  width: 14px;
  height: 14px;
  margin-right: 10px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* =====================================================================
   Step 2 — chips
   ===================================================================== */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition:
    color 180ms cubic-bezier(0.4, 0, 0.2, 1),
    background 180ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 180ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 120ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

.chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.chip:active {
  transform: translateY(0);
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* =====================================================================
   Step 3 — Ruminating
   ===================================================================== */

.ruminate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 0 120px;
  min-height: 60vh;
}

.ruminate[hidden] {
  display: none;
}

.ruminate-orbit {
  position: relative;
  width: 220px;
  height: 220px;
  margin-bottom: 40px;
}

.orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  border-top-color: var(--accent);
  border-right-color: var(--accent-strong);
  transform: translate(-50%, -50%);
  animation: orbitSpin linear infinite;
}

.orbit-1 {
  width: 220px;
  height: 220px;
  border-width: 1px;
  animation-duration: 4s;
  opacity: 0.6;
}

.orbit-2 {
  width: 160px;
  height: 160px;
  border-width: 1.5px;
  animation-duration: 3s;
  animation-direction: reverse;
  opacity: 0.8;
}

.orbit-3 {
  width: 100px;
  height: 100px;
  border-width: 2px;
  animation-duration: 2s;
}

.orbit-core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--accent);
  animation: corePulse 2.4s ease-in-out infinite;
}

@keyframes orbitSpin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes corePulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--accent-soft);
  }
  50% {
    box-shadow: 0 0 0 18px transparent;
  }
}

.ruminate-title {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.025em;
  color: var(--text);
}

.ruminate-status {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 500;
  color: var(--accent);
  margin: 0 0 8px;
  min-height: 1.4em;
  transition: opacity 200ms;
}

.ruminate-flavor {
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0;
  min-height: 1.4em;
}

/* =====================================================================
   Step 4 — Exam (interactive)
   ===================================================================== */

.exam-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.exam-banner h1 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  color: var(--text);
}

.exam-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.question-card-wrap {
  margin-bottom: 32px;
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

.question-progress {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  padding: 0 4px;
}

.question-progress span:first-child {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.question-section {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-muted);
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px;
  box-shadow: var(--shadow-md);
  min-height: 360px;
}

.q-heading {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 18px;
  letter-spacing: -0.005em;
}

.q-prose {
  font-size: 16px;
  line-height: 1.65;
  margin-bottom: 24px;
  color: var(--text);
}

.q-points {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 6px;
}

/* QCM choices */
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    border-color 180ms cubic-bezier(0.4, 0, 0.2, 1),
    background 180ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 180ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 120ms cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 15px;
  line-height: 1.55;
  user-select: none;
}

.choice-row:active {
  transform: scale(0.99);
}

.choice-row:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.choice-row input[type="radio"] {
  display: none;
}

.choice-marker {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
  position: relative;
  transition: border-color 120ms;
}

.choice-row:hover .choice-marker {
  border-color: var(--accent);
}

.choice-row.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--ring);
}

.choice-row.selected .choice-marker {
  border-color: var(--accent);
}

.choice-row.selected .choice-marker::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.choice-text {
  flex: 1;
}

/* V/F buttons */
.vf-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
}

.vf-btn {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 22px 56px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition:
    border-color 220ms cubic-bezier(0.4, 0, 0.2, 1),
    background 220ms cubic-bezier(0.4, 0, 0.2, 1),
    color 220ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 140ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 220ms cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 180px;
}

.vf-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow:
    0 8px 20px rgb(var(--accent-rgb) / 0.18),
    0 0 0 4px var(--accent-soft);
}

.vf-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.vf-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 0 0 4px var(--accent-soft);
}

/* Open question inputs */
.subparts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 22px;
  padding-left: 6px;
}

.subpart {
  display: flex;
  gap: 10px;
  font-size: 15.5px;
  line-height: 1.6;
}

.subpart-label {
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.subpart-prose {
  color: var(--text);
}

.open-input {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.answer-textarea {
  width: 100%;
  min-height: 140px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
}

.image-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.image-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: color 120ms, border-color 120ms, background 120ms;
}

.image-upload-btn:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.image-upload-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.image-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
}

.image-remove:hover {
  color: var(--error);
}

.answer-image-preview {
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: contain;
  background: #fff;
}

/* Question navigation */
.question-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 999px;
  width: 0;
  transition: width 240ms ease-out;
}

.exam-bottom {
  display: flex;
  justify-content: center;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

/* =====================================================================
   Step 5 — Results
   ===================================================================== */

.results {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.results-summary {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  grid-template-areas:
    "grade skills"
    "grade feedback"
    "actions actions";
  gap: 24px;
  align-items: start;
}

.results-summary > .grade-card {
  grid-area: grade;
}

/* Summary and mistakes views are full-screen swaps — without these the
   `hidden` attribute is overridden by display: grid/flex above. */
.results-summary[hidden],
.results-mistakes[hidden] {
  display: none;
}

.results-summary > .skills-card {
  grid-area: skills;
}

.results-summary > .feedback-card {
  grid-area: feedback;
}

.results-summary > .results-actions {
  grid-area: actions;
}

.grade-card {
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

/* Big Swiss federal note (X / 6) */
.grade-note {
  font-family: var(--display);
  font-size: 72px;
  line-height: 1;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.04em;
}
.grade-note-divider {
  color: var(--text-dim);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0;
  margin-left: 4px;
}

/* Raw points calc, italic, smaller */
.grade-points {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 10px;
}
.grade-points em {
  font-style: italic;
}
.grade-percent {
  color: var(--text-dim);
  margin-left: 4px;
}

.grade-label {
  font-size: 11.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 14px;
  font-weight: 600;
}

.feedback-card .profile-summary {
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--text);
  margin: 0;
}

/* Skills */
.skills-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skill-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.skill-rating {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.skill-pos .skill-rating {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.skill-neg .skill-rating {
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.skill-neu .skill-rating {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}

.skill-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.skill-name {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
}

.skill-comment {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

.skill-comment p {
  margin: 0;
}

.results-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

/* Mistakes view */
.results-mistakes {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.mistakes-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.mistakes-counter {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
}

.review-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.review-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 18px 20px;
}

.review-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.review-badge {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.review-badge.correct {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.review-badge.partial {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.review-badge.wrong {
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.review-title {
  font-weight: 600;
  font-size: 15.5px;
}

.review-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 14.5px;
}

.review-prose {
  color: var(--text-muted);
}

.review-row {
  display: flex;
  gap: 12px;
  font-size: 14px;
}

.review-label {
  flex-shrink: 0;
  width: 130px;
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding-top: 2px;
}

.review-value {
  color: var(--text);
  white-space: pre-wrap;
}

.review-section h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
}

.review-section .md p {
  margin: 0 0 8px;
}

.review-section .md p:last-child {
  margin-bottom: 0;
}

.review-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.review-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
}

.review-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  align-self: flex-start;
}

/* Floating chat */
.chat-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 120ms;
}

.chat-toggle:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.chat-toggle svg {
  width: 18px;
  height: 18px;
}

.chat-toggle[hidden] {
  display: none;
}

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 31;
  width: min(420px, calc(100vw - 48px));
  height: min(620px, calc(100vh - 48px));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 8px;
}

.chat-panel[hidden] {
  display: none;
}

.chat-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-panel-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chat-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}

.chat-close:hover {
  color: var(--text);
}

.chat-hint {
  margin: 0 0 4px;
}

.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 8px 4px;
}

.chat-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.55;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--text);
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
}

.chat-bubble p:first-child,
.chat-bubble h1:first-child,
.chat-bubble h2:first-child,
.chat-bubble h3:first-child,
.chat-bubble h4:first-child,
.chat-bubble ul:first-child,
.chat-bubble ol:first-child {
  margin-top: 0;
}

.chat-bubble p:last-child,
.chat-bubble h1:last-child,
.chat-bubble h2:last-child,
.chat-bubble h3:last-child,
.chat-bubble h4:last-child,
.chat-bubble ul:last-child,
.chat-bubble ol:last-child {
  margin-bottom: 0;
}

.chat-bubble h1, .chat-bubble h2, .chat-bubble h3,
.chat-bubble h4, .chat-bubble h5, .chat-bubble h6 {
  font-size: 15px;
  font-weight: 600;
  margin: 12px 0 6px;
  color: var(--text);
}
.chat-bubble ul, .chat-bubble ol {
  margin: 8px 0;
  padding-left: 22px;
}
.chat-bubble li { margin-bottom: 3px; }

/* Same for the in-mistake "Solution / Why / Assessment" markdown blocks */
.review-section .md h1,
.review-section .md h2,
.review-section .md h3,
.review-section .md h4,
.review-section .md h5,
.review-section .md h6 {
  font-size: 15px;
  font-weight: 600;
  margin: 10px 0 4px;
  color: var(--text);
}
.review-section .md ul, .review-section .md ol {
  margin: 6px 0;
  padding-left: 22px;
}

.chat-bubble code {
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 13px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  resize: vertical;
  min-height: 56px;
}

/* =====================================================================
   Output / iframe (legacy / PDF preview)
   ===================================================================== */

.output-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-md);
}

.output-card.hidden {
  display: none;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.output-header h2 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.output-actions {
  display: flex;
  gap: 8px;
}

.output-actions .btn {
  padding: 8px 14px;
  font-size: 13px;
}

.exam-iframe {
  width: 100%;
  height: 80vh;
  min-height: 600px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
}

/* =====================================================================
   Prose (rendered markdown)
   ===================================================================== */

.prose {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
}

.prose h1 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.prose h2 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.prose h3 {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text);
}

.prose p {
  margin: 0 0 14px;
}

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

.prose em {
  color: var(--text);
  font-style: italic;
}

.prose ul,
.prose ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.prose li {
  margin-bottom: 6px;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 2px 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
}

.prose pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.55;
}

.prose pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  margin: 16px 0;
  padding: 4px 16px;
  color: var(--text-muted);
}

.prose .katex {
  font-size: 1.05em;
}

.prose .katex-display {
  margin: 18px 0;
}

/* =====================================================================
   Footer
   ===================================================================== */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 80px;
}

.site-footer .muted {
  margin: 0;
  text-align: center;
}

/* =====================================================================
   Utilities
   ===================================================================== */

.hidden {
  display: none;
}

/* =====================================================================
   Responsive
   ===================================================================== */

@media (max-width: 860px) {
  .header-row {
    height: auto;
    min-height: 64px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .results-summary {
    grid-template-columns: 1fr;
    grid-template-areas:
      "grade"
      "skills"
      "feedback"
      "actions";
  }
  .results-summary > .grade-card {
    position: static;
  }
}

@media (max-width: 640px) {
  :root {
    --container-pad: 18px;
  }
  .step {
    padding: 36px 0 56px;
  }
  .step-header h1 {
    font-size: 30px;
  }
  .lede {
    font-size: 15.5px;
  }
  .card,
  .output-card,
  .question-card {
    padding: 22px;
  }
  .output-header,
  .exam-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .vf-btn {
    padding: 18px 32px;
    font-size: 16px;
    min-width: 130px;
  }
  .ruminate-orbit {
    width: 160px;
    height: 160px;
  }
  .orbit-1 {
    width: 160px;
    height: 160px;
  }
  .orbit-2 {
    width: 116px;
    height: 116px;
  }
  .orbit-3 {
    width: 72px;
    height: 72px;
  }
  .review-row {
    flex-direction: column;
    gap: 4px;
  }
  .review-label {
    width: auto;
  }
}

/* =====================================================================
   Reduced motion — honor user preference
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover,
  .btn-ghost:hover,
  .btn-primary:hover,
  .vf-btn:hover,
  .chip:hover,
  .upload-grid > .card:hover,
  .theme-toggle:hover {
    transform: none !important;
  }
}

/* =====================================================================
   Print — exam PDF export (force light print regardless of theme)
   ===================================================================== */

@media print {
  @page {
    size: A4;
    margin: 2.5cm 2cm;
  }

  .site-header,
  .site-footer,
  .hero,
  .card,
  .action-row,
  .status,
  .output-header,
  .nav,
  .paste-toggle,
  .theme-toggle,
  .chat-toggle,
  .chat-panel {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .container {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .output-card {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .prose {
    font-family: "Latin Modern Roman", "EB Garamond", Cambria, Georgia,
      "Times New Roman", serif;
    font-size: 11pt;
    line-height: 1.45;
    color: #000000 !important;
  }

  .prose h1 {
    font-family: "Latin Modern Roman", "EB Garamond", Cambria, Georgia,
      "Times New Roman", serif;
    font-size: 16pt;
    font-weight: 700;
    text-align: center;
    margin: 0 0 0.6em;
    padding-bottom: 0.4em;
    border-bottom: 1px solid #000;
    color: #000 !important;
    letter-spacing: 0;
  }

  .prose h2 {
    font-family: "Latin Modern Roman", "EB Garamond", Cambria, Georgia,
      "Times New Roman", serif;
    font-size: 12pt;
    font-weight: 700;
    margin: 1.4em 0 0.4em;
    color: #000 !important;
    page-break-after: avoid;
    break-after: avoid;
  }

  .prose h3 {
    font-size: 11pt;
    font-weight: 700;
    margin: 1em 0 0.3em;
    color: #000 !important;
    page-break-after: avoid;
    break-after: avoid;
  }

  .prose p {
    margin: 0 0 0.6em;
    orphans: 2;
    widows: 2;
  }

  .prose strong {
    color: #000 !important;
  }

  .prose hr {
    border: none;
    border-top: 0.5px solid #000;
    margin: 1.2em 0;
  }

  .prose blockquote,
  .prose pre,
  .prose ul,
  .prose ol {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .prose blockquote {
    border-left: 2px solid #000;
    color: #000 !important;
    font-style: italic;
    padding: 4px 12px;
    margin: 0.8em 0;
  }

  .prose code {
    background: transparent !important;
    border: none !important;
    color: #000 !important;
    padding: 0;
    font-family: "Latin Modern Mono", Consolas, "Courier New", monospace;
    font-size: 10pt;
  }

  .prose pre {
    background: #f5f5f5 !important;
    border: 1px solid #ccc !important;
    color: #000 !important;
    padding: 8px 12px;
    font-size: 10pt;
  }

  .prose .katex,
  .prose .katex * {
    color: #000 !important;
  }

  .prose h2,
  .prose h3 {
    page-break-after: avoid;
    break-after: avoid;
  }
}

/* =====================================================================
   Modal — confirm dialog
   ===================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modal-fade 0.18s ease;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modal-pop 0.18s ease;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.modal-message {
  margin: 0 0 16px;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin: 0 0 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
}
.modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.modal-input[hidden] { display: none; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
