:root {
  --primary: #1DAFF7;
  --primary-deep: #0A3D66;
  --dark: #0B1E33;       /* fixed: header bar background — stays dark navy in both themes, it's a brand anchor, not a "page surface" */
  --dark-fill: #0059AA;
  --gray: #5B748F;
  --gray-soft: #8CA0B8;
  --success: #10B981;
  --risk: #F59E0B;

  /* semantic, theme-aware tokens — these are what actually flip below */
  --page-bg: #F3F8FE;
  --card-bg: #FFFFFF;
  --input-bg: #F3F8FE;
  --input-bg-focus: #FFFFFF;
  --text: #0B1E33;
  --border: #E6EDF5;
  --light: var(--page-bg); /* kept as an alias — some rules below still reference --light directly */
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: #0D1B2E;
    --card-bg: #16273F;
    --input-bg: #0D1B2E;
    --input-bg-focus: #16273F;
    --text: #E6EDF5;
    --border: #28405F;
    --gray: #93A8C2;
    --gray-soft: #6E86A4;
    --primary-deep: #7FCFFB; /* labels/accents need to lighten to keep contrast on a dark card */
  }
}
:root[data-theme="dark"] {
  --page-bg: #0D1B2E;
  --card-bg: #16273F;
  --input-bg: #0D1B2E;
  --input-bg-focus: #16273F;
  --text: #E6EDF5;
  --border: #28405F;
  --gray: #93A8C2;
  --gray-soft: #6E86A4;
  --primary-deep: #7FCFFB;
}
:root[data-theme="light"] {
  --page-bg: #F3F8FE;
  --card-bg: #FFFFFF;
  --input-bg: #F3F8FE;
  --input-bg-focus: #FFFFFF;
  --text: #0B1E33;
  --border: #E6EDF5;
  --gray: #5B748F;
  --gray-soft: #8CA0B8;
  --primary-deep: #0A3D66;
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  margin: 0;
  padding: 0;
}

header {
  background: var(--dark);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  position: relative;
}
header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--dark-fill));
}

header .logo-badge {
  background: var(--primary);
  color: white;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
}

header h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 600;
  opacity: 0.92;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* --- step indicator ------------------------------------------------- */

.steps {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}
.step {
  flex: 1;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray-soft);
  padding-bottom: 0.6rem;
  border-bottom: 3px solid var(--border);
  transition: color 0.2s, border-color 0.2s;
}
.step.active { color: var(--primary-deep); border-color: var(--primary); }
.step.done { color: var(--gray); border-color: var(--dark-fill); }

/* --- card ------------------------------------------------------------ */

.card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 2.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 12px 32px -12px rgba(11, 30, 51, 0.14);
}

h2 { margin: 0 0 0.4rem; font-size: 1.45rem; letter-spacing: -0.01em; }

p.hint { color: var(--gray); font-size: 0.92rem; line-height: 1.5; margin: 0 0 1.6rem; }

/* kicker-style label — echoes the small-caps section tags used in the
   generated decks themselves, so the tool and its output share a language */
label {
  display: block;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--primary-deep);
  margin: 1.5rem 0 0.5rem;
}
label:first-of-type { margin-top: 0; }

label.label-muted { color: var(--gray-soft); }

textarea, input[type=text], select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.98rem;
  color: var(--text);
  background: var(--input-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea:focus, input[type=text]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 175, 247, 0.15);
  background: var(--input-bg-focus);
}

textarea.brief-hero { min-height: 190px; resize: vertical; font-size: 1.02rem; line-height: 1.5; }

.example-caption {
  font-size: 0.82rem;
  color: var(--gray-soft);
  font-style: italic;
  margin: 0.4rem 0 0;
  line-height: 1.5;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.field-row label { margin: 0; white-space: nowrap; }
.field-row input[type=text] { max-width: 220px; padding: 0.5rem 0.7rem; font-size: 0.88rem; }

/* --- custom file upload ----------------------------------------------- */

.file-upload { margin-top: 1.5rem; }
.file-upload-row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--input-bg);
  border: 1.5px dashed var(--gray-soft);
  color: var(--gray);
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-transform: none;
  letter-spacing: normal;
}
.file-upload-btn:hover { border-color: var(--primary); color: var(--primary-deep); background: var(--card-bg); }
.file-upload-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.file-chip {
  display: none;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary-tint, #E3F3FD);
  color: var(--primary-deep);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.5rem 0.4rem 0.8rem;
  border-radius: 999px;
}
.file-chip.visible { display: inline-flex; }
.file-chip button {
  all: unset;
  cursor: pointer;
  color: var(--primary-deep);
  opacity: 0.6;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  margin: 0;
}
.file-chip button:hover { opacity: 1; }

