/* =========================================================================
   CareWeight — base styles (Phase 1)
   Tokens, typography, hero, wizard shell, buttons, progress, output stub.
   Mobile-first. See careweight-design.md for the canonical design system.
   ========================================================================= */

:root {
  /* Forest scale */
  --forest-900: #1A2E1A;
  --forest-800: #243424;
  --forest-700: #2B3A2B;
  --forest-600: #3D5240;
  --forest-500: #4A6B4E;

  /* Sage scale */
  --sage-100: #EEF3EC;
  --sage-200: #D5E5D0;
  --sage-300: #B8D4B0;

  /* Neutrals */
  --white: #FFFFFF;
  --warm-white: #FAFAF7;
  --warm-grey: #E8E5E0;
  --warm-grey-light: #F2F0ED;

  /* Semantic */
  --error: #8B2500;
  --success: #2B6B3A;

  /* Fonts */
  --font-display: 'Zodiak', Georgia, 'Times New Roman', serif;
  --font-body: 'Switzer', -apple-system, system-ui, sans-serif;

  /* Type scale */
  --text-xs: 0.875rem;   /* 14px — output tables and footer only */
  --text-sm: 1rem;       /* 16px — labels, helper text */
  --text-base: 1.125rem; /* 18px — body text, inputs, buttons */
  --text-lg: 1.25rem;    /* 20px — card titles, mobile subsections */
  --text-xl: 1.5rem;     /* 24px — mobile section headings */
  --text-2xl: 1.75rem;   /* 28px — desktop section headings */
  --text-3xl: 2rem;      /* 32px — mobile wizard question, mobile money */
  --text-4xl: 2.25rem;   /* 36px — desktop wizard question, desktop money */
  --text-5xl: 2.5rem;    /* 40px — mobile landing headline */
  --text-6xl: 3.5rem;    /* 56px — desktop landing headline */

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  /* Space scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
}

/* ---------- Reset ---------- */

*, *::before, *::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--forest-800);
  background: var(--warm-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p {
  margin: 0;
}

button {
  font: inherit;
  cursor: pointer;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ---------- Focus ring ---------- */

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
}

.btn:focus-visible {
  outline-offset: 3px;
}

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--forest-700);
  color: var(--white);
  padding: var(--space-3) var(--space-5);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-base);
  border-radius: var(--radius-md);
  z-index: 1000;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: var(--space-4);
}

/* ---------- noscript ---------- */

.noscript {
  max-width: 640px;
  margin: var(--space-8) auto;
  padding: var(--space-5) var(--space-6);
  background: var(--sage-100);
  border-radius: var(--radius-md);
  color: var(--forest-800);
  font-size: var(--text-base);
  text-align: center;
}

/* ---------- Header ---------- */

.header {
  margin-bottom: var(--space-8);
}

@media (min-width: 640px) {
  .header {
    margin-bottom: var(--space-12);
  }
}

.header-logo {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-xl);
  color: var(--forest-900);
  letter-spacing: -0.01em;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.header-logo:hover {
  opacity: 0.8;
}

.header-logo:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ---------- Layout shell ---------- */

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) 0;
}

@media (min-width: 640px) {
  .app {
    padding: var(--space-8) var(--space-6) 0;
  }
}

@media (min-width: 960px) {
  .app {
    padding-left: 0;
    padding-right: 0;
  }
}

.view {
  /* Mobile keeps 80px so the primary CTA stays out of the thumb's natural arc. */
  padding-bottom: 80px;
}

@media (min-width: 640px) {
  .view {
    padding-bottom: var(--space-8); /* 32px on desktop — no thumb zone to protect */
  }
}

/* ---------- Landing ---------- */

.hero {
  max-width: 960px;
  margin: 0 auto;
  background: var(--sage-200);
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-8);
}

@media (min-width: 640px) {
  .hero {
    padding: 80px var(--space-12);
    gap: var(--space-12);
    align-items: stretch;
    text-align: left;
  }
}

/* Row below the headline: copy+CTA on the left, preview card on the right (desktop).
   Stacks vertically on mobile/tablet. */
.hero-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
  width: 100%;
}

@media (min-width: 960px) {
  .hero-body {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-12);
  }
}

.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  width: 100%;
}

@media (min-width: 960px) {
  .hero-copy {
    flex: 1;
    align-items: flex-start;
    max-width: 460px;
  }
}

/* Section 3 preview card — "show, don't tell" the product's promise */
.hero-preview {
  flex: 1;
  width: 100%;
  max-width: 440px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-preview-card {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  box-shadow:
    0 2px 8px rgba(26, 46, 26, 0.08),
    0 4px 16px rgba(26, 46, 26, 0.04);
  text-align: left;
}

.hero-preview-caption {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--forest-600);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--warm-grey);
}

.hero-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
  color: var(--forest-800);
  font-variant-numeric: tabular-nums;
}

/* iPhone SE-class viewports — keep "Medical coord." from truncating. */
@media (max-width: 374px) {
  .hero-preview-table {
    font-size: 0.8125rem; /* 13px — decorative landing preview only */
  }
}

.hero-preview-table th,
.hero-preview-table td {
  padding: var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--warm-grey);
  line-height: 1.4;
}

.hero-preview-table thead th {
  font-weight: 600;
  color: var(--forest-800);
  letter-spacing: 0.02em;
  padding-bottom: var(--space-3);
  padding-top: 0;
}

.hero-preview-table .col-cat {
  text-align: left;
}

.hero-preview-table .col-num {
  text-align: right;
}

.hero-preview-table tbody td {
  font-weight: 400;
}

.hero-preview-table tfoot td,
.hero-preview-table tfoot th {
  border-bottom: none;
  padding-top: var(--space-4);
  font-weight: 600;
  color: var(--forest-900);
}

.hero-preview-total {
  font-size: var(--text-sm);
  font-weight: 700;
}

.landing-headline {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 2.75rem; /* 44px mobile (was 40px) */
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--forest-900);
  max-width: 18ch;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .landing-headline {
    font-size: 4rem; /* 64px desktop (was 56px) */
    max-width: none;
    margin: 0;
    align-self: flex-start;
  }
}

.landing-subhead {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--forest-800);
  max-width: 56ch;
  margin-bottom: var(--space-12);
}

.landing-fineprint {
  font-size: var(--text-base);
  color: var(--forest-600);
  margin-top: var(--space-6);
  margin-bottom: var(--space-10);
  text-align: center;
}

.btn-cta {
  width: 100%;
}

@media (min-width: 640px) {
  .btn-cta {
    width: auto;
    min-width: 280px;
    padding-left: var(--space-12);
    padding-right: var(--space-12);
  }
}

/* ---------- Animations ---------- */

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

/* Shortened so the above-the-fold settles fast — exhausted user shouldn't wait
   ~1.4s to see the CTA. Total stagger budget ≤350ms. CTA never gets an opacity-0
   start (see index.html — btn-cta has no delay class). */
.fade-in {
  animation: fadeInSlideUp 0.35s ease-out forwards;
}

.fade-in-delay-1 {
  opacity: 0;
  animation: fadeInSlideUp 0.35s ease-out 0.05s forwards;
}

