:root {
  --ink: #111817;
  --muted: #5f6a68;
  --paper: #fbfaf6;
  --surface: #ffffff;
  --line: #dcded8;
  --soft-line: #e9e9e3;
  --teal: #167e76;
  --teal-dark: #0f5d57;
  --peach: #f1c5ae;
  --yellow: #f0cf73;
  --blue: #a9d6d4;
  --berry: #8c526b;
  --danger: #9f3434;
  --shadow: 0 18px 52px rgba(37, 45, 42, 0.09);
  --accent: #167e76;
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--paper); scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--teal-dark); }
img, svg { display: block; max-width: 100%; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 12px 16px;
  color: #fff;
  background: var(--ink);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

:focus-visible {
  outline: 3px solid #e19a35;
  outline-offset: 3px;
}
[tabindex="-1"]:focus { outline: 0; }

.ambient {
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(241, 197, 174, 0.16) 0 16%, transparent 16% 77%, rgba(169, 214, 212, 0.17) 77% 100%);
  pointer-events: none;
}

.loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 15px;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }
.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  height: 72px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  padding: 0 36px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.96);
  backdrop-filter: blur(14px);
}
.brand-button {
  width: 94px;
  height: 54px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.brand-button img { width: 88px; height: 50px; object-fit: contain; object-position: left center; }
.header-context { min-width: 0; display: flex; align-items: center; gap: 12px; }
.mode-label, .clinic-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.mode-label { color: var(--teal-dark); font-weight: 700; text-transform: uppercase; }
.clinic-label::before { content: "·"; margin-right: 12px; color: #a3aaa7; }
.progress-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 16px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.progress-button strong {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font-size: 13px;
}

.school-banner {
  padding: 10px 36px;
  border-bottom: 1px solid #d6be7e;
  background: #fff2c9;
  color: #4a3d1d;
  font-size: 13px;
  line-height: 1.5;
}

main { flex: 1; }
.screen { min-height: calc(100vh - 122px); }
.screen[hidden] { display: none; }

.home-layout {
  width: min(1480px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(340px, 0.78fr) minmax(640px, 1.22fr);
  gap: 70px;
  padding: 72px 48px 68px;
}
.intro-column { align-self: start; position: sticky; top: 116px; }
.eyebrow {
  margin: 0 0 14px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
h1, h2, h3, p { letter-spacing: 0; }
h1, .summary-heading h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 64px;
  line-height: 1.02;
  font-weight: 500;
}
.lead {
  max-width: 680px;
  margin: 24px 0 0;
  color: #3e4846;
  font-size: 19px;
  line-height: 1.62;
}
.trust-strip {
  margin-top: 28px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.trust-strip p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.text-button {
  margin: 9px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.age-fieldset { margin: 28px 0 0; padding: 0; border: 0; }
.age-fieldset legend { margin-bottom: 12px; color: var(--ink); font-size: 13px; font-weight: 700; }
.segmented-control { display: flex; flex-wrap: wrap; gap: 8px; }
.age-choice {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #46504e;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.age-choice[aria-pressed="true"] { border-color: var(--teal); background: var(--teal); color: #fff; }
.journey-progress { margin-top: 30px; }
.journey-progress > div:first-child { display: flex; align-items: baseline; gap: 6px; color: var(--muted); font-size: 12px; }
.journey-progress strong, #exploredCount { color: var(--ink); font-size: 24px; font-weight: 600; }
.progress-track { height: 4px; margin-top: 8px; overflow: hidden; background: #e1e3dd; }
.progress-track span { width: 0; height: 100%; display: block; background: var(--teal); transition: width 240ms ease; }

.section-heading { min-height: 56px; display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-family: Fraunces, Georgia, serif; font-size: 34px; font-weight: 500; }
.section-heading p { margin: 0 0 4px; color: var(--muted); font-size: 12px; }
.systems-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.system-card {
  position: relative;
  min-width: 0;
  aspect-ratio: 0.86;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.system-card:hover { transform: translateY(-3px); border-color: var(--card-accent); box-shadow: 0 14px 32px rgba(37, 45, 42, 0.09); }
.system-card.is-explored { border-color: color-mix(in srgb, var(--card-accent) 58%, white); }
.system-card.is-asked { border-color: var(--card-accent); box-shadow: inset 0 0 0 2px var(--card-accent); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-number { color: #626c69; font-family: "Courier New", monospace; font-size: 10px; }
.card-state {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: transparent;
  font-size: 12px;
  font-weight: 700;
}
.system-card.is-asked .card-state { border-color: var(--card-accent); background: var(--card-accent); color: #fff; }
.card-icon { width: 74px; height: 74px; margin: auto; color: var(--card-accent); }
.card-icon svg { width: 100%; height: 100%; }
.card-icon .st { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.card-icon .thin { stroke-width: 2; }
.card-icon .faint { opacity: 0.32; }
.card-icon .fs { fill: color-mix(in srgb, var(--card-accent) 15%, transparent); stroke: none; }
.card-copy { min-width: 0; }
.card-copy strong { display: block; font-family: Fraunces, Georgia, serif; font-size: 22px; line-height: 1.1; font-weight: 500; }
.card-copy span { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }

.detail-shell, .summary-shell { width: min(1320px, 100%); margin: 0 auto; padding: 38px 48px 72px; }
.back-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--teal-dark);
  font-weight: 700;
  cursor: pointer;
}
.back-button span { font-size: 22px; }
.detail-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 64px; margin-top: 30px; }
.system-portrait {
  position: sticky;
  top: 130px;
  height: 430px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.system-number { position: absolute; right: 16px; top: 8px; color: #899087; font-family: Fraunces, Georgia, serif; font-size: 122px; line-height: 1; }
.detail-icon { position: relative; width: 220px; height: 220px; color: var(--accent); }
.detail-icon svg { width: 100%; height: 100%; filter: drop-shadow(0 18px 30px color-mix(in srgb, var(--accent) 18%, transparent)); }
.detail-icon .st { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.detail-icon .thin { stroke-width: 2; }
.detail-icon .faint { opacity: 0.26; }
.detail-icon .fs { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
.detail-content { max-width: 800px; }
.detail-content h1 { max-width: 760px; font-size: 54px; }
.detail-meaning { max-width: 720px; margin: 22px 0 0; color: #3f4947; font-size: 19px; line-height: 1.6; }
.detail-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; padding-top: 34px; border-top: 1px solid var(--line); }
.detail-columns h2 { margin: 0; font-size: 14px; line-height: 1.4; }
.check-list { margin: 18px 0 0; padding: 0; list-style: none; }
.check-list li { position: relative; margin: 0 0 14px; padding-left: 20px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.check-list li::before { content: ""; position: absolute; left: 0; top: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.evidence-panel { margin-top: 26px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.evidence-panel summary { color: var(--teal-dark); font-size: 13px; font-weight: 700; cursor: pointer; }
.evidence-panel p { margin: 12px 0 5px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.evidence-panel a { font-size: 12px; }
.red-flag-panel { margin-top: 22px; padding: 16px 18px; border-left: 4px solid #bd6b60; background: #f8ece8; }
.red-flag-panel summary { color: #793d35; font-size: 13px; font-weight: 700; cursor: pointer; }
.red-flag-panel ul { margin: 12px 0 0; padding-left: 18px; color: #66403a; font-size: 13px; line-height: 1.6; }
.reflection-choice { margin-top: 38px; padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.reflection-choice h2 { margin: 0; font-family: Fraunces, Georgia, serif; font-size: 27px; font-weight: 500; }
.choice-buttons { display: flex; gap: 10px; margin-top: 18px; }
.choice-button { min-height: 48px; padding: 12px 18px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-weight: 700; cursor: pointer; }
.choice-button.ask { border-color: var(--teal); color: var(--teal-dark); }
.choice-button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.choice-help { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

.summary-heading { max-width: 850px; margin-top: 30px; }
.summary-heading h1 { font-size: 56px; }
.summary-context { margin: 15px 0 0; color: var(--teal-dark); font-size: 12px; font-weight: 700; }
.summary-layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 64px; margin-top: 46px; }
.question-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.question-row { min-height: 120px; display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 16px; align-items: center; padding: 22px 16px 22px 0; border-bottom: 1px solid var(--line); }
.question-row:nth-child(odd) { border-right: 1px solid var(--line); }
.question-row:nth-child(even) { padding-left: 22px; }
.question-icon { width: 54px; height: 54px; color: var(--row-accent); }
.question-icon svg { width: 100%; height: 100%; }
.question-icon .st { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.question-icon .thin { stroke-width: 2; }
.question-icon .faint { opacity: 0.28; }
.question-icon .fs { fill: color-mix(in srgb, var(--row-accent) 14%, transparent); stroke: none; }
.question-row h2 { margin: 0; font-family: Fraunces, Georgia, serif; font-size: 23px; font-weight: 500; }
.question-row p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.empty-summary { padding: 34px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.empty-summary h2 { margin: 0; font-family: Fraunces, Georgia, serif; font-size: 30px; font-weight: 500; }
.empty-summary p { max-width: 600px; margin: 12px 0 0; color: var(--muted); line-height: 1.6; }
.next-step-panel { align-self: start; padding: 28px; border: 1px solid var(--ink); border-radius: 8px; background: var(--ink); color: #fff; }
.next-step-panel .eyebrow { color: #8ed7d0; }
.next-step-panel h2 { margin: 0; font-family: Fraunces, Georgia, serif; font-size: 32px; line-height: 1.08; font-weight: 500; }
.next-step-panel > p:not(.eyebrow):not(.consent-note) { margin: 16px 0 0; color: #c8cecc; font-size: 14px; line-height: 1.65; }
.summary-actions { display: grid; gap: 9px; margin-top: 24px; }
.primary-action, .secondary-action, .quiet-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 17px;
  border-radius: 6px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.primary-action { border: 1px solid var(--teal); background: var(--teal); color: #fff; }
.primary-action:hover { background: var(--teal-dark); }
.secondary-action { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.quiet-action { min-height: 40px; border: 0; background: transparent; color: #a9dcd7; text-decoration: underline; text-underline-offset: 3px; }
.consent-note { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid #34403e; color: #98a29f; font-size: 11px; line-height: 1.55; }
.kiosk-handoff { margin-top: 24px; }
.kiosk-handoff h3 { margin: 0; font-size: 16px; }
.kiosk-handoff p { margin: 8px 0 14px; color: #c8cecc; font-size: 12px; line-height: 1.5; }
.qr-code { width: 178px; min-height: 178px; display: grid; place-items: center; padding: 14px; background: #fff; }
.qr-code img, .qr-code canvas { width: 150px !important; height: 150px !important; }

.site-footer { min-height: 50px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 20px; padding: 13px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

dialog { color: var(--ink); }
dialog::backdrop { background: rgba(17, 24, 23, 0.62); backdrop-filter: blur(5px); }
.info-dialog, .map-dialog { width: min(620px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 26px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.map-dialog { width: min(680px, calc(100% - 28px)); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.dialog-header h2 { margin: 0; font-family: Fraunces, Georgia, serif; font-size: 29px; font-weight: 500; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.info-dialog > p { color: var(--muted); line-height: 1.65; }
.urgent-box { margin: 22px 0; padding: 18px; border-left: 4px solid var(--danger); background: #f8eaea; }
.urgent-box strong { color: var(--danger); }
.urgent-box p { margin: 8px 0 0; color: #633737; font-size: 14px; line-height: 1.6; }
.health-map { margin-top: 18px; border: 1px solid var(--line); background: #fff; }
.map-head { padding: 28px; border-bottom: 1px solid var(--line); }
.map-brand { color: var(--teal-dark); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.map-head h3 { margin: 10px 0 0; font-family: Fraunces, Georgia, serif; font-size: 36px; line-height: 1.05; font-weight: 500; }
.map-meta { margin-top: 9px; color: var(--muted); font-size: 11px; }
.map-body { padding: 12px 28px 26px; }
.map-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--soft-line); }
.map-row strong { font-size: 14px; }
.map-row span { color: var(--muted); font-size: 11px; }
.map-status { align-self: center; color: var(--berry) !important; font-weight: 700; }
.map-foot { padding: 18px 28px; background: #f2f4ee; color: var(--muted); font-size: 10px; line-height: 1.55; }
.dialog-actions { display: flex; gap: 10px; margin-top: 18px; }
.status-message { min-height: 20px; margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.toast { position: fixed; z-index: 100; right: 20px; bottom: 20px; max-width: 340px; padding: 13px 16px; border-radius: 6px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 13px; }
.consent-banner { position: fixed; z-index: 90; right: 18px; bottom: 18px; width: min(430px, calc(100% - 36px)); padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.consent-banner p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.consent-banner > div { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 12px; }
.consent-banner .text-button { margin: 0; }
.consent-banner .primary-action { min-height: 40px; padding: 8px 14px; border: 0; }

@media (max-width: 1100px) {
  h1 { font-size: 48px; }
  .home-layout { grid-template-columns: 1fr; gap: 46px; padding-top: 52px; }
  .intro-column { position: static; }
  .systems-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .system-card { aspect-ratio: 0.9; }
  .detail-layout { grid-template-columns: 270px minmax(0, 1fr); gap: 42px; }
  .system-portrait { height: 360px; }
  .detail-content h1 { font-size: 46px; }
  .summary-layout { grid-template-columns: minmax(0, 1fr) 350px; gap: 40px; }
}

@media (max-width: 800px) {
  .site-header { height: 64px; gap: 12px; padding: 0 18px; }
  .brand-button { width: 74px; height: 48px; }
  .brand-button img { width: 70px; height: 44px; }
  .clinic-label { display: none; }
  .progress-button span { display: none; }
  .progress-button { padding: 6px; border-radius: 50%; }
  .school-banner { padding: 9px 18px; }
  .home-layout, .detail-shell, .summary-shell { padding-left: 22px; padding-right: 22px; }
  .home-layout { padding-top: 38px; }
  h1 { font-size: 42px; }
  .lead { font-size: 17px; }
  .systems-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .system-card { aspect-ratio: 1; }
  .detail-layout { grid-template-columns: 1fr; margin-top: 20px; }
  .system-portrait { position: relative; top: auto; height: 230px; }
  .detail-icon { width: 150px; height: 150px; }
  .detail-content h1 { font-size: 42px; }
  .detail-columns { grid-template-columns: 1fr; gap: 18px; }
  .summary-heading h1 { font-size: 44px; }
  .summary-layout { grid-template-columns: 1fr; }
  .next-step-panel { order: -1; }
}

@media (max-width: 480px) {
  .mode-label { font-size: 10px; }
  .home-layout { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 38px; }
  .lead { font-size: 16px; }
  .section-heading { align-items: start; flex-direction: column; gap: 4px; }
  .section-heading h2 { font-size: 29px; }
  .systems-grid { gap: 8px; }
  .system-card { min-height: 182px; padding: 13px; }
  .card-icon { width: 60px; height: 60px; }
  .card-copy strong { font-size: 20px; }
  .detail-shell, .summary-shell { padding: 25px 16px 52px; }
  .detail-content h1, .summary-heading h1 { font-size: 38px; }
  .detail-meaning { font-size: 17px; }
  .choice-buttons { flex-direction: column; }
  .question-list { grid-template-columns: 1fr; }
  .question-row:nth-child(odd) { border-right: 0; }
  .question-row:nth-child(even) { padding-left: 0; }
  .dialog-actions { flex-direction: column; }
}

@media print {
  body * { visibility: hidden !important; }
  #healthMap, #healthMap * { visibility: visible !important; }
  #healthMap { position: absolute; inset: 0; width: 100%; border: 0; }
}

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