/* --- buttons ----------------------------------------------------------- */

button, .btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.8rem 1.7rem;
  border-radius: 12px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 1.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  box-shadow: 0 6px 16px -6px rgba(29, 175, 247, 0.55);
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
button:hover, .btn:hover { background: var(--primary-deep); transform: translateY(-1px); box-shadow: 0 8px 20px -6px rgba(10, 61, 102, 0.45); }
button:active, .btn:active { transform: translateY(0); }
button[disabled] { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }

.btn-secondary {
  background: var(--card-bg);
  color: var(--gray);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--page-bg); color: var(--text); transform: none; box-shadow: none; }

.outline-option {
  /* .outline-option is a <label> reused as a rich content wrapper (not a
     simple form label) — reset the kicker-style label defaults (uppercase,
     bold, small, accent color) here so they don't cascade into the
     rationale/list text below; .arc-tag restyles itself explicitly */
  display: block;
  text-transform: none;
  font-weight: 400;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: normal;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.9rem;
  margin-top: 0;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.outline-option:hover { border-color: var(--primary); box-shadow: 0 4px 14px -8px rgba(29, 175, 247, 0.4); }
.outline-option:has(input:checked) { border-color: var(--primary); background: rgba(29, 175, 247, 0.04); }
.outline-option input[type=radio] { margin-right: 0.5rem; accent-color: var(--primary); }
.outline-option .arc-tag {
  display: inline-block;
  background: var(--dark-fill);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}
.outline-option .rationale { color: var(--gray); font-size: 0.88rem; margin: 0.3rem 0 0.7rem; line-height: 1.45; }
.outline-option ol { margin: 0; padding-left: 1.2rem; font-size: 0.9rem; }
.outline-option li { margin-bottom: 0.25rem; line-height: 1.4; }

.spinner-msg { color: var(--gray); font-size: 0.88rem; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request.htmx-indicator { display: inline; }

.error-box {
  background: #FDF2E1;
  color: var(--dark);
  padding: 1rem 1.2rem;
  border-radius: 12px;
  font-size: 0.9rem;
  border-left: 4px solid var(--risk);
}

.success-box {
  background: #E7F8EF;
  color: var(--dark); /* fixed, not var(--text) — this box's bg stays a light pastel in both themes */
  padding: 1.5rem;
  border-radius: 14px;
  text-align: center;
  border-left: 4px solid var(--success);
}

.usage-note { color: var(--gray-soft); font-size: 0.82rem; margin-top: 0.6rem; }

/* ======================================================================
   Wizard UX upgrade (2026-07-05 design spec) — new tokens + components.
   Extends the token system above, doesn't replace it.
   ====================================================================== */

:root {
  /* --- spacing scale (use instead of scattered rem values in new blocks) --- */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.5rem;   /* 24px */
  --space-6: 2rem;     /* 32px */
  --space-7: 2.5rem;   /* 40px */
  --space-8: 3.5rem;   /* 56px */

  /* --- type scale --- */
  --text-xs: 0.72rem;
  --text-sm: 0.82rem;
  --text-base: 0.98rem;
  --text-md: 1.05rem;
  --text-lg: 1.45rem;
  --text-xl: 1.9rem;

  /* --- radii --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* was hardcoded as an inline fallback in .file-chip — formalized here */
  --primary-tint: #E3F3FD;

  /* --- arc badge accents (UI-only, NOT tied to the selected deck theme
     swatch below — otherwise the arc badge would shift together with the
     theme swatch and imply a link that doesn't actually exist). All 4 are
     REAL values from theme.py (primary_deep/dark_fill of other themes), not
     invented; each checked for contrast against white text (WCAG AA, ≥4.5:1). --- */
  --arc-pyramid: #1E479E;  /* = Neutral Corporate primary_deep, contrast 8.6:1 */
  --arc-scqa:    #17108B;  /* = Indigo dark_fill,               contrast 14.2:1 */
  --arc-sequoia: #015037;  /* = Emerald dark_fill,              contrast 9.5:1 */
  --arc-3act:    #7D2D03;  /* = Orange dark_fill,               contrast 9.3:1 */
  --arc-default: var(--gray); /* contrast 4.8:1 */
}
@media (prefers-color-scheme: dark) {
  :root { --primary-tint: rgba(29, 175, 247, 0.16); }
}
:root[data-theme="dark"]  { --primary-tint: rgba(29, 175, 247, 0.16); }
:root[data-theme="light"] { --primary-tint: #E3F3FD; }

/* --- 1. step 1 hero card ---------------------------------------------- */

.card.card-hero { position: relative; overflow: hidden; padding-top: 2.75rem; }
.card.card-hero::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: linear-gradient(90deg, var(--primary), var(--primary-deep));
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--primary-deep);
  background: var(--primary-tint); padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill); margin-bottom: var(--space-4);
}
.hero-title {
  font-size: var(--text-xl); font-weight: 800; letter-spacing: -0.02em;
  margin: 0 0 0.6rem; line-height: 1.2; color: var(--text);
}
.hero-sub { color: var(--gray); font-size: var(--text-md); line-height: 1.55; margin: 0 0 var(--space-6); max-width: 58ch; }

