:root {
  --brand: #0ea5e9;
  --brand-dark: #0369a1;
  --brand-deep: #0c4a6e;
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-muted: #64748b;  /* WCAG 2.1 AA: contrast 4.6:1 on white */
  --line: #e2e8f0;
  --good: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 4px 6px rgba(15, 23, 42, 0.05), 0 12px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ----- nav ----- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 2rem;
}
.nav .brand { display: flex; align-items: center; }
.nav nav a {
  color: var(--ink-soft); text-decoration: none; margin-left: 1.5rem;
  font-size: 0.92rem; font-weight: 500;
}
.nav nav a:hover { color: var(--brand); }

/* ----- hero ----- */
.hero { max-width: 1180px; margin: 0 auto; padding: 3rem 1.5rem 2rem; }
.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  line-height: 1.15; margin: 0 0 1rem;
  letter-spacing: -0.02em;
}
.hero .hl { color: var(--brand-dark); }
.hero .lead {
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: var(--ink-soft); max-width: 780px; margin: 0 0 1.6rem;
}

.price-box {
  display: inline-flex; align-items: center; gap: 1.2rem;
  background: linear-gradient(135deg, #0c4a6e 0%, #0369a1 100%);
  color: white; padding: 1rem 1.4rem; border-radius: 12px;
  margin-bottom: 2rem;
}
.price-box .price { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.price-box .price-detail { font-size: 0.92rem; line-height: 1.4; }

.cta-grid {
  display: grid; grid-template-columns: 1.3fr 0.9fr; gap: 2rem;
  margin-top: 1rem;
}
@media (max-width: 880px) { .cta-grid { grid-template-columns: 1fr; } }

/* ----- form ----- */
.form-card, .trust-box {
  background: var(--card);
  border-radius: 14px; padding: 1.8rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.form-card h2 { margin: 0 0 1.2rem; font-size: 1.3rem; }
.form-card label {
  display: block; margin-bottom: 1rem;
  font-size: 0.88rem; font-weight: 600; color: var(--ink);
}
.form-card label > input:not([type="checkbox"]):not([type="radio"]),
.form-card label > select,
.form-card label > textarea {
  display: block; width: 100%;
  margin-top: 0.4rem; padding: 0.6rem 0.75rem;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.95rem; font-weight: 400; color: var(--ink);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-card label > input:not([type="checkbox"]):not([type="radio"]):focus,
.form-card label > select:focus,
.form-card label > textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.form-card textarea { resize: vertical; min-height: 100px; }

/* PDF upload */
.pdf-upload-row {
  display: flex; align-items: center; gap: 0.75rem;
  margin-top: 0.4rem; margin-bottom: 0.5rem;
}
.pdf-upload-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: #f0f9ff; color: var(--brand-dark);
  border: 1px solid #bae6fd; border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.pdf-upload-btn:hover { background: #e0f2fe; border-color: var(--brand); }
.pdf-upload-btn:active { transform: translateY(1px); }
.pdf-icon { font-size: 1rem; }
.pdf-status {
  font-size: 0.82rem; color: var(--ink-muted); font-weight: 400;
}
.pdf-status.success { color: var(--good); font-weight: 500; }
.pdf-status.error { color: var(--bad); font-weight: 500; }
.pdf-status.working { color: var(--brand-dark); font-weight: 500; }

.form-card fieldset.medical {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem 1rem 0.6rem; margin: 0 0 1rem;
}
.form-card fieldset legend {
  padding: 0 0.5rem; font-size: 0.82rem; font-weight: 600;
  color: var(--brand-dark); text-transform: uppercase; letter-spacing: 0.05em;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1rem;
  margin: 0.6rem 0 1rem;
}
.checkbox-grid label {
  margin: 0; font-weight: 400; font-size: 0.92rem;
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.checkbox-grid label:hover { border-color: var(--brand); background: #f0f9ff; }
.checkbox-grid label:has(input:checked) {
  border-color: var(--brand-dark); background: #e0f2fe;
}
.checkbox-grid input[type="checkbox"] {
  width: 1.05rem; height: 1.05rem; margin: 0; flex-shrink: 0;
  accent-color: var(--brand-dark); cursor: pointer;
}

.cta-button {
  width: 100%;
  background: var(--brand-dark);
  color: white; border: 0;
  padding: 0.95rem 1.2rem; border-radius: 10px;
  font-size: 1.05rem; font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  margin-top: 0.4rem;
}
.cta-button:hover { background: #075985; }
.cta-button:active { transform: translateY(1px); }
.cta-button.big { display: inline-block; width: auto; padding: 1.1rem 2rem; font-size: 1.1rem; margin-top: 1.5rem; text-decoration: none; text-align: center; }

.legal-note {
  font-size: 0.78rem; color: var(--ink-muted);
  margin: 1rem 0 0;
}
.legal-note a { color: var(--ink-soft); }

/* ----- trust box ----- */
.trust-box h3 { margin: 0 0 0.8rem; font-size: 1.1rem; }
.trust-box p { font-size: 0.95rem; color: var(--ink-soft); margin: 0 0 0.9rem; }
.trust-badges {
  display: grid;
  /* minmax(0, 1fr) lets columns shrink below content's min-content — without it,
     the long label "REFUND IF NOT SIGNED" forces the grid wider than the viewport on iPhone. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 1.2rem;
}
.trust-badges .badge {
  background: #f0f9ff; border: 1px solid #bae6fd;
  border-radius: 8px; padding: 0.7rem 0.5rem; text-align: center;
}
.trust-badges .num {
  display: block; font-size: 1.05rem; font-weight: 700; color: var(--brand-dark);
}
.trust-badges span:last-child {
  font-size: 0.72rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em;
  word-break: break-word;
}

/* Mobile-only — tighten layout so all sections fit inside iPhone viewport (≤480px). */
@media (max-width: 480px) {
  /* Hero/cards: tighter outer padding so content has more room */
  .hero { padding: 2rem 1rem 1.5rem; }
  .form-card, .trust-box { padding: 1.2rem; }

  /* Price-box: was inline-flex with non-wrapping text, exceeded viewport.
     Switch to flex column on mobile so it fills width and wraps cleanly. */
  .price-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    width: 100%;
    padding: 0.9rem 1rem;
    margin-bottom: 1.5rem;
  }
  .price-box .price { font-size: 1.8rem; }
  .price-box .price-detail { font-size: 0.85rem; }

  /* Trust badges: 3 across, very small labels */
  .trust-badges { gap: 0.35rem; }
  .trust-badges .badge { padding: 0.55rem 0.3rem; }
  .trust-badges .num { font-size: 0.95rem; }
  .trust-badges span:last-child {
    font-size: 0.6rem;
    letter-spacing: 0.01em;
  }

  /* Checkbox grid: tighter pads so long labels like "Cardiovascular disease" fit */
  .checkbox-grid label {
    padding: 0.5rem 0.55rem;
    font-size: 0.86rem;
  }
}

/* Defensive — prevent any child from forcing horizontal scroll on mobile */
html, body {
  overflow-x: clip;
}

/* ----- accessibility ----- */

/* Visible focus ring for keyboard navigation. :focus-visible only triggers
   on keyboard focus (Tab), not on mouse click — so mouse users don't see rings. */
*:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip-to-content link — invisible until focused via Tab */
.skip-link {
  position: absolute;
  top: -50px;
  left: 0;
  background: var(--brand-dark);
  color: white;
  padding: 0.7rem 1.2rem;
  text-decoration: none;
  border-radius: 0 0 6px 0;
  z-index: 100;
  font-weight: 600;
  transition: top 0.15s;
}
.skip-link:focus {
  top: 0;
}

/* Inline form error (role=alert, aria-live=assertive) — replaces alert() */
.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  color: #991b1b;
  font-size: 0.92rem;
  margin: 1rem 0;
  font-weight: 500;
}
.form-error[hidden] { display: none; }

/* ----- how it works ----- */
.how, .sample, .faq, .closing { max-width: 1100px; margin: 0 auto; padding: 3rem 1.5rem; }
.how h2, .sample h2, .faq h2, .closing h2 {
  font-size: 1.7rem; margin-top: 0; letter-spacing: -0.01em;
}
.steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-top: 1.6rem; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; } }
.steps li {
  background: var(--card); border-radius: 12px; padding: 1.6rem;
  border: 1px solid var(--line); position: relative;
}
.step-num {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; margin-bottom: 0.8rem;
}
.steps h3 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.steps p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }

/* ----- sample letter ----- */
.sample .muted { color: var(--ink-muted); font-size: 0.92rem; margin-top: 0.4rem; }
.letter-preview {
  background: white; border: 1px solid var(--line); border-radius: 12px;
  padding: 2rem; margin-top: 1.5rem;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 0.94rem; line-height: 1.65;
  max-height: 520px; overflow-y: auto;
  box-shadow: var(--shadow);
}
.letter-preview p { margin: 0 0 1rem; }

/* ----- FAQ ----- */
.faq details {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 0.6rem;
}
.faq summary {
  cursor: pointer; font-weight: 600; color: var(--ink);
  list-style: none; padding-right: 1.5rem; position: relative;
}
.faq summary::after {
  content: "+"; position: absolute; right: 0; top: -2px;
  font-size: 1.5rem; font-weight: 300; color: var(--brand-dark);
  transition: transform 0.2s;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details[open] { box-shadow: var(--shadow); }
.faq p { color: var(--ink-soft); font-size: 0.95rem; margin: 0.8rem 0 0; }

/* ----- closing ----- */
.closing { text-align: center; padding-top: 3rem; padding-bottom: 4rem; }
.paths { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin: 1.6rem 0 0; }
@media (max-width: 720px) { .paths { grid-template-columns: 1fr; } }
.path { padding: 1.6rem; border-radius: 12px; text-align: left; border: 1px solid var(--line); }
.path.bad { background: #fef2f2; border-color: #fecaca; }
.path.good { background: #f0fdf4; border-color: #bbf7d0; }
.path h3 { margin: 0 0 0.6rem; }
.path ul { margin: 0; padding-left: 1.2rem; color: var(--ink-soft); font-size: 0.92rem; }
.path li { margin-bottom: 0.4rem; }

/* ----- footer ----- */
footer {
  text-align: center; padding: 2rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--ink-muted); font-size: 0.88rem;
  background: white;
}
footer a { color: var(--ink-soft); margin: 0 0.4rem; }
