:root {
  /* Accents (shared) */
  --accent-blue: #3d88e8;
  --link-blue: #2f7fe0;
  --category-green: #57c462;
  --category-amber: #e0a52a;
  --category-orange: #ef8b3c;
  --category-red: #e24b41;

  /* Light theme surfaces */
  --app-bg: #d7d9de;
  --frame: #ffffff;
  --page: #ededee;
  --surface: #ffffff;
  --panel: #eeeeef;
  --row-hover: #fafafa;
  --text: #2d2e33;
  --text-strong: #22242a;
  --text-muted: #8f9298;
  --text-faint: #bfc0c4;
  --label: #73757b;
  --line: #e4e4e7;
  --brand: #c7c8ca;
  --tool: #c2c4c7;
  --tool-active: #a5a8ad;
  --tools-bg: #f4f4f6;
  --more-bg: #fafafb;
  --more-ring: #f2f2f3;
  --control-bg: #f2f2f4;
  --toggle-off: #e4e4e7;
  --answer-bg: #f3f3f6;
  --answer-correct: #d6f3dc;
  --answer-wrong: #f8dddd;
  --seg-track: #f0f0f2;
  --seg-selected: #ffffff;
  --shadow: 0 7px 17px rgb(0 0 0 / 13%);
  --row-shadow: 0 6px 14px rgb(0 0 0 / 8%);
  --frame-shadow: 0 18px 50px rgb(0 0 0 / 22%);

  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

[data-theme="dark"] {
  --accent-blue: #4a93f0;
  --link-blue: #5aa0f2;
  --category-green: #58cc6a;
  --category-amber: #e8b23a;
  --category-orange: #f5934a;
  --category-red: #ef5b52;

  --app-bg: #08080a;
  --frame: #1c1c1e;
  --page: #131315;
  --surface: #2a2a2d;
  --panel: #242427;
  --row-hover: rgb(255 255 255 / 5%);
  --text: #f2f2f5;
  --text-strong: #ffffff;
  --text-muted: #9a9ca3;
  --text-faint: #6c6e75;
  --label: #9a9ca3;
  --line: #3a3a3e;
  --brand: #6e7075;
  --tool: #6e7075;
  --tool-active: #9a9ca3;
  --tools-bg: #2a2a2d;
  --more-bg: #2a2a2d;
  --more-ring: #1c1c1e;
  --control-bg: #2f2f33;
  --toggle-off: #48484c;
  --answer-bg: #2f2f33;
  --answer-correct: #1e3a26;
  --answer-wrong: #3a2020;
  --seg-track: #242427;
  --seg-selected: #3a3a3e;
  --shadow: 0 7px 20px rgb(0 0 0 / 45%);
  --row-shadow: 0 6px 16px rgb(0 0 0 / 35%);
  --frame-shadow: 0 18px 50px rgb(0 0 0 / 55%);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-bg);
  color: var(--text);
}

button, select, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* ----------------------------- phone frame ----------------------------- */
.window {
  position: relative;
  width: min(100vw, 412px);
  height: min(100vh, 892px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--frame);
  border-radius: 40px;
  box-shadow: var(--frame-shadow);
}

.topbar {
  flex: none;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--frame);
  user-select: none;
  z-index: 6;
}

.brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-toggle {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: var(--control-bg);
  color: var(--accent-blue);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .2px;
  cursor: pointer;
  transition: transform .12s ease;
}

.theme-toggle {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--control-bg);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease;
}

.theme-toggle svg { width: 17px; height: 17px; }

.lang-toggle:active, .theme-toggle:active { transform: scale(.94); }

#app {
  position: relative;
  flex: 1;
  overflow: hidden;
}

/* --------------------------- scroll containers ------------------------- */
.lung-scroll,
.sheet-view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.lung-scroll::-webkit-scrollbar,
.sheet-view::-webkit-scrollbar { width: 0; height: 0; }

.lung-scroll {
  background: var(--frame);
  padding: 4px 16px 80px;
}

.sheet-view {
  background: var(--page);
  padding-bottom: 40px;
  animation: sheetIn .2s cubic-bezier(.2, .8, .2, 1);
}

@keyframes sheetIn {
  from { opacity: .86; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ------------------------------ home nav ------------------------------- */
.home-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2px 0 12px;
}

.side-tools {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  height: 34px;
  padding: 0 13px;
  background: var(--tools-bg);
  border-radius: 16px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 6%);
}

.tool, .more {
  appearance: none;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--tool);
  background: transparent;
  cursor: pointer;
}

.tool {
  width: 22px;
  height: 22px;
  transition: transform .12s ease, color .12s ease;
}

.tool svg { width: 22px; height: 22px; fill: currentColor; }

.tool-outline svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.more {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--more-bg);
  box-shadow: inset 0 0 0 5px var(--more-ring), 0 5px 16px rgb(0 0 0 / 8%);
  transition: transform .12s ease;
}