.fade-in-delay-2 {
  opacity: 0;
  animation: fadeInSlideUp 0.35s ease-out 0.15s forwards;
}

.fade-in-delay-3 {
  opacity: 0;
  animation: fadeInSlideUp 0.35s ease-out 0.25s forwards;
}

/* ---------- Wizard ---------- */

.wizard-shell {
  max-width: 960px;
  margin: 0 auto;
  background: var(--white);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

@media (min-width: 640px) {
  .wizard-shell {
    padding: var(--space-8);
  }
}

.progress {
  margin-bottom: var(--space-8);
}

.progress-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--forest-800);
  margin-bottom: var(--space-3);
}

.progress-track {
  width: 100%;
  height: 4px;
  background: var(--sage-300);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--forest-500);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Width per data-screen-pct = Math.round(done / total * 100), set by wizard.js.
   Driven by CSS rather than inline `style.width = …` so CSP style-src can stay
   strict. Discrete values cover standard flow (1..9 of 9) and solo flow (1..6
   of 6). 33, 67, 100 are shared between the two flows. */
.progress-fill[data-screen-pct="0"]   { width: 0; }
.progress-fill[data-screen-pct="11"]  { width: 11.111%; } /* 1/9 */
.progress-fill[data-screen-pct="17"]  { width: 16.667%; } /* 1/6 */
.progress-fill[data-screen-pct="22"]  { width: 22.222%; } /* 2/9 */
.progress-fill[data-screen-pct="33"]  { width: 33.333%; } /* 3/9 or 2/6 */
.progress-fill[data-screen-pct="44"]  { width: 44.444%; } /* 4/9 */
.progress-fill[data-screen-pct="50"]  { width: 50%;     } /* 3/6 */
.progress-fill[data-screen-pct="56"]  { width: 55.556%; } /* 5/9 */
.progress-fill[data-screen-pct="67"]  { width: 66.667%; } /* 6/9 or 4/6 */
.progress-fill[data-screen-pct="78"]  { width: 77.778%; } /* 7/9 */
.progress-fill[data-screen-pct="83"]  { width: 83.333%; } /* 5/6 */
.progress-fill[data-screen-pct="89"]  { width: 88.889%; } /* 8/9 */
.progress-fill[data-screen-pct="100"] { width: 100%; }

.step-container {
  margin-bottom: var(--space-12);
}

.step-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 2.125rem; /* 34px mobile (was 32px) */
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--forest-900);
  margin-bottom: var(--space-4);
}

@media (min-width: 640px) {
  .step-heading {
    font-size: 2.5rem; /* 40px desktop (was 36px) */
  }
}

.helper {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--forest-600);
}

.wizard-nav {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .wizard-nav {
    flex-direction: row;
    justify-content: space-between;
    gap: var(--space-4);
  }
}

.save-indicator {
  font-size: var(--text-sm);
  color: var(--forest-600);
  text-align: left;
  margin-top: var(--space-6);
}

/* ---------- Output (screen chrome) ---------- */

.output-shell {
  max-width: 960px; /* Match .wizard-shell so output content lines up with wizard */
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-8);
}

@media (min-width: 640px) {
  .output-shell {
    padding: var(--space-6) var(--space-6) var(--space-12);
  }
}

/* Single intro paragraph above the document — replaces the previous
   .output-screen-heading H2 which competed with the doc's own title. */
.output-screen-intro {
  font-size: var(--text-base);
  color: var(--forest-700);
  margin: 0 0 var(--space-6);
  max-width: 56ch;
  /* Match other tabindex="-1" targets — no focus ring on a paragraph */
  outline: none;
}

.output-screen-intro:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 56px;
  padding: var(--space-4) var(--space-8);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--forest-700);
  color: var(--white);
  font-weight: 600;
  width: 100%;
}

.btn-primary:hover {
  background: var(--forest-800);
}

.btn-primary:active {
  background: var(--forest-900);
}

@media (min-width: 640px) {
  .btn-primary {
    width: auto;
    min-width: 200px;
  }
}

.btn-secondary {
  background: var(--white);
  color: var(--forest-700);
  font-weight: 500;
  border: 1px solid var(--warm-grey);
  padding: var(--space-3) var(--space-6);
  width: 100%;
}

.btn-secondary:hover {
  background: var(--sage-100);
}

@media (min-width: 640px) {
  .btn-secondary {
    width: auto;
    min-width: 140px;
  }
}

/* ---------- Footer ---------- */

.footer {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
  font-size: var(--text-sm);
  color: var(--forest-600);
  text-align: center;
  line-height: 1.5;
}

@media (min-width: 640px) {
  .footer {
    padding: var(--space-8) var(--space-6);
  }
}

.footer-link {
  color: var(--forest-700);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  font-weight: 600;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--forest-900);
}

/* =========================================================================
   Wizard form components (Phase 2a)
   Inputs, radios, checkboxes, sibling rows, notices, errors.
   ========================================================================= */

.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;
}

/* ---------- Layout helpers ---------- */

.form-group {
  border: none;
  margin: 0 0 var(--space-6);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-group-compact {
  gap: var(--space-3);
}

.form-group-section {
  margin-bottom: var(--space-8);
}

.form-section-label {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--forest-800);
  margin-bottom: var(--space-3);
  display: block;
}

.form-section-sub {
  font-weight: 400;
  color: var(--forest-600);
  font-size: var(--text-base);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0 0 var(--space-6);
}

.form-label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--forest-800);
  display: block;
}

.form-helper {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--forest-600);
  margin: 0;
}

.form-helper-lead {
  margin-bottom: var(--space-6);
  font-size: var(--text-base);
  color: var(--forest-800);
}

.form-error {
  font-size: var(--text-sm);
  color: var(--error);
  font-weight: 500;
  margin: var(--space-1) 0 0;
  /* Reserve the slot vertically so toggling validation does not shift the
     form below. [hidden] would normally collapse via display:none — we
     override to visibility so the box stays in flow at one line of height. */
  min-height: 1lh;
}

.form-error[hidden] {
  display: block;
  visibility: hidden;
}

/* ---------- Text input ---------- */

.form-input {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--forest-800);
  background: var(--white);
  border: 1.5px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  min-height: 52px;
  width: 100%;
  max-width: 480px;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input::placeholder {
  color: var(--forest-600);
  opacity: 1;
}

.form-input:focus-visible {
  outline: none;
  border-color: var(--forest-500);
  box-shadow: 0 0 0 3px var(--forest-500);
}

.form-field.has-error .form-input,
.form-input.has-error {
  border-color: var(--error);
}

/* ---------- Radio / checkbox ---------- */

.form-radio,
.form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-height: 48px;
  padding: var(--space-2) var(--space-2);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease;
}

.form-radio:hover,
.form-checkbox:hover {
  background: var(--sage-100);
}

.form-radio input[type="radio"],
.form-checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin: 0;
  flex-shrink: 0;
  background: var(--white);
  border: 1.5px solid var(--warm-grey);
  position: relative;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  /* Optical alignment with the label line-height */
  margin-top: 2px;
}

.form-radio input[type="radio"] {
  border-radius: 50%;
}

