:root {
  color-scheme: light;
  --ink: #16232c;
  --muted: #5f6d78;
  --paper: #f7f9fc;
  --panel: #ffffff;
  --line: #dbe4f0;
  --red: #b42318;
  --red-dark: #7a271a;
  --teal: #0b57d0;
  --teal-dark: #073f9f;
  --teal-soft: #eaf2ff;
  --blue: #0b57d0;
  --amber: #a15c07;
  --shadow: 0 18px 46px rgba(22, 35, 44, 0.13);
  --max: 1120px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: 0;
  background: var(--paper);
}

body.modal-open {
  overflow: hidden;
}

body.emergency-page {
  background: #fff8f6;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(217, 224, 221, 0.82);
  background: rgba(247, 249, 252, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 950;
}

.brand-mark img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.02rem;
  letter-spacing: 0.08em;
}

.brand small {
  color: var(--muted);
  font-weight: 750;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.top-nav a {
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 850;
}

.top-nav a:hover {
  background: #fff;
  color: var(--ink);
}

main {
  display: grid;
  gap: 20px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px 18px 42px;
}

.emergency-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #f2b9b2;
  border-radius: 8px;
  background: #fff5f3;
  color: var(--red-dark);
  font-weight: 760;
}

.info-band .emergency-strip {
  grid-column: 1 / -1;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 22px;
  align-items: stretch;
  min-height: calc(100vh - 172px);
}

.hero-copy {
  display: grid;
  align-content: center;
  gap: 18px;
  min-width: 0;
  padding: 30px 0;
}

.eyebrow {
  margin: 0;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 0;
  font-size: clamp(2.35rem, 6vw, 5.1rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 1.04;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
}

.lede {
  max-width: 720px;
  margin-bottom: 0;
  color: #3f4f5a;
  font-size: 1.18rem;
}

.hero-actions,
.preview-actions,
.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-link,
.secondary-link,
.primary-button,
.secondary-button {
  display: inline-grid;
  place-items: center;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 900;
  line-height: 1.12;
}

.primary-link,
.primary-button {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 14px 28px rgba(11, 87, 208, 0.22);
}

.secondary-link,
.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-button.quiet {
  color: var(--teal-dark);
}

.primary-button {
  width: 100%;
  min-height: 58px;
  font-size: 1.08rem;
}

.hero-media {
  position: relative;
  min-height: 470px;
  margin: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #dce7e2;
  box-shadow: var(--shadow);
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-media figcaption {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.builder-section,
.medicine-list-section,
.evidence-section,
.info-band,
.profile-pathway,
.scanned-profile {
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(22, 35, 44, 0.07);
}

.scanned-profile {
  border-color: #f2b9b2;
  background: #fff8f6;
}

.scanned-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.scanned-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #f2d1cc;
  border-radius: 8px;
  background: #fff;
}

.scanned-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.scanned-grid dd {
  margin: 0;
  color: var(--ink);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.scanned-note {
  margin: 0;
  color: var(--red-dark);
  font-weight: 900;
}

.emergency-profile-shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  max-width: 980px;
  padding-top: 22px;
}

.emergency-profile-card {
  width: 100%;
  border-width: 2px;
  box-shadow: var(--shadow);
}

.emergency-brand {
  margin-bottom: 16px;
}

.emergency-profile-card h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 4.2rem);
  line-height: 0.98;
}

.emergency-profile-card .secondary-link {
  justify-self: start;
}

.emergency-profile-actions {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding-top: 4px;
}

.emergency-profile-actions p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
}

.section-heading {
  display: grid;
  gap: 6px;
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 410px);
  gap: 18px;
  align-items: start;
}

.qr-form,
.optional-grid,
.risk-list,
.profile-grid {
  display: grid;
  gap: 14px;
}

.question-block {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.question-block legend {
  padding: 0;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 900;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f1;
}

.segmented-control label {
  position: relative;
}

.segmented-control input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  place-items: center;
  min-height: 54px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 950;
}

