:root {
  --ink: #11110f;
  --muted: #68645e;
  --paper: #f6f3ed;
  --white: #fff;
  --gold: #bf8120;
  --gold-dark: #87590f;
  --line: #ded8ce;
  --soft: #eee8de;
  --info: #eaf0f2;
  --info-line: #5c7783;
  --radius-lg: 28px;
  --radius-md: 18px;
  --shadow: 0 18px 55px rgba(26, 22, 14, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Arial, Helvetica, sans-serif; line-height: 1.55; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid rgba(191, 129, 32, .35); outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell { width: min(100%, 980px); margin: 0 auto; padding: 20px 16px 48px; }
.tool-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.tool-mark { width: 54px; height: 54px; border: 1px solid var(--gold); border-radius: 50%; display: grid; place-items: center; color: var(--gold-dark); font-weight: 800; flex: 0 0 auto; }
.eyebrow { color: var(--gold-dark); font-size: .76rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; margin: 0 0 8px; }
h1, h2, h3, p { overflow-wrap: break-word; }
h1 { font-size: clamp(1.25rem, 4.8vw, 2rem); line-height: 1.15; margin: 0; letter-spacing: -.025em; }
h2 { font-size: clamp(1.75rem, 7vw, 3.5rem); line-height: 1.04; margin: 0 0 20px; letter-spacing: -.045em; }
h3 { font-size: clamp(1.25rem, 4vw, 1.7rem); line-height: 1.18; margin: 0 0 12px; letter-spacing: -.025em; }
p { margin: 0 0 16px; }

.intro-panel, .assessment, .results { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: clamp(24px, 6vw, 58px); }
.intro-lead { font-size: clamp(1.25rem, 4.5vw, 2rem); line-height: 1.25; font-weight: 650; letter-spacing: -.025em; }
.privacy-note { display: flex; gap: 12px; align-items: flex-start; background: #f8f2e7; border-radius: 14px; padding: 15px; margin: 24px 0; }
.privacy-note > span { color: var(--gold-dark); font-weight: 900; }
.privacy-note p { margin: 0; }

.button { min-height: 48px; border-radius: 12px; padding: 12px 20px; border: 1px solid var(--ink); font-weight: 750; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--ink); color: var(--white); }
.button-secondary { background: var(--white); color: var(--ink); }
.intro-panel > .button { width: 100%; }
.plain-details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
summary { cursor: pointer; font-weight: 750; }
.plain-details p { margin: 14px 0 0; color: var(--muted); }

.progress-wrap { margin-bottom: 34px; }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; font-weight: 700; margin-bottom: 8px; }
.progress-track { height: 5px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 16.66%; background: var(--gold); transition: width .25s ease; }
.error-summary { background: #fff3e6; border-left: 4px solid var(--gold-dark); border-radius: 10px; padding: 13px 15px; margin-bottom: 22px; font-weight: 700; }
.form-step { min-height: 390px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend, .field > label { display: block; font-weight: 800; margin-bottom: 10px; }
.field, .field-group { margin-bottom: 24px; }
.field-row { display: grid; gap: 14px; }
.optional { color: var(--muted); font-weight: 500; }
input[type="number"], input[type="date"], select { width: 100%; min-height: 52px; border: 1px solid #cfc8bd; border-radius: 12px; background: var(--white); color: var(--ink); padding: 10px 13px; }
.helper { color: var(--muted); font-size: .88rem; margin: 8px 0 0; }

.choice-grid, .radio-list { display: grid; gap: 10px; }
.choice-card, .radio-list label, .segmented label { position: relative; }
.choice-card input, .radio-list input, .segmented input { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice-card > span, .radio-list label > span { display: block; min-height: 52px; border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px 15px 48px; position: relative; transition: border .15s ease, background .15s ease; }
.choice-card > span::before, .radio-list label > span::before { content: ''; position: absolute; left: 16px; top: 18px; width: 17px; height: 17px; border: 1.5px solid #9b958c; border-radius: 50%; }
.choice-card input:checked + span, .radio-list input:checked + span { border-color: var(--gold); background: #fbf6ed; }
.choice-card input:checked + span::before, .radio-list input:checked + span::before { border: 5px solid var(--gold); }
.choice-card input:focus-visible + span, .radio-list input:focus-visible + span, .segmented input:focus-visible + span { outline: 3px solid rgba(191, 129, 32, .35); outline-offset: 2px; }
.choice-card strong, .choice-card small, .radio-list small { display: block; }
.choice-card small, .radio-list small { color: var(--muted); font-weight: 400; margin-top: 5px; }
.compact-list { grid-template-columns: 1fr; }

.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.segmented-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented span { display: grid; place-items: center; min-height: 48px; text-align: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; font-weight: 700; }
.segmented input:checked + span { background: var(--ink); color: var(--white); border-color: var(--ink); }
.acknowledgment { display: grid; grid-template-columns: 24px 1fr; gap: 11px; align-items: start; border: 1px solid var(--line); border-radius: 14px; padding: 15px; font-weight: 650; }
.acknowledgment input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--gold-dark); }
.form-actions { display: flex; gap: 10px; margin-top: 28px; }
.form-actions .button { flex: 1; }

.results-heading { margin-bottom: 34px; }
.results-heading > p:last-child { color: var(--muted); }
.result-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: clamp(20px, 4vw, 32px); margin-bottom: 16px; }
.result-card p:last-child { margin-bottom: 0; }
.result-number { font-size: clamp(3.5rem, 15vw, 7rem); line-height: .9; letter-spacing: -.07em; font-weight: 700; margin: 14px 0 18px; }
.evidence-chip { display: inline-flex; align-items: center; min-height: 30px; border: 1px solid #d7b168; border-radius: 99px; padding: 5px 10px; color: var(--gold-dark); font-size: .76rem; font-weight: 800; margin-bottom: 16px; }
.evidence-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.evidence-chips .evidence-chip { margin-bottom: 0; }
.evidence-chip-historical { border-color: #c9c2b7; background: #f5f2ec; color: #625d55; }
.model-name { color: var(--muted); font-weight: 750; margin-top: -4px; }
.result-label { font-weight: 800; margin-top: -8px; }
.historical-note { background: #f3f0ea; border-left: 4px solid #a39b8e; border-radius: 12px; color: #504c46; padding: 15px 16px; margin: 20px 0; }
.notice-inline { background: #f8f2e7; border-radius: 12px; color: #5f513a; padding: 13px 15px; margin: 14px 0; }
.details-body h4 { color: var(--ink); font-size: 1rem; margin: 20px 0 8px; }
.formula-line { background: #faf8f4; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 12px 14px; }
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.status-grid > div { background: var(--white); padding: 13px; }
.status-grid dt { color: var(--muted); font-size: .8rem; margin-bottom: 3px; }
.status-grid dd { margin: 0; font-weight: 750; }
.course-change { font-size: clamp(2rem, 9vw, 4rem); line-height: 1; font-weight: 700; letter-spacing: -.04em; margin: 10px 0; }
.course-interval { color: var(--muted); font-weight: 650; }
.notice-card { background: var(--info); border-left: 4px solid var(--info-line); }
.notice-card h3 { font-size: 1.25rem; }
.model-facts { margin-top: 18px; display: grid; gap: 7px; }
.model-facts div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 7px; }
.model-facts dt { color: var(--muted); }
.model-facts dd { margin: 0; font-weight: 750; text-align: right; }
.details-card { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.details-body { padding-top: 12px; color: var(--muted); }

.prediction-layout { display: grid; gap: 22px; }
.prediction-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.prediction-table th, .prediction-table td { border-bottom: 1px solid var(--line); padding: 10px 4px; text-align: left; }
.prediction-table td:last-child { text-align: right; font-weight: 800; }
.chart-wrap { background: #faf8f4; border-radius: 14px; padding: 14px; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: .78rem; margin-top: 8px; }
.legend-solid::before, .legend-dashed::before { content: ''; display: inline-block; width: 20px; margin-right: 6px; vertical-align: middle; border-top: 2px solid var(--ink); }
.legend-dashed::before { border-top-style: dashed; border-top-color: var(--gold-dark); }
.limitations summary { font-size: 1.05rem; }
.medical-disclaimer { background: #f5efe4; border: 1px solid #e0c99d; border-radius: 14px; padding: 17px; margin: 18px 0 28px; }
.result-cta { background: var(--ink); color: var(--white); border-radius: var(--radius-md); padding: clamp(24px, 5vw, 42px); }
.result-cta h2 { font-size: clamp(1.7rem, 6vw, 2.8rem); }
.result-cta .button-primary { background: var(--white); color: var(--ink); border-color: var(--white); }
.result-cta .button-secondary { background: transparent; color: var(--white); border-color: #7a7772; }
.cta-actions { display: grid; gap: 10px; }
.restart-button { width: 100%; margin-top: 18px; min-height: 44px; background: transparent; border: 0; text-decoration: underline; font-weight: 700; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

@media (min-width: 640px) {
  .app-shell { padding: 34px 24px 70px; }
  .two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compact-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .intro-panel > .button { width: auto; min-width: 240px; }
  .status-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .prediction-layout { grid-template-columns: minmax(280px, .8fr) minmax(360px, 1.2fr); align-items: center; }
  .cta-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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