.form-checkbox input[type="checkbox"] {
  border-radius: 6px;
}

.form-radio input[type="radio"]:checked,
.form-checkbox input[type="checkbox"]:checked {
  background: var(--forest-700);
  border-color: var(--forest-700);
}

.form-radio input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--white);
}

.form-checkbox input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
}

.form-radio input:focus-visible,
.form-checkbox input:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
}

.form-radio-label,
.form-checkbox-label {
  font-size: var(--text-base);
  color: var(--forest-800);
  line-height: 1.5;
}

.form-radio-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-radio-inline {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  /* Pill rows lack the per-row top padding that stacked .form-radio elements provide,
     so they hug the fieldset legend. Add explicit breathing room. */
  margin-top: var(--space-2);
}

.form-radio-pill {
  border: 1px solid var(--warm-grey);
  background: var(--white);
  min-width: 88px;
}

.form-radio-pill:has(input:checked) {
  border-color: var(--forest-700);
  background: var(--sage-100);
}

/* ---------- Sibling rows ---------- */

.sibling-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.sibling-row {
  background: var(--white);
  border: 1px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.sibling-row.has-error {
  border-color: var(--error);
}

.sibling-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.sibling-row-title {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--forest-800);
  margin: 0;
}

.sibling-row-remove {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--forest-700);
  background: none;
  border: none;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  border-radius: var(--radius-sm);
}

.sibling-row-remove:hover {
  color: var(--forest-900);
  background: var(--sage-100);
}

/* Two-stage remove — replaces the Remove button until Confirm/Cancel/timeout */
.sibling-row-remove-confirm {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  background: var(--sage-100);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}

.sibling-row-remove-prompt {
  font-size: var(--text-sm);
  color: var(--forest-800);
  margin-right: var(--space-2);
}

.sibling-row-confirm-btn,
.sibling-row-cancel-btn {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  min-height: 48px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sibling-row-confirm-btn {
  background: var(--error);
  border: 1.5px solid var(--error);
  color: var(--white);
}

.sibling-row-confirm-btn:hover {
  background: #6F1E00;
  border-color: #6F1E00;
}

.sibling-row-cancel-btn {
  background: var(--white);
  border: 1.5px solid var(--warm-grey);
  color: var(--forest-800);
}

.sibling-row-cancel-btn:hover {
  background: var(--warm-grey-light);
}

.sibling-row-confirm-btn:focus-visible,
.sibling-row-cancel-btn:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
}

.sibling-row .form-group {
  margin: 0;
}

.sibling-row .form-field {
  margin: 0;
}

.sibling-non-resident-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.sibling-non-resident-fields[hidden] {
  display: none;
}

.btn-add {
  width: auto;
  min-width: 0;
  padding: var(--space-3) var(--space-5);
  min-height: 48px;
  margin-bottom: var(--space-6);
}

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

/* ---------- Notices ---------- */

.notice {
  background: var(--sage-100);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
}

.notice p {
  font-size: var(--text-base);
  color: var(--forest-800);
  line-height: 1.6;
  margin: 0;
}

.notice-housing {
  background: var(--sage-200);
}

/* ---------- Step container constraints ---------- */

.step-container .form-helper-lead,
.step-container .form-field,
.step-container .form-group,
.step-container .form-input {
  max-width: 640px;
}

.step-container .form-input {
  max-width: 480px;
}

/* Keep step heading max-width too so long questions don't stretch full 960. */
.step-heading {
  max-width: 720px;
}

/* =========================================================================
   Step 2 — categories, summary, rate breakdown, mid-wizard preview
   ========================================================================= */

.category-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.category-card {
  background: var(--white);
  border: 1px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.category-title {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--forest-800);
  margin: 0;
}

.category-description {
  font-size: var(--text-sm);
  color: var(--forest-600);
  margin: 0;
  line-height: 1.5;
}

.category-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

.category-card .form-field {
  margin: 0;
  max-width: none;
}

@media (min-width: 640px) {
  .category-fields {
    flex-direction: row;
    align-items: flex-end;
    gap: var(--space-4);
  }
  .category-fields .form-field:first-child {
    flex: 1;
  }
  .category-fields .form-field-hours {
    flex: 0 0 auto;
  }
}

/* ---------- Select ---------- */

.form-select {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--forest-800);
  background: var(--white);
  border: 1.5px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-8) var(--space-3) var(--space-4);
  min-height: 52px;
  width: 100%;
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233D5240' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  background-size: 16px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-select:focus-visible {
  outline: none;
  border-color: var(--forest-500);
  box-shadow: 0 0 0 3px var(--forest-500);
}

.form-input-hours {
  width: 120px;
  max-width: 120px;
}

/* ---------- Summary box ---------- */

.summary-box {
  background: var(--sage-200);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin: 0 0 var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* .summary-* (Step 2) and .budget-summary-* (Step 4) share identical styling —
   one set of selectors carries the rules for both card chromes. */
.summary-label,
.budget-summary-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--forest-800);
  margin: 0 0 var(--space-2);
}

.summary-money,
.budget-summary-money {
  font-family: var(--font-body);
  font-size: 2rem; /* 32px mobile per CLAUDE.md money constraint */
  font-weight: 700;
  color: var(--forest-900);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0;
}

@media (min-width: 640px) {
  .summary-money,
  .budget-summary-money {
    font-size: 2.25rem; /* 36px desktop */
  }
}

.summary-money-secondary,
.budget-summary-secondary {
  font-size: var(--text-base);
  color: var(--forest-800);
  margin: 0;
}

.summary-hours {
  font-size: var(--text-base);
  color: var(--forest-800);
  margin: var(--space-3) 0 0;
}

.summary-footnote {
  font-size: var(--text-sm);
  /* forest-800 on sage-200 hits AAA 7:1 — forest-600 only made AA. */
  color: var(--forest-800);
  line-height: 1.5;
  margin: var(--space-3) 0 0;
}

/* ---------- Rate breakdown (expandable) ---------- */

.rate-breakdown {
  margin: 0 0 var(--space-8);
}

.rate-breakdown summary {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--forest-700);
  cursor: pointer;
  padding: var(--space-3) 0;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rate-breakdown summary::-webkit-details-marker { display: none; }

.rate-breakdown summary::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232B3A2B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='9 18 15 12 9 6'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

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

.rate-breakdown summary:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.rate-breakdown summary:hover {
  color: var(--forest-900);
}

.rate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin: var(--space-3) 0;
  font-variant-numeric: tabular-nums;
}

.rate-table th, .rate-table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--warm-grey);
  color: var(--forest-800);
  line-height: 1.4;
}

.rate-table th {
  font-weight: 600;
}

.rate-table .col-num {
  text-align: right;
}

.rate-footnote {
  font-size: var(--text-sm);
  color: var(--forest-600);
  margin: var(--space-3) 0 0;
}

.rate-footnote-mobile {
  display: none;
}

