/* ===================================================================
   PromptForge — design system
   Direction: "blueprint studio". The product turns a vague idea into a
   technical drawing, so the interface borrows from drafting: measured
   grids, hairline rules, draftsman blue, and annotation-style labels.
   Type: Quicksand (voice) · Inter (dense text) · JetBrains Mono (spec)
   =================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* palette */
  --paper:        #F4F6FB;
  --paper-2:      #EAEFF8;
  --surface:      #FFFFFF;
  --surface-2:    #FAFBFE;
  --ink:          #0B1120;
  --ink-2:        #141E33;
  --ink-3:        #1E2A44;

  --blueprint:    #2F6BFF;
  --blueprint-6:  #5A8AFF;
  --blueprint-3:  #D9E4FF;
  --blueprint-1:  #EEF3FF;

  --cyan:         #12B0A8;
  --cyan-1:       #E3F7F5;
  --amber:        #E8912B;
  --amber-1:      #FDF1E0;
  --rose:         #E23D62;
  --rose-1:       #FDE9ED;

  --text:         #0F1729;
  --text-2:       #4C5871;
  --text-3:       #7C879E;
  --text-inv:     #EEF2FB;
  --text-inv-2:   #9AA8C4;

  --line:         #E1E7F3;
  --line-2:       #CFD8EA;
  --line-dark:    #22304C;

  /* type */
  --font-ui:   'Quicksand', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --t-xs:   0.75rem;   --t-sm:  0.8125rem;  --t-base: 0.9375rem;
  --t-md:   1.0625rem; --t-lg:  1.375rem;   --t-xl:   1.875rem;
  --t-2xl:  2.5rem;    --t-3xl: 3.5rem;

  /* space — 4px base */
  --s1: .25rem;  --s2: .5rem;   --s3: .75rem;  --s4: 1rem;
  --s5: 1.5rem;  --s6: 2rem;    --s7: 3rem;    --s8: 4rem;  --s9: 6rem;

  --r-sm: 8px;  --r: 12px;  --r-lg: 18px;  --r-xl: 26px;  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(15,23,41,.05);
  --shadow-2: 0 4px 16px -6px rgba(15,23,41,.12), 0 1px 3px rgba(15,23,41,.05);
  --shadow-3: 0 18px 48px -18px rgba(15,23,41,.22), 0 2px 8px rgba(15,23,41,.06);
  --shadow-blue: 0 10px 28px -10px rgba(47,107,255,.5);

  --ease: cubic-bezier(.22,.68,.35,1);
  --dur: .22s;
  --nav-h: 68px;
  --wrap: 1180px;
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blueprint); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}
h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-lg); }
h4 { font-size: var(--t-md); letter-spacing: -0.01em; }

:focus-visible {
  outline: 2.5px solid var(--blueprint);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--blueprint-3); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 3. Signature: the blueprint grid ---------- */
/* A drafting grid, faint enough to read as paper texture rather than decoration. */
.blueprint-bg {
  position: relative;
  isolation: isolate;
}
.blueprint-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(47,107,255,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47,107,255,.055) 1px, transparent 1px),
    linear-gradient(rgba(47,107,255,.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47,107,255,.11) 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
  mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 20%, transparent 78%);
  pointer-events: none;
}
.blueprint-bg--dark::before {
  background-image:
    linear-gradient(rgba(120,164,255,.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,164,255,.09) 1px, transparent 1px),
    linear-gradient(rgba(120,164,255,.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,164,255,.16) 1px, transparent 1px);
}

/* ---------- 4. Layout ---------- */
.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }
.wrap--narrow { width: min(100% - 2.5rem, 760px); margin-inline: auto; }
.wrap--reading { width: min(100% - 2.5rem, 640px); margin-inline: auto; }

.stack > * + * { margin-top: var(--s4); }
.stack-sm > * + * { margin-top: var(--s2); }
.stack-lg > * + * { margin-top: var(--s6); }