.more svg { width: 18px; height: 18px; fill: var(--tool); }

.tool:active, .more:active,
.back-button:active, .list-row:active,
.question-row:active, .answer:active, .modifier:active { transform: scale(.96); }

/* ------------------------------ headings ------------------------------- */
.back-button {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border: 1px solid rgb(0 0 0 / 3%);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: 0 9px 22px rgb(0 0 0 / 10%);
  font-size: 34px;
  line-height: 26px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease;
}

.nav-title {
  margin: 18px 0 26px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  line-height: 20px;
  color: var(--text-strong);
}

.nav-title.in-flow { margin: 0 0 24px; }

.wide-content {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 50px 4px 36px;
}

.wide-content h1 {
  margin: 0 0 16px;
  font-size: 27px;
  line-height: 33px;
  font-weight: 860;
  color: var(--text-strong);
}

.wide-content h3,
.section-label {
  margin: 22px 12px 9px;
  color: var(--label);
  font-size: 14px;
  font-weight: 760;
  line-height: 20px;
}

.wide-content h1 + h3 { margin-top: -8px; }

.list-card,
.white-pill,
.result-box,
.why-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 .5px 1px rgb(0 0 0 / 3%), var(--row-shadow);
  overflow: hidden;
}

.list-row,
.question-row {
  width: 100%;
  min-height: 50px;
  padding: 0 14px 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 13px;
  background: transparent;
  color: var(--text-strong);
  text-align: left;
  font-size: 14px;
  font-weight: 620;
  cursor: pointer;
  transition: background .12s ease, transform .12s ease;
}

.list-row:hover, .question-row:hover { background: var(--row-hover); }

.list-row:last-child,
.question-row:last-child,
.detail-row:last-child,
.text-field-row:last-child,
.segmented-block:last-child { border-bottom: 0; }

.row-icon {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--accent-blue);
  display: grid;
  place-items: center;
}

.row-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.6px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.list-row span:nth-child(2),
.question-row span { flex: 1; }

.list-row em,
.question-row em {
  color: var(--text-faint);
  font-style: normal;
  font-size: 26px;
  line-height: 1;
}

.detail-page h1 { margin-top: 0; }

.detail-row {
  min-height: 64px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.detail-row strong { font-size: 14px; line-height: 18px; color: var(--text-strong); }

.detail-row span,
.muted {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
}

.assessment-page { margin-top: 8px; }

.assessment-page .intro {
  max-width: 360px;
  margin: 0 auto 8px;
  text-align: center;
  font-size: 14px;
  line-height: 19px;
  font-weight: 600;
  color: var(--text);
}

.assessment-page .muted { max-width: 340px; margin: 0 auto 4px; text-align: center; }

.blue-heading { color: var(--accent-blue) !important; margin-top: 18px !important; }

.question-list { border-radius: 16px; overflow: hidden; }

.question-row {
  align-items: flex-start;
  min-height: 64px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.question-row > strong { color: var(--accent-blue); font-size: 15px; }

.question-row span strong,
.question-text strong,
.explanation strong { font-weight: 760; color: inherit; }

.question-row span { font-size: 14px; line-height: 19px; font-weight: 650; }

.question-page { margin-top: 8px; background: var(--surface); border-radius: 16px; max-width: none; width: 100%; }

body[data-route="question"] .sheet-view { background: var(--surface); }

.question-text { margin: 0 0 18px; font-size: 15px; line-height: 21px; font-weight: 650; color: var(--text); }

.answers { display: grid; gap: 10px; }

.answer {
  min-height: 40px;
  padding: 11px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--answer-bg);
  color: var(--text-strong);
  text-align: left;
  font-size: 14px;
  font-weight: 650;
}

.answer.correct { background: var(--answer-correct); }
.answer.wrong { background: var(--answer-wrong); }
.answer.disabled:not(.correct):not(.wrong) { color: var(--text-faint); opacity: .85; }

.explanation { margin: 0 0 6px; font-size: 14px; line-height: 20px; font-weight: 650; color: var(--text); }

.white-pill {
  padding: 12px 18px;
  text-align: center;
  font-size: 14px;
  line-height: 19px;
  font-weight: 600;
  color: var(--text);
}

.brock-page { margin-top: 8px; position: relative; }
.brock-page .nav-title { margin-bottom: 26px; }

.reset-link {
  position: absolute;
  top: -2px;
  right: 5px;
  border: 0;
  padding: 5px 13px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--accent-blue);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 1px 4px rgb(0 0 0 / 7%);
  cursor: pointer;
}

.form-list { overflow: hidden; }