@media screen and (max-width: 639px) {
  /* Source column wraps badly at 375px — hide it; show a single footnote that
     names both sources, so the rate breakdown stays scannable. */
  .rate-table thead th:nth-child(3),
  .rate-table tbody td:nth-child(3) {
    display: none;
  }

  .rate-table th,
  .rate-table td {
    padding: var(--space-3) var(--space-2);
  }

  .rate-footnote-mobile {
    display: block;
    font-size: var(--text-sm);
    color: var(--forest-600);
    margin-top: var(--space-2);
  }
}

/* ---------- Mid-wizard preview (Section 3 tease) ---------- */

.mid-preview {
  background: var(--white);
  border: 1px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  margin: 0 0 var(--space-6);
  box-shadow:
    0 2px 8px rgba(26, 46, 26, 0.06),
    0 4px 16px rgba(26, 46, 26, 0.03);
}

.mid-preview-caption {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--forest-600);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--warm-grey);
}

.mid-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
  color: var(--forest-800);
  font-variant-numeric: tabular-nums;
}

.mid-preview-table th,
.mid-preview-table td {
  padding: var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--warm-grey);
  line-height: 1.4;
  text-align: left;
}

.mid-preview-table thead th {
  font-weight: 600;
  letter-spacing: 0.02em;
  padding-bottom: var(--space-3);
  padding-top: 0;
}

.mid-preview-table .col-num {
  text-align: right;
}

.mid-preview-table tfoot th,
.mid-preview-table tfoot td {
  border-bottom: none;
  padding-top: var(--space-4);
  font-weight: 600;
  color: var(--forest-900);
}

.mid-preview-total-money {
  font-weight: 700;
}

/* Mobile card-stack: 5-col preview will not fit 375px. Collapse each row into
   a labelled card (data-label values come from JS — see renderMidPreview). */
@media screen and (max-width: 639px) {
  .mid-preview-table {
    display: block;
  }

  .mid-preview-table thead {
    /* Keep in a11y tree, hide visually */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .mid-preview-table tbody,
  .mid-preview-table tfoot {
    display: block;
  }

  .mid-preview-table tbody tr {
    display: block;
    background: var(--warm-white);
    border: 1px solid var(--warm-grey);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-2);
  }

  .mid-preview-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: var(--space-2) 0;
    border-bottom: 1px dashed var(--warm-grey);
    text-align: right;
    font-size: var(--text-xs);
  }

  .mid-preview-table tbody td:last-child {
    border-bottom: none;
  }

  .mid-preview-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--forest-600);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    margin-right: var(--space-3);
  }

  /* First cell = card title */
  .mid-preview-table tbody tr td:first-child {
    display: block;
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--forest-900);
    padding: 0 0 var(--space-2);
    border-bottom: 1px solid var(--warm-grey);
    margin-bottom: var(--space-1);
  }

  .mid-preview-table tbody tr td:first-child::before {
    display: none;
  }

  /* Totals row → pill */
  .mid-preview-table tfoot tr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--sage-100);
    border-radius: var(--radius-sm);
    margin-top: var(--space-2);
    font-size: var(--text-sm);
  }

  .mid-preview-table tfoot th,
  .mid-preview-table tfoot td {
    display: inline;
    padding: 0;
    border: none;
  }

  .mid-preview-table tfoot td:empty {
    display: none;
  }
}

.mid-preview-footnote {
  font-size: var(--text-xs);
  color: var(--forest-600);
  margin: var(--space-4) 0 0;
  line-height: 1.5;
}

/* =========================================================================
   Step 3 — model selector
   ========================================================================= */

.model-selector {
  gap: var(--space-3);
}

.model-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--white);
  border: 1.5px solid var(--warm-grey);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  min-height: 48px;
}

.model-card:hover {
  background: var(--sage-100);
}

.model-card input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin: 0;
  flex-shrink: 0;
  background: var(--white);
  border: 1.5px solid var(--warm-grey);
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  margin-top: 3px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.model-card input[type="radio"]:checked {
  background: var(--forest-700);
  border-color: var(--forest-700);
}

.model-card input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--white);
}

.model-card input[type="radio"]:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
}

.model-card:has(input:checked) {
  border-color: var(--forest-700);
  background: var(--sage-100);
}

.model-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

.model-card-title {
  font-family: var(--font-body);
  font-size: var(--text-lg); /* 20px */
  font-weight: 600;
  color: var(--forest-800);
  line-height: 1.3;
}

.model-card-description {
  font-size: var(--text-sm); /* 16px */
  color: var(--forest-600);
  line-height: 1.5;
}

.form-group.has-error .form-error,
.model-selector .form-error {
  margin-top: var(--space-2);
}

/* ---------- Step 3.2 — assignment rows ---------- */

.step3-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.step3-row {
  background: var(--white);
  border: 1px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.step3-row-title {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--forest-800);
  margin: 0;
}

.step3-row-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

.step3-row .form-field {
  margin: 0;
  max-width: none;
}

@media (min-width: 640px) {
  .step3-row-fields {
    flex-direction: row;
    align-items: flex-end;
    gap: var(--space-4);
  }
  .step3-row-fields .form-field:first-child {
    flex: 1;
  }
  .step3-row-fields .form-field-hours {
    flex: 0 0 auto;
  }
}

/* ---------- Change-from-current chip (CLAUDE.md #12: text + icon + colour) ---------- */

.change-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  align-self: flex-start;
  background: var(--sage-200);
  color: var(--forest-800);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.3;
}

.change-chip-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--forest-700);
}

.change-chip-text {
  color: var(--forest-800);
}

/* ---------- Remote-tasks block (per far sibling) ---------- */

.step3-remote {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.remote-block {
  background: var(--sage-100);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
}

.remote-block-title {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--forest-900);
  margin: 0 0 var(--space-3);
  line-height: 1.3;
}

.remote-block-lead {
  font-size: var(--text-base);
  color: var(--forest-800);
  margin: 0 0 var(--space-3);
  line-height: 1.5;
}

.remote-block-tasks {
  margin: 0 0 var(--space-4);
  padding: 0 0 0 var(--space-5);
  list-style: disc;
  color: var(--forest-800);
}

.remote-block-tasks li {
  font-size: var(--text-base);
  line-height: 1.6;
  padding-left: var(--space-1);
}

.remote-block-financial {
  font-size: var(--text-base);
  color: var(--forest-800);
  line-height: 1.6;
  margin: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--sage-300);
}

.remote-block-financial strong {
  font-weight: 600;
  color: var(--forest-900);
}

/* ---------- Housing arrangement block (per live-in sibling) ---------- */

.step3-housing {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.housing-block {
  background: var(--sage-200);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
}

.housing-block-title {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--forest-900);
  margin: 0 0 var(--space-3);
  line-height: 1.3;
}

.housing-block-lead {
  font-size: var(--text-base);
  color: var(--forest-800);
  margin: 0 0 var(--space-5);
  line-height: 1.5;
}

.housing-arrangement {
  margin: 0;
  gap: var(--space-3);
}

.housing-arrangement > legend {
  margin-bottom: var(--space-3);
}

.housing-suboption {
  margin: calc(-1 * var(--space-2)) 0 var(--space-2) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 320px;
}

.housing-other-text {
  resize: vertical;
  min-height: 96px;
  max-width: none;
}