.row { display: flex; gap: var(--s3); align-items: center; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.row--top { align-items: flex-start; }
.spacer { flex: 1; }

.grid { display: grid; gap: var(--s4); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.section { padding-block: var(--s9); }
.section--tight { padding-block: var(--s7); }

/* ---------- 5. Type utilities ---------- */
.display {
  font-family: var(--font-ui);
  font-size: clamp(2.25rem, 6.2vw, var(--t-3xl));
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.035em;
}
.lead { font-size: var(--t-md); line-height: 1.65; color: var(--text-2); }
.muted { color: var(--text-3); }
.small { font-size: var(--t-sm); }
.tiny  { font-size: var(--t-xs); }
.mono  { font-family: var(--font-mono); font-size: 0.875em; }
.center { text-align: center; }
.balance { text-wrap: balance; }

/* Annotation label — the drafting-sheet callout used above section titles */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--blueprint);
}
.eyebrow::before {
  content: '';
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: .6;
}
.eyebrow--dark { color: var(--blueprint-6); }

.gradient-text {
  background: linear-gradient(100deg, var(--blueprint) 10%, var(--cyan) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- 6. Buttons ---------- */
.btn {
  --btn-bg: var(--blueprint);
  --btn-fg: #fff;
  --btn-bd: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--t-base);
  letter-spacing: -0.005em;
  padding: .68rem 1.25rem;
  border-radius: var(--r);
  border: 1.5px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled='true'] {
  opacity: .5; cursor: not-allowed; transform: none;
}

.btn--primary { box-shadow: var(--shadow-blue); }
.btn--primary:hover { --btn-bg: #1F5AF0; }

.btn--ghost {
  --btn-bg: transparent; --btn-fg: var(--text); --btn-bd: var(--line-2);
}
.btn--ghost:hover { --btn-bg: var(--surface); --btn-bd: var(--blueprint); --btn-fg: var(--blueprint); }

.btn--quiet { --btn-bg: transparent; --btn-fg: var(--text-2); }
.btn--quiet:hover { --btn-bg: var(--paper-2); --btn-fg: var(--text); }

.btn--dark { --btn-bg: var(--ink); }
.btn--dark:hover { --btn-bg: var(--ink-3); }

.btn--danger { --btn-bg: var(--rose); }
.btn--danger:hover { --btn-bg: #C93055; }

.btn--on-dark { --btn-bg: rgba(255,255,255,.08); --btn-fg: #fff; --btn-bd: rgba(255,255,255,.22); }
.btn--on-dark:hover { --btn-bg: rgba(255,255,255,.16); }

.btn--lg { padding: .9rem 1.7rem; font-size: var(--t-md); border-radius: var(--r-lg); }
.btn--sm { padding: .42rem .85rem; font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn--icon { padding: .55rem; aspect-ratio: 1; }
.btn--block { width: 100%; }

.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 7. Cards & surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s5);
  box-shadow: var(--shadow-1);
}
.card--flat { box-shadow: none; }
.card--pad-sm { padding: var(--s4); }
.card--dark {
  background: var(--ink);
  border-color: var(--line-dark);
  color: var(--text-inv);
}
.card--dark h1, .card--dark h2, .card--dark h3, .card--dark h4 { color: #fff; }

.card--link {
  display: block;
  color: inherit;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card--link:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--blueprint-3);
  box-shadow: var(--shadow-2);
}

/* Hairline rule with a drafting tick, used between spec sections */
.rule { height: 1px; background: var(--line); border: 0; margin-block: var(--s5); }
.rule--ticked {
  position: relative;
  background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px);
}

/* ---------- 8. Badges, chips, pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  font-family: var(--font-ui);
  font-size: var(--t-xs);
  font-weight: 600;
  padding: .28em .7em;
  border-radius: var(--r-pill);
  background: var(--paper-2);
  color: var(--text-2);
  white-space: nowrap;
}
.badge--blue  { background: var(--blueprint-1); color: var(--blueprint); }
.badge--cyan  { background: var(--cyan-1);      color: var(--cyan); }
.badge--amber { background: var(--amber-1);     color: #A9670F; }
.badge--rose  { background: var(--rose-1);      color: var(--rose); }
.badge--dark  { background: var(--ink); color: #fff; }
.badge--outline { background: transparent; border: 1px solid var(--line-2); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--t-sm);
  padding: .5rem .9rem;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  user-select: none;
}
.chip:hover { border-color: var(--blueprint-6); color: var(--blueprint); }
.chip[aria-pressed='true'], .chip.is-selected {
  background: var(--blueprint-1);
  border-color: var(--blueprint);
  color: var(--blueprint);
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- 9. Forms ---------- */
.field { display: block; }
.field + .field { margin-top: var(--s4); }

.label {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--t-sm);
  color: var(--text);
  margin-bottom: .4rem;
}
.label .req { color: var(--rose); font-weight: 700; }
.hint { font-size: var(--t-sm); color: var(--text-3); margin-top: .35rem; line-height: 1.5; }

.input, .select, .textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--t-base);
  padding: .72rem .9rem;
  background: var(--surface);
  border: 1.5px solid var(--line-2);
  border-radius: var(--r);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-2); background: var(--surface-2); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blueprint);
  box-shadow: 0 0 0 4px var(--blueprint-1);
  background: var(--surface);
}
.input[aria-invalid='true'], .textarea[aria-invalid='true'] {
  border-color: var(--rose);
  box-shadow: 0 0 0 4px var(--rose-1);
}
.textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
.textarea--brief { min-height: 190px; font-size: var(--t-md); }