.segmented-control input:checked + span {
  background: #fff;
  color: var(--teal);
  box-shadow: 0 6px 18px rgba(22, 35, 44, 0.1);
}

.multi-select {
  position: relative;
}

.multi-select-toggle,
select,
.field input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.multi-select-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 900;
  text-align: left;
}

.multi-select-menu {
  position: static;
  z-index: 15;
  margin-top: 6px;
  max-height: 330px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.medicine-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 780;
}

.medicine-option:hover {
  background: var(--teal-soft);
}

.medicine-option input {
  width: 22px;
  height: 22px;
  accent-color: var(--teal);
}

select {
  appearance: none;
  padding: 10px 38px 10px 12px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 21px,
    calc(100% - 14px) 21px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  font-weight: 850;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 850;
}

.field.compact {
  margin-top: 4px;
}

.field input {
  padding: 10px 12px;
}

.optional-details {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.optional-details summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-weight: 950;
}

.optional-grid {
  margin-top: 12px;
}

.preview-panel {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.lock-card {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 6px solid var(--red);
  border-radius: 8px;
  background: #fff;
  color: #111827;
  box-shadow: var(--shadow);
  text-align: center;
}

.lock-eyebrow,
.lock-note {
  margin: 0;
  font-weight: 900;
}

.lock-eyebrow {
  color: var(--red-dark);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lock-card h3 {
  color: var(--red);
  font-size: clamp(1.38rem, 4vw, 2.1rem);
  line-height: 1;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: min(100%, 270px);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-code {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: center;
}

.qr-code img,
.qr-code canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lock-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
  text-align: left;
}

.lock-card dl div {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f6f8f7;
}

.lock-card dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lock-card dd {
  margin: 0;
  color: var(--ink);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.lock-note {
  color: var(--red-dark);
  font-size: 0.92rem;
}

.info-band {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: start;
  background: #edf7f4;
}

.info-band p,
.evidence-section p,
.profile-pathway p {
  margin: 8px 0 0;
  color: #40515b;
}

.risk-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.risk-list article,
.profile-grid article {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.risk-list strong,
.profile-grid strong {
  color: var(--ink);
  font-size: 1.02rem;
}

.risk-list span,
.profile-grid span {
  color: var(--muted);
}

.profile-pathway {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  align-items: center;
}

.profile-media-grid {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 12px;
}

.profile-media-grid img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
  border-radius: 8px;
}

.profile-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.medicine-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.medicine-chips span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 820;
}

.evidence-section {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.7fr);
  align-items: center;
}

.source-links a {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-weight: 880;
}

.fullscreen-overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(13, 24, 31, 0.84);
}

.fullscreen-overlay[hidden] {
  display: none;
}

.fullscreen-card {
  width: min(430px, 100%);
}

.fullscreen-card .lock-card {
  min-height: min(760px, calc(100vh - 96px));
  align-content: center;
}

.close-button {
  position: absolute;
  top: 16px;
  right: 16px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  white-space: pre-wrap;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(11, 87, 208, 0.28);
  outline-offset: 2px;
}

@media (max-width: 920px) {
  .site-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    justify-content: flex-start;
  }

  main {
    padding-inline: 14px;
  }

  .hero,
  .builder-layout,
  .info-band,
  .evidence-section,
  .profile-pathway {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 0;
  }

  .hero-copy {
    padding: 14px 0 0;
  }

  .hero-media {
    min-height: 320px;
  }

  .preview-panel {
    position: static;
  }

  .risk-list,
  .profile-grid,
  .scanned-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }

  .builder-section,
  .medicine-list-section,
  .evidence-section,
  .info-band,
  .profile-pathway {
    padding: 16px;
  }

  .hero-media {
    min-height: 280px;
  }

  .profile-media-grid {
    grid-template-columns: 1fr;
  }

  .profile-media-grid img {
    min-height: 190px;
  }

  .primary-link,
  .secondary-link {
    width: 100%;
  }
}