/* =========================================================================
   Step 4 — budget, rate editor, funding source, caregiver compensation
   ========================================================================= */

.budget-summary {
  background: var(--sage-200);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin: 0 0 var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* .budget-summary-* shares rules with .summary-* (combined selectors above) */

.budget-table-wrap {
  background: var(--white);
  border: 1px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  margin: 0 0 var(--space-6);
  overflow-x: auto;
}

.budget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs); /* 14px — preview-style table, same precedent as mid-preview-table */
  color: var(--forest-800);
  font-variant-numeric: tabular-nums;
}

.budget-table th,
.budget-table td {
  padding: var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--warm-grey);
  line-height: 1.4;
  text-align: left;
}

.budget-table thead th {
  font-weight: 600;
  letter-spacing: 0.02em;
  padding-bottom: var(--space-3);
  padding-top: 0;
  color: var(--forest-800);
}

.budget-table .col-num {
  text-align: right;
}

.budget-table tfoot th,
.budget-table tfoot td {
  border-bottom: none;
  padding-top: var(--space-4);
  font-weight: 600;
  color: var(--forest-900);
}

.budget-table-total {
  font-weight: 700;
}

/* Mobile card-stack — same pattern as .mid-preview-table and .output-table.
   Long headers like "Monthly cost" truncate on 375px; card layout sidesteps
   that and matches how the final output document presents this data. */
@media screen and (max-width: 639px) {
  .budget-table-wrap {
    padding: var(--space-4) var(--space-3);
    overflow-x: visible;
  }

  .budget-table {
    display: block;
  }

  .budget-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .budget-table tbody,
  .budget-table tfoot {
    display: block;
  }

  .budget-table tbody tr {
    display: block;
    background: var(--white);
    border: 1px solid var(--warm-grey);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-2);
  }

  .budget-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: var(--space-2) 0;
    border-bottom: 1px dashed var(--warm-grey);
    text-align: right;
    font-size: var(--text-sm);
  }

  .budget-table tbody td:last-child {
    border-bottom: none;
  }

  .budget-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--forest-600);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    margin-right: var(--space-3);
  }

  .budget-table tbody tr td:first-child {
    display: block;
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--forest-900);
    padding: 0 0 var(--space-2);
    border-bottom: 1px solid var(--warm-grey);
    margin-bottom: var(--space-1);
  }

  .budget-table tbody tr td:first-child::before {
    display: none;
  }

  .budget-table tfoot tr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--sage-100);
    border-radius: var(--radius-sm);
    margin-top: var(--space-2);
    font-size: var(--text-sm);
  }

  .budget-table tfoot th,
  .budget-table tfoot td {
    display: inline;
    padding: 0;
    border: none;
  }
}

/* ---------- Rate editor disclosure ---------- */

.rate-editor {
  margin: 0 0 var(--space-8);
}

.rate-editor summary {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--forest-700);
  cursor: pointer;
  padding: var(--space-3) 0;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rate-editor summary::-webkit-details-marker { display: none; }

.rate-editor summary::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232B3A2B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='9 18 15 12 9 6'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

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

.rate-editor summary:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.rate-editor-helper {
  font-size: var(--text-sm);
  color: var(--forest-600);
  margin: var(--space-2) 0 var(--space-4);
  max-width: 60ch;
}

.rate-editor-rows {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

@media (min-width: 640px) {
  .rate-editor-rows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3) var(--space-6);
  }
}

.rate-editor-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.rate-editor-row .form-label {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.rate-editor-row-input {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.rate-editor-currency,
.rate-editor-unit {
  font-size: var(--text-base);
  color: var(--forest-700);
  font-weight: 500;
}

.rate-editor-row .form-input-hours {
  width: 88px;
  max-width: 88px;
}

.rate-editor-reset {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--forest-700);
  background: none;
  border: none;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  border-radius: var(--radius-sm);
}

.rate-editor-reset:hover {
  color: var(--forest-900);
  background: var(--sage-100);
}

.rate-editor-reset:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
}

/* ---------- Compensation amount block ---------- */

.compensation-amount {
  margin: calc(-1 * var(--space-2)) 0 var(--space-3) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 400px;
}

.compensation-amount-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.compensation-amount-currency,
.compensation-amount-unit {
  font-size: var(--text-base);
  color: var(--forest-700);
  font-weight: 500;
}

.compensation-amount .form-input-hours {
  width: 120px;
  max-width: 120px;
}

/* ---------- Model C lock notice ---------- */

.notice-model-c {
  background: var(--sage-200);
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: flex-start;
}

.link-back {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--forest-700);
  background: none;
  border: none;
  padding: var(--space-2) 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius-sm);
  min-height: 48px;
}

.link-back span {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-back:hover {
  color: var(--forest-900);
}

.link-back:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
}

/* Disabled radio rows (Model C lock) */
.form-radio.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.form-radio.is-disabled input[type="radio"] {
  cursor: not-allowed;
}

/* ---------- Step 5: Protocols ---------- */

.step5-section {
  background: var(--white);
  border: 1px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-12);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  position: relative;
}

@media (min-width: 640px) {
  .step5-section {
    padding: var(--space-6);
  }
}

/* White cards on warm-white at 375px blend together — add a centered sage
   divider in the 48px gap between sections (skipped after the last). */
@media screen and (max-width: 639px) {
  .step5-section::after {
    content: "";
    display: block;
    width: 48px;
    height: 1px;
    background: var(--sage-300);
    position: absolute;
    bottom: calc(-1 * var(--space-6));
    left: 50%;
    transform: translateX(-50%);
  }

  .step5-section:last-child::after {
    display: none;
  }
}

.step5-section-heading {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--forest-800);
  margin: 0;
}

.step5-section-helper {
  margin: calc(-1 * var(--space-3)) 0 0;
}

.step5-section-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.step5-section-body > .form-group {
  margin: 0;
}

.step5-section-body > .form-field {
  margin: 0;
}

.step5-section-body .form-input-date {
  max-width: 240px;
}

/* Section-level decide-later opt-out — stays interactive while the body greys */
.section-decide-later {
  background: var(--sage-100);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  align-self: stretch;
}

.section-decide-later:hover {
  background: var(--sage-200);
}

.step5-section.section-disabled .step5-section-body {
  opacity: 0.45;
  pointer-events: none;
}

/* "Other" reveal block for channel + trigger free-text */
.step5-other-detail {
  margin-left: calc(24px + var(--space-3)); /* align with checkbox label text */
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 480px;
}

/* Section B — decision rows */
.step5-decision-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.step5-decision-row {
  background: var(--warm-grey-light);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.step5-decision-title {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--forest-800);
  margin: 0;
}

.step5-decision-helper {
  font-size: var(--text-sm);
  color: var(--forest-600);
  margin: calc(-1 * var(--space-2)) 0 0;
}

.step5-decision-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.step5-decision-row .form-field,
.step5-decision-row .form-group {
  margin: 0;
}

@media (min-width: 768px) {
  .step5-decision-fields {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--space-6);
  }
  .step5-decision-fields > .form-field {
    flex: 1 1 0;
    min-width: 0;
  }
  .step5-decision-fields > .form-group {
    flex: 0 0 auto;
  }
}

