:root {
  --ink: #11110f;
  --muted: #69655f;
  --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 { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid rgba(191, 129, 32, .38); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.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: 56px; height: 56px; 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: .16em; text-transform: uppercase; margin: 0 0 8px; }
h1, h2, h3, p { overflow-wrap: break-word; }
h1 { font-size: clamp(1.25rem, 4.7vw, 2rem); line-height: 1.15; margin: 0; letter-spacing: -.025em; }
h2 { font-size: clamp(1.8rem, 7vw, 3.4rem); line-height: 1.04; margin: 0 0 18px; letter-spacing: -.042em; }
h3 { font-size: clamp(1.2rem, 4vw, 1.6rem); line-height: 1.18; margin: 0 0 10px; }
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(22px, 5vw, 54px); }
.intro-lead { font-size: clamp(1.2rem, 3.5vw, 1.65rem); line-height: 1.42; max-width: 790px; }
.scope-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 28px 0; }
.scope-grid div { border: 1px solid var(--line); border-radius: 15px; padding: 16px; display: grid; gap: 4px; }
.scope-grid span { color: var(--muted); font-size: .92rem; }
.notice { border-radius: var(--radius-md); padding: 18px 20px; margin: 24px 0; }
.notice p { margin: 6px 0 0; }
.notice-neutral { background: var(--info); border-left: 4px solid var(--info-line); }
.acknowledgment { display: flex; align-items: flex-start; gap: 12px; padding: 16px 0; cursor: pointer; }
.acknowledgment input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--gold-dark); flex: 0 0 auto; }
.inline-error, .error-summary { color: #8f251c; background: #fff0ed; border: 1px solid #e5b0a9; border-radius: 12px; padding: 12px 14px; font-weight: 700; }
.inline-error { margin-bottom: 14px; }
.error-summary { margin: 0 0 22px; }

.button { min-height: 52px; border-radius: 13px; padding: 13px 22px; border: 1px solid var(--ink); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.button-primary { background: var(--ink); color: var(--white); }
.button-primary:hover { background: #292824; }
.button-secondary { background: var(--white); color: var(--ink); }
.button-secondary:hover { background: var(--soft); }

.progress-wrap { margin-bottom: 30px; }
.progress-meta { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 8px; color: var(--muted); font-weight: 700; font-size: .9rem; }
.progress-track { height: 5px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 50%; background: var(--gold); transition: width .2s ease; }
.form-step { min-height: 440px; }
.field-group { border: 0; padding: 0; margin: 0 0 26px; }
.field-group legend { font-weight: 800; margin-bottom: 12px; }
.radio-list { display: grid; gap: 10px; }
.radio-list label { display: flex; align-items: flex-start; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 15px; cursor: pointer; }
.radio-list label:has(input:checked) { border-color: var(--gold); background: #fffaf0; }
.radio-list input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--gold-dark); flex: 0 0 auto; }
.radio-list span { display: grid; gap: 3px; }
.radio-list small, .helper, .section-note { color: var(--muted); }
.helper { font-size: .88rem; margin: 8px 0 0; }
.section-note { margin-top: -6px; }
.field { display: grid; gap: 7px; }
.field label { font-weight: 800; }
.field-short { max-width: 270px; }
.input-unit { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--white); }
.input-unit:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(191, 129, 32, .12); }
.input-unit input { width: 100%; min-width: 0; border: 0; padding: 13px 14px; background: transparent; }
.input-unit input:focus { outline: 0; }
.input-unit span { display: grid; place-items: center; min-width: 52px; padding: 0 12px; border-left: 1px solid var(--line); background: var(--soft); color: var(--muted); font-weight: 800; }
.measure-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.optional-panel { margin-top: 30px; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 0 20px 20px; }
.optional-panel summary { cursor: pointer; font-weight: 800; padding: 18px 0; }
.optional-panel > p { color: var(--muted); }
.form-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; }
.form-actions .button:last-child { margin-left: auto; }

.results-heading { max-width: 760px; margin-bottom: 26px; }
.result-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: clamp(18px, 4vw, 30px); background: var(--white); margin-bottom: 16px; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.status-grid div { background: var(--paper); border-radius: 13px; padding: 13px; }
.status-grid dt { color: var(--muted); font-size: .8rem; }
.status-grid dd { margin: 3px 0 0; font-weight: 800; }
.modifier-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.modifier-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; background: var(--white); }
.modifier-value { display: flex; align-items: baseline; gap: 10px; margin: 15px 0 12px; }
.modifier-value strong { font-size: clamp(2.4rem, 9vw, 4.1rem); line-height: .9; }
.modifier-value span { color: var(--muted); }
.modifier-card dl { margin: 0; }
.modifier-card dt { color: var(--muted); font-size: .82rem; }
.modifier-card dd { margin: 2px 0 12px; font-weight: 800; }
.profile-card { background: var(--ink); color: var(--white); }
.profile-card .eyebrow { color: #d9a34b; }
.profile-card p { color: #d8d5cf; }
.optional-results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.optional-result { background: var(--paper); border-radius: 13px; padding: 16px; }
.optional-result strong { display: block; font-size: 1.35rem; margin-bottom: 6px; }
.optional-result p { color: var(--muted); font-size: .9rem; margin: 0; }
.warning-card { background: #fff7e8; border-color: #e5bd78; }
.warning-card p:last-child { margin-bottom: 0; }
.limitations { padding: 0; overflow: hidden; }
.limitations summary { cursor: pointer; font-weight: 800; padding: 20px 24px; }
.details-body { padding: 0 24px 12px; }
.medical-disclaimer { background: var(--info); border-left: 4px solid var(--info-line); border-radius: var(--radius-md); padding: 18px 20px; margin: 18px 0; }
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.engine-version { margin: 20px 0 0; color: var(--muted); font-size: .78rem; }

@media (max-width: 720px) {
  .app-shell { padding: 14px 10px 32px; }
  .tool-header { align-items: flex-start; }
  .tool-mark { width: 48px; height: 48px; }
  .intro-panel, .assessment, .results { padding: 22px 18px; border-radius: 22px; }
  .scope-grid, .measure-grid, .modifier-grid, .optional-results, .status-grid { grid-template-columns: 1fr; }
  .form-step { min-height: 0; }
  .optional-panel { padding-inline: 16px; }
  .form-actions .button { flex: 1 1 0; }
  .result-actions .button { width: 100%; }
}

@media print {
  body { background: #fff; }
  .app-shell { max-width: none; padding: 0; }
  .tool-header, .result-actions { display: none !important; }
  .results { border: 0; box-shadow: none; padding: 0; }
  .result-card, .modifier-card, .medical-disclaimer { break-inside: avoid; }
  .limitations details { display: block; }
  .limitations summary { list-style: none; }
}