.select {
  appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234C5871' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M5 9l7 7 7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  background-size: 18px;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 3rem; }
.input-group__btn {
  position: absolute;
  right: .4rem;
  border: 0;
  background: transparent;
  color: var(--text-3);
  padding: .45rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.input-group__btn:hover { background: var(--paper-2); color: var(--text); }

.error-text {
  display: flex; align-items: flex-start; gap: .4rem;
  font-size: var(--t-sm); color: var(--rose); margin-top: .4rem;
}

/* Switch */
.switch { display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track {
  width: 44px; height: 25px;
  background: var(--line-2);
  border-radius: var(--r-pill);
  position: relative;
  transition: background var(--dur) var(--ease);
  flex-shrink: 0;
}
.switch__track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--blueprint); }
.switch input:checked + .switch__track::after { transform: translateX(19px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 4px var(--blueprint-1); }

/* Choice cards — used heavily by the question wizard */
.choice {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s4);
  border: 1.5px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.choice:hover { border-color: var(--blueprint-6); background: var(--surface-2); }
.choice input { margin-top: .25rem; accent-color: var(--blueprint); width: 17px; height: 17px; flex-shrink: 0; }
.choice:has(input:checked) {
  border-color: var(--blueprint);
  background: var(--blueprint-1);
  box-shadow: inset 0 0 0 1px var(--blueprint);
}
.choice__title { font-family: var(--font-ui); font-weight: 600; }
.choice__hint { font-size: var(--t-sm); color: var(--text-3); margin-top: .15rem; }

/* Colour input */
.color-field { display: flex; align-items: center; gap: var(--s3); }
.color-field input[type='color'] {
  width: 48px; height: 42px; padding: 3px;
  border: 1.5px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer;
}

/* ---------- 10. Progress & gauges (signature) ---------- */
.progress {
  height: 7px;
  background: var(--paper-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blueprint), var(--cyan));
  transition: width .5s var(--ease);
}
.progress--amber .progress__bar { background: linear-gradient(90deg, var(--amber), #F3B95E); }

/* Completeness gauge — the drawing-becomes-finished-plan motif */
.gauge { display: grid; place-items: center; position: relative; }
.gauge svg { transform: rotate(-90deg); }
.gauge__track { stroke: var(--paper-2); }
.gauge__fill {
  stroke: var(--blueprint);
  stroke-linecap: round;
  transition: stroke-dashoffset .7s var(--ease);
}
.gauge__fill--full { stroke: var(--cyan); }
.gauge__fill--low  { stroke: var(--amber); }
.gauge__value {
  position: absolute;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--t-md);
  letter-spacing: -0.03em;
}
.gauge__value span { font-size: .6em; font-weight: 600; color: var(--text-3); }

/* Phase rail — numbering is used because build phases are a real sequence */
.phase-rail { list-style: none; padding: 0; position: relative; }
.phase-rail::before {
  content: '';
  position: absolute;
  left: 17px; top: 24px; bottom: 24px;
  width: 2px;
  background: repeating-linear-gradient(var(--line-2) 0 5px, transparent 5px 10px);
}
.phase-rail__item { display: flex; gap: var(--s4); padding-block: var(--s3); position: relative; }
.phase-rail__no {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--text-3);
  z-index: 1;
}
.phase-rail__item.is-done .phase-rail__no { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.phase-rail__item.is-active .phase-rail__no {
  background: var(--blueprint); border-color: var(--blueprint); color: #fff;
  box-shadow: 0 0 0 5px var(--blueprint-1);
}

/* ---------- 11. Navigation ---------- */
.nav {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: var(--s5);
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(244,246,251,.86);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav--dark {
  background: rgba(11,17,32,.82);
  border-bottom-color: var(--line-dark);
}
.nav__inner { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; display: flex; align-items: center; gap: var(--s5); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--blueprint), #1B4FD8);
  color: #fff;
  box-shadow: var(--shadow-blue);
}
.nav--dark .brand { color: #fff; }

.nav__links { display: flex; align-items: center; gap: var(--s1); }
.nav__link {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--t-sm);
  color: var(--text-2);
  padding: .5rem .8rem;
  border-radius: var(--r-sm);
  transition: all var(--dur) var(--ease);
}
.nav__link:hover { text-decoration: none; color: var(--text); background: var(--paper-2); }
.nav__link.is-active { color: var(--blueprint); background: var(--blueprint-1); }
.nav--dark .nav__link { color: var(--text-inv-2); }
.nav--dark .nav__link:hover { color: #fff; background: rgba(255,255,255,.08); }

.nav__toggle { display: none; }

/* Avatar / user menu */
.avatar {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--t-sm);
  flex-shrink: 0;
}
.avatar--lg { width: 56px; height: 56px; font-size: var(--t-md); }

.menu { position: relative; }
.menu__panel {
  position: absolute;
  right: 0; top: calc(100% + 10px);
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-3);
  padding: var(--s2);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all var(--dur) var(--ease);
}
.menu.is-open .menu__panel { opacity: 1; visibility: visible; transform: translateY(0); }
.menu__item {
  display: flex; align-items: center; gap: var(--s3);
  padding: .55rem .7rem;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--text-2);
  width: 100%;
  border: 0; background: none; text-align: left; cursor: pointer;
}
.menu__item:hover { text-decoration: none; background: var(--paper-2); color: var(--text); }
.menu__item--danger { color: var(--rose); }
.menu__item--danger:hover { background: var(--rose-1); color: var(--rose); }
.menu__divider { height: 1px; background: var(--line); margin: var(--s2) 0; }