/* =========================================================================
   Output document — Phase 3a
   "Paper" card on screen, plain-paper on print. 7 sections + chrome.
   ========================================================================= */

.output-doc-wrap {
  margin-bottom: var(--space-8);
}

.output-doc {
  background: var(--white);
  border-radius: var(--radius-md);
  /* The one place CLAUDE.md hard constraints allow shadows. */
  box-shadow:
    0 2px 8px rgba(26, 46, 26, 0.08),
    0 4px 16px rgba(26, 46, 26, 0.04);
  padding: var(--space-6) var(--space-5);
  color: var(--forest-800);
  font-size: var(--text-base);
  line-height: 1.6;
}

@media (min-width: 640px) {
  .output-doc {
    padding: var(--space-12) var(--space-12);
  }
}

.output-doc-header {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--warm-grey);
}

.output-doc-brand {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--forest-600);
  margin: 0 0 var(--space-2);
}

.output-doc-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 2rem; /* 32px mobile */
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--forest-900);
  margin: 0 0 var(--space-5);
}

@media (min-width: 640px) {
  .output-doc-title {
    font-size: 2.25rem; /* 36px desktop */
  }
}

.output-doc-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-5);
  margin: 0;
  font-size: var(--text-sm);
}

.output-doc-meta-row {
  display: contents;
}

.output-doc-meta dt {
  color: var(--forest-600);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: var(--text-xs); /* 14px — meets the documented floor (CLAUDE.md §Hard constraints) */
  align-self: center;
}

.output-doc-meta dd {
  margin: 0;
  color: var(--forest-800);
}

.output-doc-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.output-doc-footer {
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--warm-grey);
  font-size: var(--text-sm);
  color: var(--forest-600);
}

.output-doc-footer p {
  margin: 0 0 var(--space-3);
}

.output-doc-footer p:last-child {
  margin-bottom: 0;
}

/* Section structure */

.output-section {
  break-inside: avoid-page;
}

.output-section-heading {
  font-family: var(--font-body);
  font-size: var(--text-xl); /* 24px */
  font-weight: 600;
  color: var(--forest-900);
  margin: 0 0 var(--space-4);
  letter-spacing: -0.005em;
}

@media screen and (max-width: 639px) {
  .output-section-heading {
    font-size: var(--text-lg); /* 20px mobile */
  }
}

.output-subheading {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--forest-800);
  margin: var(--space-6) 0 var(--space-3);
}

.output-paragraph {
  margin: 0 0 var(--space-4);
  color: var(--forest-800);
}

.output-paragraph:last-child {
  margin-bottom: 0;
}

.output-paragraph-lead {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--forest-900);
  margin-bottom: var(--space-3);
}

.output-paragraph-label {
  font-weight: 600;
  color: var(--forest-900);
  margin-bottom: var(--space-2);
}

.output-callout {
  background: var(--sage-100);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
}

.output-firewall {
  background: var(--warm-grey-light);
  border-left: 6px solid var(--forest-700);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--forest-700);
  margin-top: var(--space-6);
}

.output-decide-later {
  color: var(--forest-600);
  font-style: italic;
}

.output-list {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-6);
  color: var(--forest-800);
}

.output-list li {
  margin-bottom: var(--space-2);
  line-height: 1.6;
}

/* Tables */

.output-table-wrap {
  overflow-x: auto;
  margin: 0 0 var(--space-5);
}

.output-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.output-table th,
.output-table td {
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--warm-grey);
  vertical-align: top;
  line-height: 1.4;
}

.output-table thead th {
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--forest-600);
  background: var(--warm-grey-light);
}

.output-table .col-num {
  text-align: right;
}

.output-table .col-name {
  font-weight: 500;
  color: var(--forest-900);
}

.output-table .col-cat {
  font-weight: 500;
  color: var(--forest-800);
}

.output-table .col-change {
  color: var(--forest-600);
  font-size: var(--text-xs);
}

.output-table tfoot th,
.output-table tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--forest-800);
  font-weight: 700;
  color: var(--forest-900);
  padding-top: var(--space-3);
}

.output-table-numbers tfoot .output-total-money {
  font-size: var(--text-base);
}

/* ----- Mobile: card-stack data tables (screen only) -----
   Long tables (5-6 cols) don't fit on a 375px phone — horizontal scroll
   reads poorly for the 45-60 audience. Below 640px we collapse each row
   into a labelled card: first cell becomes the card title, the rest stack
   as label/value pairs (label sourced from `data-label`). Print and desktop
   keep the standard table layout.
   Exception: the signature table keeps its row layout (handwriting needs
   horizontal space). */

@media screen and (max-width: 639px) {
  .output-table-wrap {
    overflow-x: visible;
  }

  .output-table {
    display: block;
    width: 100%;
    border-collapse: collapse;
  }

  .output-table thead {
    /* Visually replaced by data-label::before pseudo-content on each td, but kept in
       the accessibility tree so screen-reader table-nav still announces columns. */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .output-table tbody,
  .output-table tfoot {
    display: block;
  }

  .output-table tr {
    display: block;
    background: var(--white);
    border: 1px solid var(--warm-grey);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-3);
  }

  .output-table tr:last-child {
    margin-bottom: 0;
  }

  .output-table td,
  .output-table th[scope="row"] {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    padding: var(--space-3) 0;
    border-bottom: 1px dashed var(--warm-grey);
    text-align: left;
    line-height: 1.4;
  }

  .output-table td:last-child,
  .output-table th[scope="row"]:last-child {
    border-bottom: none;
  }

  .output-table td::before,
  .output-table th[scope="row"]::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--forest-600);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
  }

  /* Hide cells where the original was visually empty (totals padding columns) */
  .output-table td[aria-hidden="true"] {
    display: none;
  }

  /* First cell becomes the card title — full-width, no label, larger type.
     Excluded for .output-signatures because the signature table runs its own
     mobile layout (handwriting lines via ::after) and the card-title border
     would otherwise leak through and double up under each name line. */
  .output-table:not(.output-signatures) tbody tr td:first-child,
  .output-table:not(.output-signatures) tfoot tr th:first-child {
    display: block;
    text-align: left;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--forest-900);
    padding: 0 0 var(--space-3);
    border-bottom: 1px solid var(--warm-grey);
    margin-bottom: var(--space-2);
  }

  .output-table:not(.output-signatures) tbody tr td:first-child::before,
  .output-table:not(.output-signatures) tfoot tr th:first-child::before {
    display: none;
  }

  /* Numeric cells right-align their value (default flex already does this) */
  .output-table .col-num {
    text-align: right;
  }

  /* Totals row — compact sage-100 summary bar, not another data card.
     Label across the top, key numbers side by side below. */
  .output-table tfoot tr.output-table-totals {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--sage-100);
    border: 1px solid var(--sage-200);
    border-radius: var(--radius-sm);
    padding: var(--space-4) var(--space-5);
    margin-top: var(--space-3);
  }

  .output-table tfoot tr.output-table-totals th:first-child,
  .output-table tfoot tr.output-table-totals td:first-child {
    display: block;
    width: 100%;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--forest-600);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-2);
    padding: 0;
    border: none;
  }

  .output-table tfoot tr.output-table-totals th:first-child::before,
  .output-table tfoot tr.output-table-totals td:first-child::before {
    display: none;
  }

  .output-table tfoot tr.output-table-totals td[aria-hidden="true"],
  .output-table tfoot tr.output-table-totals td:empty {
    display: none;
  }

  .output-table tfoot tr.output-table-totals td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 0;
    border: none;
  }

  .output-table tfoot tr.output-table-totals td::before {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--forest-600);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .output-table tfoot tr.output-table-totals .output-total-money {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--forest-900);
  }

  /* Signature table — stacked layout for readability on phones.
     NAME label → handwriting line → DATE label → shorter line, per signer.
     Print restores standard table layout (see @media print). */
  .output-signatures {
    display: block;
  }

  .output-signatures thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .output-signatures tbody {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
  }

  .output-signatures tbody tr {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
  }

  .output-signatures tbody td {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: 0;
    border: none;
    border-bottom: none;
    min-height: 0;
    height: auto;
  }

  .output-signatures tbody td::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--forest-600);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* Signature line — bottom border on a pseudo-element, with space above for
     someone to (theoretically) write. Date line is shorter. */
  .output-signatures tbody td::after {
    content: "";
    display: block;
    width: 100%;
    height: 0;
    border-bottom: 1.5px solid var(--forest-800);
    margin-top: var(--space-8);
  }

  .output-signatures tbody td.col-sig-date::after {
    width: 60%;
    margin-top: var(--space-5);
  }
}

