/* CLIMB case review: tokens follow the CLIMB project page (site/assets/style.css) */
:root {
  color-scheme: light;
  --paper: #fefff7;
  --paper-2: #e9f1fa;
  --surface: #fff;
  --ink: #102d5c;
  --ink-2: #315079;
  --muted: #557092;
  --hair: #c9d9eb;
  --accent: #0c43a0;
  --accent-soft: #dcecf9;
  --shadow: 0 10px 30px -22px rgba(12, 67, 160, .28);
  --r: 10px;
  --display: "Cormorant Garamond", Georgia, serif;
  --sans: "Manrope", -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 3vw, 36px);
  /* one hue per source record */
  --s0: #0c43a0; --s0-soft: #e3ecfa;
  --s1: #2f8fb8; --s1-soft: #e2f3fa;
  --s2: #b9741c; --s2-soft: #fbf0df;
  --s3: #a8455c; --s3-soft: #f9e6ea;
  --yes: #1f7a55; --no: #b23b3b; --unsure: #8a6d1d; --unusual: #5c7a1f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 500px at 85% -10%, var(--paper-2) 0%, transparent 60%),
    radial-gradient(900px 400px at -10% 110%, #f1f6ee 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.015em; font-weight: 600; }
p { margin: 0 0 .8em; }
b { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px var(--gutter);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid color-mix(in srgb, var(--hair) 70%, transparent);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 800 20px/1 var(--sans); letter-spacing: -.04em; }
.brand-sub { font: 500 italic 19px/1 var(--display); letter-spacing: 0; color: var(--muted); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.progress { display: flex; align-items: center; gap: 10px; font: 600 13px/1 var(--sans); color: var(--ink-2); }
.progress-bar { width: 120px; height: 6px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }

.btn {
  font: 700 14px/1 var(--sans); padding: 10px 16px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--accent); transition: transform .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn.solid { background: var(--accent); color: #fff; }
.btn.solid:hover { background: #0a3888; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--hair); }
.btn.ghost:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 0; max-width: 1480px; margin: 0 auto; }
.rail {
  position: sticky; top: 59px; align-self: start; height: calc(100vh - 59px); overflow-y: auto;
  padding: 24px 12px 24px var(--gutter); border-right: 1px solid var(--hair);
}
.rail h3 { font: 700 11px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.rail h3:first-child { margin-top: 0; }
.rail-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rail-item {
  position: relative; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--hair); background: var(--surface);
  font: 700 12px/1 var(--sans); color: var(--ink-2); cursor: pointer; display: grid; place-items: center;
}
.rail-item:hover { border-color: var(--accent); }
.rail-item.cur { background: var(--ink); color: #fff; border-color: var(--ink); }
.rail-item[data-a]::after { content: ""; position: absolute; right: 3px; top: 3px; width: 6px; height: 6px; border-radius: 50%; }
.rail-item[data-a="yes"]::after { background: var(--yes); }
.rail-item[data-a="no"]::after { background: var(--no); }
.rail-item[data-a="unsure"]::after { background: var(--unsure); }
.rail-item[data-a="realistic"]::after { background: var(--yes); }
.rail-item[data-a="unusual"]::after { background: var(--unusual); }
.rail-item[data-a="implausible"]::after { background: var(--no); }

.main { padding: 32px var(--gutter) 64px; min-width: 0; }

/* ---------- case header ---------- */
.eyebrow { display: flex; align-items: center; gap: 10px; font: 700 12px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.dot-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--hair); }
.case-head h1 { font-size: clamp(34px, 4.4vw, 52px); line-height: 1.05; margin: 12px 0 12px; }
.case-head h1 em { font-style: italic; color: var(--muted); font-weight: 500; }
.lede { max-width: 70ch; color: var(--ink-2); }

/* ---------- steps ---------- */
.step { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 16px; margin-top: 34px; animation: rise .45s ease both; }
.step:nth-of-type(3) { animation-delay: .06s; }
.step:nth-of-type(4) { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.step-num {
  width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--accent); color: var(--accent);
  display: grid; place-items: center; font: 600 20px/1 var(--display); background: var(--surface);
}
.step-body h2 { font-size: 28px; line-height: 1.15; margin-top: 2px; }
.step-note { color: var(--muted); font-size: 14.5px; margin: 6px 0 14px; max-width: 75ch; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px; border-radius: 99px;
  background: var(--soft); color: var(--ink); font: 700 14px/1.2 var(--sans); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.tag {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); color: #fff; font: 800 11px/1 var(--sans); flex: none;
}
.chip .chief { font: 600 11px/1 var(--sans); color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

/* source cards */
.sources { display: grid; gap: 14px; grid-template-columns: repeat(var(--k), minmax(240px, 1fr)); overflow-x: auto; padding-bottom: 6px; }
.card {
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow);
  border-top: 4px solid var(--c); min-width: 0; display: flex; flex-direction: column;
}
.card-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--hair); background: linear-gradient(var(--soft), transparent); border-radius: 6px 6px 0 0; }
.card-head .top { display: flex; align-items: center; gap: 8px; }
.card-head h3 { font-size: 21px; line-height: 1.15; }
.meta { font: 600 13px/1.4 var(--sans); color: var(--ink-2); margin-top: 6px; }
.meta span + span::before { content: "·"; margin: 0 6px; color: var(--hair); }
.cc { font-size: 13.5px; margin-top: 6px; color: var(--ink-2); }
.cc b { color: var(--ink); }
.facts { list-style: none; margin: 0; padding: 10px 16px 14px; font-size: 14px; line-height: 1.45; }
.facts li { padding: 5px 0; border-bottom: 1px dashed color-mix(in srgb, var(--hair) 70%, transparent); }
.facts li:last-child { border-bottom: 0; }
.group { font: 700 10.5px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 12px 16px 0; }
.orig { display: none; font-size: 12px; color: var(--muted); margin-top: 2px; }
body.show-orig .orig { display: block; }

/* merged patient */
.merge-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.stepper { display: inline-flex; padding: 4px; gap: 4px; background: var(--paper-2); border-radius: 99px; }
.stepper button {
  border: 0; background: transparent; cursor: pointer; border-radius: 99px; padding: 7px 14px;
  font: 700 13px/1 var(--sans); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
}
.stepper button .tag { width: 18px; height: 18px; font-size: 10px; }
.stepper button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 45, 92, .15); }
.toggle { font: 600 13px/1 var(--sans); color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.patient {
  background: var(--surface); border: 1px solid var(--hair); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden;
}
.patient-head { display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: baseline; padding: 18px 22px; border-bottom: 1px solid var(--hair); background: linear-gradient(90deg, var(--accent-soft), transparent 70%); }
.patient-head h3 { font-size: 26px; }
.patient-cols { display: grid; grid-template-columns: 1fr 1fr; }
.patient-cols > div + div { border-left: 1px solid var(--hair); }
.mfacts { list-style: none; margin: 0; padding: 6px 22px 16px; font-size: 14.5px; line-height: 1.45; }
.mfacts li { display: grid; grid-template-columns: 54px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px dashed color-mix(in srgb, var(--hair) 70%, transparent); transition: background .3s ease, opacity .3s ease; }
.mfacts li:last-child { border-bottom: 0; }
.mfacts li.new { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 12%, transparent), transparent 80%); margin: 0 -22px; padding-left: 22px; padding-right: 22px; }
.mfacts li.later { display: none; }
.dots { display: flex; gap: 3px; padding-top: 4px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.dots i.off { background: transparent; border: 1.5px solid var(--hair); }
.combined { display: inline-block; margin-left: 6px; font: 700 10.5px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--s2); background: var(--s2-soft); padding: 3px 6px; border-radius: 4px; vertical-align: 2px; cursor: help; }
.srcvals { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* verdict */
.verdict {
  margin: 44px 0 0 60px; padding: 24px 26px; border-radius: 14px; background: var(--ink); color: #fff;
  box-shadow: 0 24px 50px -30px rgba(16, 45, 92, .7);
}
.verdict h2 { font-size: 27px; line-height: 1.2; max-width: 46ch; color: #fff; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 14px; }
.choice {
  flex: 1 1 140px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 18px; border-radius: 10px; cursor: pointer; font: 700 17px/1 var(--sans);
  background: rgba(255, 255, 255, .06); color: #fff; border: 1px solid rgba(255, 255, 255, .22);
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.choice:hover { border-color: #fff; }
.choice kbd { font: 700 11px/1 var(--sans); padding: 4px 6px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, .35); opacity: .75; }
.choice[aria-checked="true"][data-v="yes"] { background: var(--yes); border-color: var(--yes); }
.choice[aria-checked="true"][data-v="no"] { background: var(--no); border-color: var(--no); }
.choice[aria-checked="true"][data-v="unsure"] { background: var(--unsure); border-color: var(--unsure); }
.choice[aria-checked="true"][data-v="realistic"] { background: var(--yes); border-color: var(--yes); }
.choice[aria-checked="true"][data-v="unusual"] { background: var(--unusual); border-color: var(--unusual); }
.choice[aria-checked="true"][data-v="implausible"] { background: var(--no); border-color: var(--no); }
.verdict textarea {
  width: 100%; resize: vertical; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .22); padding: 12px 14px;
  background: rgba(255, 255, 255, .06); color: #fff; font: 400 15px/1.5 var(--sans);
}
.verdict textarea::placeholder { color: rgba(255, 255, 255, .5); }
.verdict-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.verdict .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .3); }
.verdict .btn.ghost:hover { background: rgba(255, 255, 255, .08); border-color: #fff; }
.verdict .btn.solid { background: #fff; color: var(--ink); border-color: #fff; }
.saved { font-size: 13px; color: rgba(255, 255, 255, .6); }



/* background complaints and second question */
.bgblock { border-top: 1px solid var(--hair); background: repeating-linear-gradient(-45deg, transparent 0 8px, color-mix(in srgb, var(--paper-2) 55%, transparent) 8px 9px); }
.bgnote { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; margin-left: 6px; color: var(--muted); }
.bgfacts { list-style: none; margin: 0; padding: 8px 22px 14px; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14.5px; }
.bgfacts li { display: inline-flex; align-items: center; gap: 8px; }
.diamond { width: 9px; height: 9px; border: 1.5px solid var(--muted); transform: rotate(45deg); flex: none; }
.q2 { margin: 6px 0 14px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .15); }
.q2 h3 { font-size: 21px; line-height: 1.25; color: #fff; max-width: 52ch; }
.small-choices { margin: 12px 0 10px; }
/* the background question has no good or bad answer colour */
#bg-choices .choice[aria-checked="true"] { background: #fff; color: var(--ink); border-color: #fff; }
.small-choices .choice { padding: 10px 16px; font-size: 15px; }
.q2 input {
  width: 100%; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .22); padding: 10px 14px;
  background: rgba(255, 255, 255, .06); color: #fff; font: 400 15px/1.4 var(--sans);
}
.q2 input::placeholder { color: rgba(255, 255, 255, .5); }

/* AI judgment (inside the dark verdict card) */
.ai { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .15); }
.ai-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ai-hint { font-size: 13px; color: rgba(255, 255, 255, .55); }
.verdict .btn:disabled { opacity: .4; cursor: not-allowed; }
.ai-out { margin-top: 14px; padding: 14px 16px; border-radius: 10px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .15); }
.ai-verdict { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-badge { font: 800 13px/1 var(--sans); padding: 6px 10px; border-radius: 99px; color: #fff; }
.ai-badge[data-v="yes"] { background: var(--yes); }
.ai-badge[data-v="no"] { background: var(--no); }
.ai-badge[data-v="unsure"] { background: var(--unsure); }
.ai-model { font-size: 13px; color: rgba(255, 255, 255, .65); margin: 0 0 10px; }
.ai-q { font: 700 12px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .7); min-width: 92px; }
.ai details + details { margin-top: 8px; }
.ai-reason { margin: 10px 0 8px; font-size: 15px; line-height: 1.5; color: #fff; }
.ai details summary { cursor: pointer; font: 700 13px/1.4 var(--sans); color: rgba(255, 255, 255, .8); }
.ai pre {
  white-space: pre-wrap; word-break: break-word; margin: 10px 0 0; padding: 12px 14px; border-radius: 8px;
  background: rgba(0, 0, 0, .25); color: rgba(255, 255, 255, .88); font: 400 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 340px; overflow: auto;
}

/* intro dialog */
dialog { border: 0; padding: 0; border-radius: 16px; max-width: 600px; width: calc(100% - 32px); box-shadow: 0 30px 80px -30px rgba(16, 45, 92, .6); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(16, 45, 92, .35); backdrop-filter: blur(3px); }
.intro { padding: 30px 32px 28px; }
.intro h2 { font-size: 34px; line-height: 1.1; margin: 12px 0 14px; }
.field { display: grid; gap: 6px; font: 700 13px/1 var(--sans); color: var(--ink-2); margin: 18px 0 18px; }
.field input { font: 500 16px/1 var(--sans); padding: 12px 14px; border-radius: 10px; border: 1px solid var(--hair); background: var(--surface); color: var(--ink); }


/* merge checks panel */
.merge-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
.checks {
  position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--hair); border-radius: 14px; box-shadow: var(--shadow);
  padding: 16px 16px 6px; font-size: 13px; line-height: 1.45;
}
.checks-head h3 { font-size: 22px; }
.checks-head p { color: var(--muted); font-size: 12.5px; margin: 2px 0 10px; }
.check { border-top: 1px solid var(--hair); padding: 10px 0; }
.check h4 { margin: 0 0 6px; font: 700 13px/1.3 var(--sans); color: var(--ink); display: flex; gap: 8px; align-items: baseline; }
.check .ok { color: var(--yes); font-weight: 800; }
.check ul { list-style: none; margin: 0; padding: 0 0 0 21px; }
.check li { padding: 4px 0; border-bottom: 1px dashed color-mix(in srgb, var(--hair) 70%, transparent); }
.check li:last-child { border-bottom: 0; }
.check .lab { display: block; color: var(--ink-2); font-weight: 600; }
.check .vals { display: block; color: var(--muted); margin: 0 0 0 21px; }
.check li .vals { margin: 1px 0 0; }
.check .tag { width: 16px; height: 16px; font-size: 9px; vertical-align: 1px; margin-right: 1px; }
.check .none { color: var(--muted); font-style: italic; margin: 0 0 0 21px; }
@media (max-width: 1240px) {
  .merge-grid { grid-template-columns: minmax(0, 1fr); }
  .checks { position: static; max-height: none; order: -1; }
}

/* ---------- narrow screens ---------- */
@media (max-width: 1080px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--hair); padding: 14px var(--gutter); overflow-x: auto; }
  #rail { display: flex; gap: 18px; }
  .rail h3 { margin: 0 0 8px; }
  .rail-grid { grid-template-columns: repeat(20, 34px); }
  .patient-cols { grid-template-columns: minmax(0, 1fr); }
  .patient-cols > div + div { border-left: 0; border-top: 1px solid var(--hair); }
  .verdict { margin-left: 0; }
}
@media (max-width: 640px) {
  .nav { flex-wrap: wrap; }
  .nav-right { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  #btn-help { display: none; }
  .step { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .sources { grid-template-columns: repeat(var(--k), minmax(250px, 82%)); scroll-snap-type: x mandatory; }
  .card { scroll-snap-align: start; }
  .mfacts li { grid-template-columns: 44px 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
