:root {
  --bg: #eef5fa;
  --card: #ffffff;
  --ink: #253449;
  --muted: #738197;
  --line: #d6e2ed;
  --soft-line: #e8eef5;
  --blue: #3678bd;
  --green: #3fa06c;
  --amber: #d0841b;
  --red: #c8404b;
  --violet-bg: #f0eefc;
  --violet-line: #d8d2f4;
  --shadow: 0 14px 40px rgb(37 52 73 / 0.07);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

button, input { font: inherit; }

/* ── Shell ─────────────────────────────────────────── */
.page-shell {
  width: min(100% - 40px, 1720px);
  margin: 0 auto;
  padding: 32px 0 40px;
}

/* ── Hero ──────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 26px;
}

.brand-mark {
  display: grid;
  width: 50px; height: 50px;
  place-items: center;
  border: 1px solid #cddfeb;
  border-radius: 13px;
  color: var(--blue);
  background: #eaf4fc;
  font-size: 22px;
  font-weight: 800;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(24px, 2.6vw, 38px);
  line-height: 1.1;
  font-weight: 850;
  letter-spacing: 0;
}

.hero-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 16px;
}

/* Language selector */
.language-picker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.language-picker select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  padding: 6px 34px 6px 12px;
  cursor: pointer;
  font-weight: 700;
  transition: border-color 0.2s, background 0.2s;
}

.language-picker select:hover { border-color: var(--blue); background: #f5f9fd; }
.language-picker select:focus-visible { outline: 3px solid rgb(54 120 189 / 0.18); border-color: var(--blue); }

/* ── Main grid ─────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: minmax(380px, 0.7fr) minmax(580px, 1.3fr);
  gap: 24px;
  margin-top: 26px;
}

/* ── Card ──────────────────────────────────────────── */
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.predictors { padding: 26px; }

/* ── Section title ─────────────────────────────────── */
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.section-title h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 820;
  letter-spacing: 0;
}
.section-title span {
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}

/* ── Controls ──────────────────────────────────────── */
.control-row {
  border-top: 1px solid var(--soft-line);
  padding: 18px 0 20px;
}
.control-label {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 800;
}
.control-label span { color: var(--muted); font-size: 15px; font-weight: 650; }
.control-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 14px;
  align-items: center;
}
input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--blue) 0%, var(--blue) 30%, #d9e2eb 30%, #d9e2eb 100%);
  outline: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  appearance: none;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
}
input[type="number"] {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  color: var(--ink);
  padding: 0 14px;
  font-size: 19px;
}
input[type="number"]:focus { outline: 3px solid rgb(54 120 189 / 0.18); border-color: var(--blue); }

/* ── Presets ───────────────────────────────────────── */
.preset-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 20px;
}
.preset-row button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
  font-size: 15px;
  transition: border-color 0.2s, background 0.2s;
}
.preset-row button:hover { border-color: var(--blue); background: #f5f9fd; }
.preset-row button:focus-visible { outline: 3px solid rgb(54 120 189 / 0.18); }

.note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════
   OUTPUT CARD — vertical stack
   ═══════════════════════════════════════════════════════ */
.output-card {
  display: flex;
  flex-direction: column;
  padding: 28px 30px 24px;
}

/* ── Risk hero ─────────────────────────────────────── */
.risk-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 20px;
  margin-bottom: 22px;
}
.risk-value {
  color: #203047;
  font-size: clamp(56px, 6vw, 88px);
  font-weight: 900;
  line-height: 0.92;
}
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 9px;
  padding: 0 14px;
  font-size: 17px;
  font-weight: 830;
}
.risk-badge span { width: 12px; height: 12px; border-radius: 50%; }
.risk-badge.low         { border: 1px solid rgb(63 160 108 / 0.48); background: rgb(63 160 108 / 0.1);  color: var(--green); }
.risk-badge.low span         { background: var(--green); }
.risk-badge.intermediate { border: 1px solid rgb(208 132 27 / 0.5);  background: rgb(208 132 27 / 0.12); color: var(--amber); }
.risk-badge.intermediate span { background: var(--amber); }
.risk-badge.high         { border: 1px solid rgb(200 64 75 / 0.5);  background: rgb(200 64 75 / 0.12); color: var(--red); }
.risk-badge.high span         { background: var(--red); }