/* Signature table — bigger lines + space for handwriting.
   Scoped to ≥640px so they don't override the mobile stacked layout above. */

@media screen and (min-width: 640px) {
  .output-signatures th,
  .output-signatures td {
    padding: var(--space-4) var(--space-3);
  }

  .output-signatures .col-sig-name {
    width: 65%;
  }

  .output-signatures tbody td {
    height: 56px;
    border-bottom: 1.5px solid var(--forest-800);
  }
}

/* Sub-blocks (remote / housing / compensation) */

.output-subblock {
  background: var(--sage-100);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-5);
  margin-top: var(--space-5);
  break-inside: avoid-page;
}

.output-subblock-housing {
  background: var(--sage-200);
}

.output-subblock-comp {
  background: var(--warm-grey-light);
}

.output-subblock .output-subheading {
  margin-top: 0;
}

/* Action toolbar (outside document, hidden in print) */

.output-actions {
  margin-top: var(--space-8);
}

.output-actions-back {
  margin-top: var(--space-12);
}

/* ---------- In-document actions (Download / Print) ----------
   Live inside the .output-doc card chrome, between the body sections and the
   footer disclaimer. Print stylesheet hides them so paper output is clean. */

.output-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

/* ---------- Share-link banner ----------
   Sage-100 callout with inline CTA on desktop, stacked on mobile.
   Mirrors the .output-callout visual language so the share affordance reads
   as a friendly invitation, not a separate utility section. */

.output-share-banner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-5);
  background: var(--sage-100);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  margin-top: var(--space-8);
}

.output-share-banner-text {
  flex: 1;
  margin: 0;
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--forest-800);
}

.output-share-banner-text strong {
  color: var(--forest-900);
  font-weight: 600;
}

.output-share-banner-cta {
  flex-shrink: 0;
  white-space: nowrap;
}

@media screen and (max-width: 639px) {
  .output-share-banner {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
    padding: var(--space-5);
  }

  .output-share-banner-cta {
    width: 100%;
  }

  .output-doc-actions {
    flex-direction: column;
    margin-top: var(--space-8);
  }

  .output-doc-actions .btn {
    width: 100%;
  }
}

/* ---------- Output banner (status / schema-mismatch notice) ---------- */

.output-banner {
  background: var(--sage-200);
  color: var(--forest-900);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  font-size: var(--text-base);
  line-height: 1.5;
  /* Layout: text on the left, dismiss button on the right. The :not([hidden])
     guard prevents the layout from overriding the hidden attribute (otherwise
     display: flex would defeat the browser's display: none for [hidden]). */
  align-items: flex-start;
  gap: var(--space-3);
}

.output-banner:not([hidden]) {
  display: flex;
}

.output-banner-text {
  flex: 1;
  margin: 0;
}

.output-banner-dismiss {
  /* Hidden by default — only error banners are dismissible. Transient
     status messages auto-clear after 5s and need no button. */
  display: none;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  margin: -8px -8px 0 0; /* Pull into padding so visual padding stays balanced */
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--forest-700);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.output-banner.is-error .output-banner-dismiss {
  display: inline-flex;
}

.output-banner-dismiss:hover,
.output-banner-dismiss:focus-visible {
  background: rgba(43, 58, 43, 0.08);
  color: var(--forest-900);
}

.output-banner.is-error {
  background: var(--warm-grey-light);
  border-left: 4px solid var(--error);
}

/* ---------- Companion message section (Phase 3b) ---------- */

.companion-wrap {
  margin-top: var(--space-12);
}

.companion-section {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow:
    0 2px 8px rgba(26, 46, 26, 0.08),
    0 4px 16px rgba(26, 46, 26, 0.04);
}

@media (min-width: 640px) {
  .companion-section {
    padding: var(--space-8);
  }
}

.companion-heading {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--forest-900);
  margin: 0 0 var(--space-2);
}

@media screen and (max-width: 639px) {
  .companion-heading {
    font-size: var(--text-base);
  }
}

.companion-helper {
  font-size: var(--text-base);
  color: var(--forest-700);
  margin: 0 0 var(--space-5);
  line-height: 1.5;
}

.companion-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.companion-tab {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--forest-700);
  background: var(--white);
  border: 1.5px solid var(--warm-grey);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  min-height: 48px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.companion-tab:hover {
  background: var(--sage-100);
}

.companion-tab.is-active,
.companion-tab[aria-selected="true"] {
  background: var(--forest-700);
  border-color: var(--forest-700);
  color: var(--white);
}

.companion-tab:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
}

.companion-textarea-wrap {
  margin-bottom: var(--space-4);
}

.companion-textarea {
  width: 100%;
  max-width: none;
  min-height: 180px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  resize: vertical;
}

/* [Link]-trap warning, sits between textarea and Copy-message action row */
.link-trap-prompt {
  background: var(--sage-200);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.link-trap-prompt-text {
  margin: 0;
  font-size: var(--text-base);
  color: var(--forest-800);
  line-height: 1.5;
}

.link-trap-prompt-text code {
  font-family: 'Switzer', monospace;
  background: var(--white);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.95em;
}

.link-trap-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.link-trap-prompt-actions .btn {
  min-height: 48px;
  padding: var(--space-3) var(--space-5);
}

.companion-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.companion-status {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--forest-700);
  min-height: 24px;
}

/* ---------- Share-link privacy modal (native <dialog>) ---------- */

.share-modal {
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-6);
  max-width: 480px;
  width: calc(100% - var(--space-8));
  background: var(--white);
  color: var(--forest-800);
  box-shadow: 0 16px 48px rgba(26, 46, 26, 0.25);
}