.text-field-row,
.segmented-block {
  min-height: 54px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.text-field-row { flex-direction: row; align-items: center; justify-content: space-between; }

.text-field-row input {
  width: 120px;
  border: 0;
  outline: 0;
  text-align: right;
  color: var(--text);
  background: transparent;
}

.text-field-row input::placeholder { color: var(--text-faint); }

.segmented span { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 11px; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0;
  overflow: hidden;
  border-radius: 14px;
  background: var(--seg-track);
  padding: 2px;
}

.segmented button {
  min-height: 26px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease;
}

.segmented button.selected { background: var(--seg-selected); border-radius: 13px; box-shadow: 0 1px 4px rgb(0 0 0 / 12%); }

.brock-switch { min-height: 46px; padding: 5px 14px; border-bottom: 1px solid var(--line); }

.result-box { min-height: 42px; padding: 10px 15px; display: flex; align-items: center; gap: 12px; }
.result-box strong { color: var(--accent-blue); font-size: 24px; }
.result-box span { color: var(--text-muted); font-size: 14px; font-weight: 650; }

.reference-link {
  display: block;
  margin: 16px auto 0;
  border: 0;
  background: transparent;
  color: var(--link-blue);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.reference-link.inline { display: inline-block; margin: 0; text-decoration: none; }
.reference-link.centered { display: block; margin: 22px auto 0; }

.info-page { margin-top: 4px; }
.info-card { overflow: hidden; }

.legal-row { margin: 18px 12px 26px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.legal-row button { border: 0; background: transparent; color: var(--link-blue); font-size: 11px; font-weight: 700; cursor: pointer; }

.why-card { padding: 16px 20px; text-align: center; box-shadow: 0 4px 12px rgb(0 0 0 / 10%), var(--row-shadow); }
.why-card .shield { margin: 0 auto 4px; color: var(--accent-blue); display: grid; place-items: center; }
.why-card .shield svg { width: 27px; height: 27px; }
.why-card strong { color: var(--text-strong); }
.why-card p { margin: 8px 0 0; color: var(--text-muted); font-size: 13px; line-height: 18px; font-weight: 600; }

/* ------------------------------ calculator ----------------------------- */
.tab-pill {
  height: 24px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: var(--accent-blue);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 1px 5px rgb(0 90 220 / 30%);
  margin-bottom: 18px;
}

.score-card {
  --cat: var(--category-green);
  width: 100%;
  min-height: 252px;
  padding: 16px 24px 21px;
  margin: 0 auto 22px;
  text-align: center;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.score-card[data-color="amber"] { --cat: var(--category-amber); }
.score-card[data-color="orange"] { --cat: var(--category-orange); }
.score-card[data-color="red"] { --cat: var(--category-red); }

.score-card h2 { margin: 0 0 13px; font-size: 14px; line-height: 20px; font-weight: 800; color: var(--text-strong); }

.scale-line { position: relative; width: min(345px, 100%); height: 17px; margin: 0 auto 22px; }

.scale-line::before {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 5px;
  right: 5px;
  height: 12px;
  border-radius: 8px;
  background: var(--cat);
}

.scale-line span {
  position: absolute;
  top: 0;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 3.5px solid var(--cat);
  background: var(--surface);
  z-index: 1;
}

.scale-line span:first-child { left: 0; }
.scale-line span:last-child { right: 0; }

.score { height: 92px; color: var(--cat); font-size: 102px; font-weight: 800; line-height: .9; }
.score.long { font-size: 84px; }

.score-card p { margin: 8px 0 16px; color: var(--cat); font-size: 19px; line-height: 23px; font-weight: 500; }

.modifier {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-blue);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  cursor: pointer;
}

.modifier span {
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border: 1.8px solid currentColor;
  border-radius: 50%;
  font-size: 13px;
  line-height: 11px;
}

.modifier.selected { color: var(--link-blue); }

.form-panel {
  width: 100%;
  min-height: 64px;
  margin: 0 auto 16px;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--row-shadow);
}

.select-row,
.switch-row {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 18px;
}

.select-row span,
.switch-row span { flex: 1; }

i {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-left: 3px;
  color: var(--accent-blue);
  vertical-align: -2px;
}

i svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.7px; }

select {
  appearance: none;
  border: 0;
  padding: 4px 16px 4px 8px;
  max-width: 170px;
  color: var(--accent-blue);
  background: transparent;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 8px) calc(50% - 2px), calc(100% - 4px) calc(50% - 2px);
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  font-size: 14px;
  font-weight: 500;
  text-align: right;
  cursor: pointer;
}

select option { color: #000; }

.two-switches { min-height: 80px; gap: 2px; }

.switch-row { position: relative; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }

.switch-row b {
  width: 50px;
  height: 24px;
  border-radius: 14px;
  background: var(--toggle-off);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 4%);
  transition: background .16s ease;
}

.switch-row b::before {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
  transition: transform .16s ease;
}

.switch-row input:checked + b { background: var(--accent-blue); }
.switch-row input:checked + b::before { transform: translateX(26px); }

.inflammatory { min-height: 72px; }
.inflammatory .switch-row span { max-width: 300px; }

/* ------------------------------ responsive ----------------------------- */
@media (max-width: 460px) {
  .window {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
}