.quintile-text {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

/* ── Risk scale ────────────────────────────────────── */
.risk-scale {
  margin-bottom: 24px;
}
.scale-track {
  position: relative;
  display: grid;
  grid-template-columns: 3.9571fr 2.3091fr 5.3899fr 10.354fr 77.9899fr;
  height: 22px;
  overflow: visible;
  border-radius: 999px;
  background: #e9eef4;
}
.scale-segment { min-width: 0; }
.scale-segment:first-child { border-radius: 999px 0 0 999px; }
.scale-segment:nth-child(5) { border-radius: 0 999px 999px 0; }
.scale-segment.low          { background: var(--green); }
.scale-segment.intermediate { background: var(--amber); }
.scale-segment.high         { background: var(--red); }

.scale-pointer {
  position: absolute;
  top: 28px;
  left: 20%;
  width: 0; height: 0;
  transform: translateX(-50%);
  border-right: 10px solid transparent;
  border-top: 16px solid var(--ink);
  border-left: 10px solid transparent;
  transition: left 0.3s ease;
}
.scale-labels {
  position: relative;
  height: 38px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.scale-labels span {
  position: absolute;
  top: 6px;
  transform: translateX(-50%);
}
.scale-labels span:nth-child(1) { left: 0;       transform: none; }
.scale-labels span:nth-child(2) { left: 3.96%;                   }
.scale-labels span:nth-child(3) { left: 6.27%;                   }
.scale-labels span:nth-child(4) { left: 11.66%;                  }
.scale-labels span:nth-child(5) { left: 22.01%;                  }
.scale-labels span:nth-child(6) { right: 0;      transform: none; }

/* ── Stats row ─────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.6fr;
  gap: 12px;
  margin-bottom: 22px;
}
.stat-item {
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  background: #fbfdff;
  padding: 14px 16px;
}
.stat-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 22px;
}
.stat-item span {
  color: var(--muted);
  font-size: 13px;
}
.stat-formula strong {
  font-size: 15px;
  margin-bottom: 4px;
}
.stat-formula span {
  font-size: 12px;
  line-height: 1.45;
}

/* ── Context strip ─────────────────────────────────── */
.context-strip {
  border-top: 1px solid var(--soft-line);
  padding-top: 18px;
}
.context-strip h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 820;
}
.context-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.ctx-item {
  border: 1px solid var(--soft-line);
  border-radius: 9px;
  background: #fbfdff;
  padding: 12px 14px;
}
.ctx-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  text-align: center;
  border-radius: 5px;
  padding: 3px 0;
}
.ctx-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.ctx-low  strong { background: rgb(63 160 108 / 0.12); color: var(--green); }
.ctx-mid  strong { background: rgb(208 132 27 / 0.12); color: var(--amber); }
.ctx-high strong { background: rgb(200 64 75 / 0.12); color: var(--red);  }

/* ── Disclaimer footer ─────────────────────────────── */
.disclaimer-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.disclaimer-col strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}
.disclaimer-warn strong { color: var(--red); }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1100px) {
  .main-grid,
  .output-card,
  .disclaimer-footer,
  .context-cols,
  .stat-row {
    grid-template-columns: 1fr;
  }
  .output-card { display: block; }
  .risk-hero { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 700px) {
  .page-shell { width: min(100% - 20px, 1720px); padding-top: 20px; }
  .hero { grid-template-columns: 44px minmax(0, 1fr); }
  .language-picker { grid-column: 1 / -1; justify-self: start; }
  .brand-mark { width: 42px; height: 42px; font-size: 18px; }
  .hero-copy p { font-size: 14px; }
  .section-title h2 { font-size: 20px; }
  .predictors { padding: 18px; }
  .output-card { padding: 20px 18px 18px; }
  .control-inputs,
  .preset-row { grid-template-columns: 1fr; }
}