.share-modal::backdrop {
  background: rgba(26, 46, 26, 0.55);
}

.share-modal[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.share-modal-title {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--forest-900);
  margin: 0;
}

.share-modal-body p {
  margin: 0 0 var(--space-3);
  font-size: var(--text-base);
  line-height: 1.5;
}

.share-modal-list {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
  color: var(--forest-800);
}

.share-modal-list li {
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
  line-height: 1.5;
}

.share-modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

@media (max-width: 480px) {
  .share-modal {
    padding: var(--space-5);
  }
  .share-modal-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .share-modal-actions .btn {
    width: 100%;
  }
}

/* =========================================================================
   Discoverability — FAQ + About sections on the landing view
   (Phase 4a: static HTML for AI extractors and traditional search.)
   FAQ uses sage-100 cards with right-side chevron. Headings sit at section
   scale (40px desktop / 32px mobile) — bigger than the standard text-2xl
   to anchor each block as its own major area below the hero.
   ========================================================================= */

.faq-section,
.about-section,
.feedback-section {
  margin: var(--space-12) 0 0;
}

.feedback-section {
  padding-bottom: var(--space-8);
}

.feedback-helper {
  font-size: var(--text-base);
  color: var(--forest-700);
  line-height: 1.6;
  margin: 0 0 var(--space-6);
  max-width: 56ch;
}

.feedback-thanks {
  background: var(--sage-100);
  border-radius: var(--radius-sm);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  font-size: var(--text-base);
  color: var(--forest-900);
}

.feedback-thanks p { margin: 0; }

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 56ch;
}

.feedback-form .form-field {
  margin: 0;
}

.feedback-textarea {
  resize: vertical;
  min-height: 7rem;
  font-family: var(--font-body);
}

.form-label-aside {
  font-weight: 400;
  color: var(--forest-700);
  font-size: var(--text-sm);
}

.required-mark {
  color: var(--forest-700);
  margin-left: 2px;
}

.feedback-submit {
  align-self: flex-start;
  margin-top: var(--space-2);
}

.faq-heading,
.about-heading {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 500;
  color: var(--forest-900);
  margin: 0 0 var(--space-6);
  letter-spacing: -0.015em;
  line-height: 1.1;
}

/* ----- FAQ items: sage-100 cards with right-side chevron ----- */

.faq-item {
  margin: 0 0 var(--space-3);
  background: var(--sage-100);
  border-radius: var(--radius-md);
}

.faq-item:last-of-type {
  margin-bottom: 0;
}

.faq-item summary {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--forest-800);
  cursor: pointer;
  padding: var(--space-5) var(--space-6);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-radius: var(--radius-md);
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232B3A2B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 20px 20px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  transform: rotate(180deg);
}

.faq-item summary:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
}

.faq-item summary:hover {
  color: var(--forest-900);
}

.faq-item .faq-q {
  flex: 1;
  color: inherit;
}

.faq-item .faq-a {
  padding: 0 var(--space-6) var(--space-5);
}

.faq-item .faq-a p {
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--forest-800);
  margin: 0;
}

.faq-meta,
.about-meta {
  font-size: var(--text-sm);
  color: var(--forest-600);
  margin: var(--space-6) 0 0;
  font-variant-numeric: tabular-nums;
}

/* ----- About / Methodology ----- */

.about-item {
  margin: 0 0 var(--space-6);
}

.about-item:last-of-type {
  margin-bottom: 0;
}

.about-subheading {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--forest-900);
  margin: 0 0 var(--space-3);
}

.about-item p {
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--forest-800);
  margin: 0;
}

.about-item a {
  color: var(--forest-700);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.about-item a:hover {
  color: var(--forest-900);
}

.about-item a:focus-visible {
  outline: 3px solid var(--forest-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Mobile — slightly shorter card padding and smaller heading on 375px. */
@media screen and (max-width: 639px) {
  .faq-section,
  .about-section,
  .feedback-section {
    margin-top: var(--space-8);
  }

  .faq-heading,
  .about-heading {
    font-size: 32px;
    margin-bottom: var(--space-5);
  }

  .faq-item summary {
    font-size: var(--text-base);
    padding: var(--space-4) var(--space-5);
  }

  .faq-item .faq-a {
    padding: 0 var(--space-5) var(--space-4);
  }
}

/* =========================================================================
   Print stylesheet — output document only
   Hides screen chrome (header logo, action toolbar, wizard nav, footer band)
   and lets the .output-doc occupy the full page in pure black on white.
   ========================================================================= */

@media print {
  body {
    background: var(--white);
    color: #000;
    font-size: 12pt;
    line-height: 1.5;
  }

  .skip-link,
  .noscript,
  .header,
  .footer,
  .progress,
  .wizard-nav,
  .save-indicator,
  .output-screen-intro,
  .output-banner,
  .output-actions,
  .output-doc-actions,
  .output-share-banner,
  .companion-wrap,
  .companion-section,
  .share-modal,
  button {
    display: none !important;
  }

  .hero {
    background: transparent;
    padding: 0;
  }

  .wizard-shell,
  .output-shell {
    box-shadow: none;
    border: none;
    padding: 0;
    max-width: 100%;
  }

  /* Document goes full-bleed inside @page margins */
  .output-doc {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    color: #000;
    background: #fff;
  }

  .output-doc-header {
    border-bottom: 2px solid #000;
  }

  .output-doc-title,
  .output-section-heading,
  .output-subheading,
  .output-paragraph-lead,
  .output-paragraph-label,
  .output-table .col-name {
    color: #000;
  }

  .output-paragraph,
  .output-doc-meta dd,
  .output-doc-footer,
  .output-list,
  .output-table {
    color: #000;
  }

  .output-table th,
  .output-table td {
    border-bottom: 1px solid #000;
  }

  .output-table thead th {
    background: #f3f3f3;
    border-bottom: 2px solid #000;
    color: #000;
  }

  .output-table tfoot th,
  .output-table tfoot td {
    border-top: 2px solid #000;
  }

  .output-callout,
  .output-firewall {
    background: transparent;
    border-left: 3px solid #000;
    padding-left: var(--space-3);
  }

  .output-subblock {
    background: transparent;
    border: 1px solid #000;
    page-break-inside: avoid;
    break-inside: avoid-page;
  }

  .output-section,
  .output-table-wrap,
  .output-doc-body > section {
    page-break-inside: avoid;
    break-inside: avoid-page;
  }

  /* Restore standard table layout for signature handwriting on paper —
     overrides the mobile stacked layout in case the user prints from a
     narrow window. */
  .output-signatures {
    display: table;
  }
  .output-signatures thead {
    display: table-header-group;
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }
  .output-signatures tbody {
    display: table-row-group;
  }
  .output-signatures tbody tr {
    display: table-row;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
  }
  .output-signatures tbody td {
    display: table-cell;
    border-bottom: 1.5px solid #000;
    height: 56px;
    padding: var(--space-4) var(--space-3);
  }
  .output-signatures tbody td::before,
  .output-signatures tbody td::after {
    display: none;
  }

  @page {
    margin: 2cm;
  }
}