/* ---------- 12. Flash / toast ---------- */
.flash-zone {
  position: fixed;
  top: calc(var(--nav-h) + 12px);
  right: 20px;
  z-index: 90;
  display: grid;
  gap: var(--s2);
  width: min(calc(100vw - 40px), 400px);
}
.flash {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blueprint);
  border-radius: var(--r);
  box-shadow: var(--shadow-3);
  font-size: var(--t-sm);
  animation: flashIn .3s var(--ease);
}
@keyframes flashIn { from { opacity: 0; transform: translateX(20px); } }
.flash--success { border-left-color: var(--cyan); }
.flash--success .flash__icon { color: var(--cyan); }
.flash--error   { border-left-color: var(--rose); }
.flash--error .flash__icon { color: var(--rose); }
.flash--warning { border-left-color: var(--amber); }
.flash--warning .flash__icon { color: var(--amber); }
.flash--info .flash__icon { color: var(--blueprint); }
.flash__icon { flex-shrink: 0; margin-top: 1px; }
.flash__close {
  border: 0; background: none; cursor: pointer;
  color: var(--text-3); padding: 2px; border-radius: 4px; flex-shrink: 0;
}
.flash__close:hover { color: var(--text); background: var(--paper-2); }

/* ---------- 13. Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th {
  text-align: left;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--t-xs);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
.table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

/* ---------- 14. Empty states ---------- */
.empty {
  text-align: center;
  padding: var(--s8) var(--s5);
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.empty__icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  margin: 0 auto var(--s4);
  border-radius: var(--r);
  background: var(--blueprint-1);
  color: var(--blueprint);
}

/* ---------- 15. Code / spec output ---------- */
.code-block {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  line-height: 1.7;
  background: var(--ink);
  color: var(--text-inv);
  padding: var(--s5);
  border-radius: var(--r);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 2;
}
.code-block__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--ink-2);
  border-radius: var(--r) var(--r) 0 0;
  border-bottom: 1px solid var(--line-dark);
  color: var(--text-inv-2);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
}
.code-block__head + .code-block { border-radius: 0 0 var(--r) var(--r); }

kbd {
  font-family: var(--font-mono);
  font-size: .8em;
  padding: .15em .45em;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
}