.textarea-wrap { position: relative; }
.char-counter {
  position: absolute; right: var(--space-3); bottom: var(--space-3);
  font-size: 0.75rem; color: var(--gray-soft); background: var(--card-bg);
  padding: 0.15rem 0.55rem; border-radius: var(--radius-pill);
  box-shadow: 0 1px 4px rgba(11, 30, 51, 0.12); pointer-events: none;
}

@media (max-width: 640px) {
  .card { padding: 1.4rem; border-radius: var(--radius-md); }
  .card.card-hero { padding-top: 2.2rem; }
  .hero-title { font-size: 1.5rem; }
}

/* --- 2. step 2 outline option cards + methodology tooltip -------------- */

.outline-option-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }
.arc-badge {
  display: inline-block; color: white; font-size: var(--text-xs); font-weight: 700;
  letter-spacing: 0.04em; padding: 0.25rem 0.6rem; border-radius: var(--radius-sm);
}
.arc-audience { font-size: var(--text-sm); font-weight: 600; color: var(--gray); }

.method-info { margin-left: auto; position: relative; }
.method-info summary {
  list-style: none; cursor: pointer; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--border); color: var(--gray); font-size: 0.78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; user-select: none;
}
.method-info summary::-webkit-details-marker { display: none; }
.method-info summary:hover { border-color: var(--primary); color: var(--primary-deep); }
.method-info[open] summary { border-color: var(--primary); background: var(--primary-tint); color: var(--primary-deep); }
.method-info-body {
  margin-top: var(--space-2); padding: var(--space-3); background: var(--input-bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--text); line-height: 1.5;
}

.arc-emphasis { font-size: var(--text-sm); font-weight: 600; color: var(--primary-deep); margin: 0 0 0.4rem; }

.arc-timeline { list-style: none; margin: var(--space-3) 0 0; padding: 0; position: relative; }
.arc-timeline li { display: flex; gap: var(--space-3); padding-bottom: var(--space-3); position: relative; }
.arc-timeline li:not(:last-child)::before {
  content: ""; position: absolute; left: 5px; top: 16px; bottom: -4px; width: 2px; background: var(--border);
}
.arc-dot { flex-shrink: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); margin-top: 3px; z-index: 1; }
.arc-slide { display: flex; flex-direction: column; font-size: var(--text-sm); line-height: 1.4; }
.arc-slide strong { color: var(--text); }
.arc-summary { color: var(--gray); }

/* --- 3. theme swatch chips (replaces the plain <select id="theme">) ---- */

.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); }
.swatch-chip {
  display: flex; align-items: center; gap: var(--space-2);
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  padding: 0.55rem 0.8rem; cursor: pointer; position: relative;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.swatch-chip:hover { border-color: var(--primary); }
.swatch-chip:has(input:checked) {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 175, 247, 0.15);
  background: var(--primary-tint);
}
.swatch-chip input[type=radio] {
  position: absolute; opacity: 0; width: 1px; height: 1px;
}
.swatch-colors { display: flex; flex-shrink: 0; }
.swatch-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--card-bg); box-shadow: 0 0 0 1px rgba(11,30,51,0.10);
  margin-left: -6px;
}
.swatch-dot:first-child { margin-left: 0; }
.swatch-name { font-size: var(--text-sm); font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- 4. template preview cards (replaces the plain <select id="template">) --- */

.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--space-3); }
.template-card {
  display: flex; align-items: center; gap: var(--space-3);
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-3); cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.template-card:hover { border-color: var(--primary); }
.template-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,175,247,.15); background: var(--primary-tint); }
.template-card input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; }