/* ---------- 16. App shell (signed-in layout) ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.shell__main { flex: 1; padding-block: var(--s6) var(--s8); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
  margin-bottom: var(--s6);
}
.page-head__title { display: flex; flex-direction: column; gap: .35rem; }

.stat {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.stat__value {
  font-family: var(--font-ui);
  font-size: var(--t-xl);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}
.stat__label { font-size: var(--t-xs); color: var(--text-3); font-weight: 500; }

/* ---------- 17. Footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding-block: var(--s6);
  font-size: var(--t-sm);
  color: var(--text-3);
}
.footer a { color: var(--text-2); }
.footer--dark { border-top-color: var(--line-dark); background: var(--ink); color: var(--text-inv-2); }
.footer--dark a { color: var(--text-inv); }

/* ---------- 18. Auth screens ---------- */
.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  padding: var(--s5);
}
.auth-card {
  width: min(100%, 440px);
  margin-inline: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: var(--s6);
  box-shadow: var(--shadow-3);
}
.auth-card__head { text-align: center; margin-bottom: var(--s5); }

/* ---------- 19. Utilities ---------- */
.ic { flex-shrink: 0; vertical-align: middle; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px;
  background: var(--ink); color: #fff;
  padding: .7rem 1.2rem; border-radius: 0 0 var(--r) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; top: 0; }

.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: var(--s2); }
.mt-4 { margin-top: var(--s4); }
.mt-6 { margin-top: var(--s6); }
.mb-4 { margin-bottom: var(--s4); }
.w-full { width: 100%; }
.text-blue { color: var(--blueprint); }
.text-cyan { color: var(--cyan); }
.text-amber { color: var(--amber); }
.text-rose { color: var(--rose); }

/* ---------- 20. Responsive ---------- */
@media (max-width: 860px) {
  :root { --t-2xl: 2rem; --t-xl: 1.5rem; }

  .nav__toggle {
    display: grid; place-items: center;
    margin-left: auto;
    padding: .5rem;
    border: 1.5px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
  }
  .nav__links {
    position: fixed;
    inset: var(--nav-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--s1);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: var(--s4);
    box-shadow: var(--shadow-3);
    transform: translateY(-120%);
    transition: transform var(--dur) var(--ease);
  }
  .nav__links.is-open { transform: translateY(0); }
  .nav__link { padding: .75rem .9rem; font-size: var(--t-base); }

  .section { padding-block: var(--s7); }
  .page-head { align-items: flex-start; }
  .flash-zone { right: 12px; left: 12px; width: auto; }
}

@media (max-width: 520px) {
  .wrap, .wrap--narrow, .wrap--reading { width: calc(100% - 1.75rem); }
  .card { padding: var(--s4); border-radius: var(--r); }
  .auth-card { padding: var(--s5) var(--s4); border-radius: var(--r-lg); }
  .btn { width: 100%; }
  .btn--auto, .row .btn--auto { width: auto; }
  .grid--4, .grid--3 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 21. Print (spec sheets) ---------- */
@media print {
  .nav, .footer, .flash-zone, .btn { display: none !important; }
  body { background: #fff; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  .code-block { background: #f6f6f6; color: #111; border: 1px solid #ddd; }
}

/* =====================================================================
   22. AI READINESS  (Phase 2)
   Shows which model would run each job, and whether a stored key works.
   ===================================================================== */

.ai-readiness {
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.readiness-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.readiness-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  padding: 10px var(--s3);
  background: var(--surface);
  font-size: var(--t-xs);
}

.readiness-item__label {
  font-family: var(--font-ui);
  font-weight: 600;
  color: var(--text);
}

.readiness-item__model {
  color: var(--text-2);
  text-align: right;
  word-break: break-word;
}

.readiness-item__fallback {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--blueprint-1);
  color: var(--blueprint);
  font-family: var(--font-ui);
  font-size: 11px;
}

/* A blocked row is the actionable one, so it carries the only colour. */
.readiness-item--blocked { background: var(--amber-1); }
.readiness-item--blocked .readiness-item__model {
  color: var(--amber);
  font-weight: 600;
}

/* --- per-key status pill --- */
.key-status { font-family: var(--font-ui); white-space: nowrap; }
.key-status--checking { color: var(--text-3); }
.key-status--ok       { color: var(--cyan); font-weight: 600; }
.key-status--bad      { color: var(--rose); font-weight: 600; cursor: help; }

@media (max-width: 520px) {
  .readiness-item { flex-direction: column; gap: 2px; }
  .readiness-item__model { text-align: left; }
}

/* =====================================================================
   23. WIZARD  (Phase 5)
   ===================================================================== */

.wizard { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: var(--s6); align-items: start; }

.wizard__rail {
  position: sticky; top: calc(var(--nav-h) + var(--s4));
  padding: var(--s4); border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface);
}

.wizard__main { min-width: 0; }

.gauge-row { display: flex; align-items: center; gap: var(--s3); }

.stage-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.stage-list__item a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: var(--r-sm);
  text-decoration: none; color: var(--text-2); border: 1px solid transparent;
}
.stage-list__item a:hover { background: var(--surface-2); }
.stage-list__no { font-size: var(--t-xs); }
.stage-list__item.is-current a { border-color: var(--blueprint); background: var(--blueprint-1); color: var(--blueprint); }
.stage-list__item.is-done .stage-list__pct { color: var(--cyan); }

/* --- question groups --- */
.qgroup { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--line); }
.qgroup:first-of-type { border-top: 0; padding-top: var(--s3); }
.qgroup__head { display: flex; gap: var(--s3); align-items: flex-start; margin-bottom: var(--s4); }
.qgroup__icon { color: var(--blueprint); margin-top: 2px; }
.qgroup__head h2 { font-size: var(--t-md); }

/* --- a single question --- */
.q { padding: var(--s4) 0; border-bottom: 1px dashed var(--line); }
.q:last-child { border-bottom: 0; }
.q[hidden] { display: none; }
.q--skipped { opacity: .55; }

.q__label { display: block; font-family: var(--font-ui); font-weight: 600; color: var(--text); }
.q__help  { font-size: var(--t-xs); color: var(--text-2); margin-top: 4px; max-width: 62ch; }
.q__hint  { font-size: var(--t-xs); color: var(--text-3); margin-top: 6px; }
.q .input, .q .chip-group, .q .choice-row, .q .choice-stack, .q .color-field { margin-top: 10px; }

.q__critical {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px;
  background: var(--amber-1); color: var(--amber);
  font-family: var(--font-ui); font-size: 11px; font-weight: 600; vertical-align: 2px;
}
.q__ai {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--blueprint-1); color: var(--blueprint);
  font-family: var(--font-ui); font-size: 11px; vertical-align: 2px;
}
.q__skip { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; font-size: var(--t-xs); color: var(--text-3); cursor: pointer; }

/* --- choices --- */
.choice-row   { display: flex; gap: var(--s2); flex-wrap: wrap; }
.choice-stack { display: flex; flex-direction: column; gap: 6px; }

.choice {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface);
  cursor: pointer; font-size: var(--t-xs); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice:hover { border-color: var(--line-dark); }
.choice--wide { width: 100%; }
.choice--on { border-color: var(--blueprint); background: var(--blueprint-1); color: var(--blueprint); font-weight: 600; }
.choice:focus-within { outline: 2px solid var(--blueprint); outline-offset: 2px; }

.color-field { display: flex; gap: var(--s2); align-items: center; }
.color-field input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; }
.color-field .input { max-width: 140px; }

.wizard__actions {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s3);
  margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--line); flex-wrap: wrap;
}

/* --- project type picker --- */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s3); }
.type-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer; transition: border-color var(--dur) var(--ease);
}
.type-card input { position: absolute; opacity: 0; }
.type-card:hover { border-color: var(--line-dark); }
.type-card--on { border-color: var(--blueprint); background: var(--blueprint-1); box-shadow: var(--shadow-blue); }
.type-card:focus-within { outline: 2px solid var(--blueprint); outline-offset: 2px; }

/* --- review --- */
.gap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.gap-list a {
  display: flex; justify-content: space-between; gap: var(--s3); align-items: baseline;
  padding: 9px 12px; background: var(--surface); border-radius: var(--r-sm);
  text-decoration: none; color: var(--text);
}
.gap-list a:hover { background: var(--paper-2); }
.gap-list__label { font-size: var(--t-xs); font-weight: 500; }

.answer-list { display: grid; grid-template-columns: minmax(160px, 34%) 1fr; gap: 8px var(--s4); margin: 0; }
.answer-list dt { font-family: var(--font-ui); font-weight: 600; font-size: var(--t-xs); color: var(--text-2); }
.answer-list dd { margin: 0; font-size: var(--t-xs); color: var(--text); }