.template-preview {
  position: relative; flex-shrink: 0; width: 72px; height: 44px;
  border-radius: 6px; background: var(--input-bg); border: 1px solid var(--border); overflow: hidden;
}
.template-info { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.template-name { font-size: var(--text-sm); font-weight: 700; color: var(--text); }
.template-desc { font-size: 0.78rem; color: var(--gray); line-height: 1.4; }

/* corporate: narrow dark spine on the left + light header + 2 body lines */
.template-preview--corporate { background: #F6FAFE; }
.template-preview--corporate::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 10px; background: linear-gradient(180deg, var(--primary-deep), var(--dark-fill)); }
.template-preview--corporate .tp-el:nth-child(1) { position: absolute; left: 16px; top: 8px; width: 40px; height: 5px; border-radius: 2px; background: var(--dark); }
.template-preview--corporate .tp-el:nth-child(2) { position: absolute; left: 16px; top: 18px; width: 48px; height: 3px; border-radius: 2px; background: var(--gray-soft); }
.template-preview--corporate .tp-el:nth-child(3) { position: absolute; left: 16px; top: 26px; width: 30px; height: 3px; border-radius: 2px; background: var(--gray-soft); }

/* bold_bar_pitch: white left section with title + gradient art panel on the right (~38%) */
.template-preview--bold_bar_pitch { background: #FFFFFF; }
.template-preview--bold_bar_pitch::before { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 27px; background: linear-gradient(160deg, var(--primary), var(--primary-deep)); }
.template-preview--bold_bar_pitch .tp-el:nth-child(1) { position: absolute; left: 8px; top: 9px; width: 30px; height: 5px; border-radius: 2px; background: var(--dark); }
.template-preview--bold_bar_pitch .tp-el:nth-child(2) { position: absolute; left: 8px; top: 19px; width: 34px; height: 3px; border-radius: 2px; background: var(--primary); }
.template-preview--bold_bar_pitch .tp-el:nth-child(3) { display: none; }

/* ledger_financial: dark numbered tab in the corner + table rows (alternating) */
.template-preview--ledger_financial { background: #F6FAFE; }
.template-preview--ledger_financial::before { content: ""; position: absolute; left: 0; top: 0; width: 18px; height: 10px; background: var(--dark-fill); }
.template-preview--ledger_financial .tp-el:nth-child(1) { position: absolute; left: 6px; top: 15px; right: 6px; height: 5px; border-radius: 1px; background: var(--dark-fill); }
.template-preview--ledger_financial .tp-el:nth-child(2) { position: absolute; left: 6px; top: 22px; right: 6px; height: 4px; border-radius: 1px; background: var(--border); }
.template-preview--ledger_financial .tp-el:nth-child(3) { position: absolute; left: 6px; top: 28px; right: 6px; height: 4px; border-radius: 1px; background: var(--gray-soft); opacity: .5; }

/* --- 5. indeterminate render progress bar + elapsed timer -------------- */

.render-progress { margin-top: var(--space-4); }
/* more specific than the generic `.htmx-request .htmx-indicator { display:
   inline }` rule above — this block needs to lay out as a column (bar +
   label), not inline, while it's showing. */
.render-progress.htmx-indicator { display: none; }
.htmx-request .render-progress.htmx-indicator { display: block; }
.render-progress-bar { height: 6px; border-radius: var(--radius-pill); background: var(--border); overflow: hidden; position: relative; }
.render-progress-fill {
  position: absolute; top: 0; left: -40%; height: 100%; width: 40%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--primary), var(--primary-deep));
  animation: render-progress-slide 1.3s ease-in-out infinite;
}
@keyframes render-progress-slide { 0% { left: -40%; } 100% { left: 100%; } }
.render-progress-label { display: flex; align-items: center; gap: var(--space-2); color: var(--gray); font-size: var(--text-sm); margin: 0.6rem 0 0; }
.render-progress-spinner {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--primary);
  animation: render-progress-spin 0.8s linear infinite;
}
@keyframes render-progress-spin { to { transform: rotate(360deg); } }
.render-progress-timer { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary-deep); }

/* --- 6. step 3 rerender section ---------------------------------------- */

.section-title { margin: 0 0 0.4rem; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