/* --- compiled phases --- */
.phase-stack { display: flex; flex-direction: column; gap: var(--s2); }
.phase { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); overflow: hidden; }
.phase__head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); cursor: pointer; list-style: none;
}
.phase__head::-webkit-details-marker { display: none; }
.phase__head:hover { background: var(--surface-2); }
.phase__no {
  flex: 0 0 auto; width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 999px; background: var(--blueprint-1); color: var(--blueprint);
  font-size: var(--t-xs); font-weight: 600;
}
.phase__title { flex: 1 1 auto; font-family: var(--font-ui); font-weight: 600; font-size: var(--t-xs); }
.phase__body { padding: 0 var(--s4) var(--s4); border-top: 1px solid var(--line); padding-top: var(--s4); }
.phase__body .code-block { max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.phase--done .phase__no { background: var(--cyan-1); color: var(--cyan); }
.phase--done .phase__title { color: var(--text-3); text-decoration: line-through; }

@media (max-width: 900px) {
  .wizard { grid-template-columns: 1fr; }
  .wizard__rail { position: static; }
  .stage-list { flex-direction: row; flex-wrap: wrap; }
  .stage-list__item a { padding: 6px 9px; }
  .answer-list { grid-template-columns: 1fr; gap: 2px var(--s3); }
  .answer-list dd { margin-bottom: 10px; }
}

/* =====================================================================
   24. ADMIN  (Phase 6)
   ===================================================================== */

.admin-tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  margin-top: var(--s4); padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
}
.admin-tabs__tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--r-sm) var(--r-sm) 0 0;
  font-family: var(--font-ui); font-size: var(--t-xs); font-weight: 600;
  color: var(--text-2); text-decoration: none;
  border: 1px solid transparent; border-bottom: 0;
}
.admin-tabs__tab:hover { background: var(--surface-2); color: var(--text); }
.admin-tabs__tab.is-active {
  background: var(--surface); border-color: var(--line);
  color: var(--blueprint); margin-bottom: -1px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); }
.stat { padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.stat__value { font-size: var(--t-2xl); font-weight: 600; line-height: 1.1; color: var(--ink); }
.stat__label { font-family: var(--font-ui); font-weight: 600; font-size: var(--t-xs); margin-top: 4px; }
.stat__sub { margin-top: 2px; }

.admin-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--s6); align-items: start; }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.feed li {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 11px; background: var(--surface);
  border-radius: var(--r-sm); font-size: var(--t-xs);
}
.feed li:nth-child(even) { background: var(--surface-2); }
.feed__action { font-weight: 600; color: var(--text); }

/* forms laid out in rows */
.field-row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; min-width: 0; }
.field--sm { flex: 0 0 130px; }

.input--sm { padding: 6px 9px; font-size: var(--t-xs); }

/* tables that contain a form per row */
.table form { display: contents; }

@media (max-width: 900px) {
  .admin-cols { grid-template-columns: 1fr; }
  .admin-tabs__tab { padding: 8px 11px; }
}

/* =====================================================================
   25. MATERIALS  (Phase 7)
   ===================================================================== */

.materials-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s4); }
.materials-grid .card h3 { display: flex; align-items: center; gap: 9px; font-size: var(--t-md); }
input[type=file].input { padding: 9px; font-family: var(--font-body); font-size: var(--t-xs); cursor: pointer; }

@media (max-width: 640px) { .materials-grid { grid-template-columns: 1fr; } }

/* =====================================================================
   26. "WHERE DO I GET THIS KEY?"  (help panel on the account page)
   ===================================================================== */

.keyhelp__toggle {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--font-ui); font-size: var(--t-xs); font-weight: 600;
  color: var(--blueprint);
}
.keyhelp__toggle:hover { text-decoration: underline; }
.keyhelp__toggle[aria-expanded="true"] .ic { transform: rotate(0); }

.keyhelp {
  padding: var(--s4); border: 1px solid var(--blueprint);
  border-radius: var(--r-sm); background: var(--blueprint-1);
}
.keyhelp[hidden] { display: none; }
.keyhelp__panel[hidden] { display: none; }

.keyhelp__steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; }
.keyhelp__steps li { font-size: var(--t-xs); color: var(--text); }

.keyhelp__note {
  padding: 9px 12px; border-left: 2px solid var(--blueprint);
  background: var(--surface); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-2);
}
