/* ===== Scar Tracker — Apple-style design system =====
   Light #f5f5f7 canvas, white surfaces, no borders, one accent (#0071e3),
   SF Pro via system-ui, tight negative tracking, pill CTAs, glass nav. */

:root {
  --bg: #f5f5f7;
  --bg-2: #ebebef;
  --card: #ffffff;
  --bd: rgba(0,0,0,.06);
  --bd-2: rgba(0,0,0,.04);
  --fg: #1d1d1f;
  --fg-2: rgba(0,0,0,.8);
  --mut: #6e6e73;
  --acc: #0071e3;
  --acc-link: #0066cc;
  --acc-dim: rgba(0,113,227,.10);
  --warn: #b25000;
  --warn-dim: rgba(255,159,10,.14);
  --bad: #d70015;
  --bad-dim: rgba(255,59,48,.12);
  --ok: #248a3d;
  --ok-dim: rgba(52,199,89,.14);
  --purple: #8944ab;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;

  --max-w: 980px;
  --nav-h: 48px;
  --radius: 18px;
  --radius-sm: 12px;
  --pill: 980px;
  --shadow: 0 2px 12px rgba(0,0,0,.04), 0 12px 40px rgba(0,0,0,.05);
  --shadow-lift: 3px 5px 30px rgba(0,0,0,.10);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; min-width: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font: 17px/1.47 -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: -.374px;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acc-link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.card, .hero, .metric, .protocol-card, .tl-card, .md { overflow-wrap: anywhere; }
canvas.chart { max-width: 100%; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md table { display: block; overflow-x: auto; }
.md pre { overflow-x: auto; }

/* ===== Navigation (glass) ===== */
.top {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s5);
  height: var(--nav-h);
  position: sticky;
  top: 0;
  background: rgba(245,245,247,.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.08);
  z-index: 100;
}
.brand {
  font-weight: 600;
  color: var(--fg);
  font-size: 17px;
  letter-spacing: -.374px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand-icon { display: none; }
.brand, .nav-desktop a, .foot a { min-height: 44px; display: inline-flex; align-items: center; padding: 0 var(--s2); }
.day-pill {
  background: var(--fg);
  color: #fff;
  font-weight: 600;
  padding: 3px var(--s3);
  border-radius: var(--pill);
  font-size: 12px;
  letter-spacing: -.12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  line-height: 0;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}
.nav-desktop { margin-left: auto; display: flex; gap: 2px; align-items: center; }
.nav-desktop a {
  color: var(--fg-2);
  font-size: 12px;
  letter-spacing: -.12px;
  padding: 6px var(--s3);
  border-radius: var(--pill);
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.nav-desktop a:hover, .nav-desktop a.active { color: var(--fg); text-decoration: none; background: rgba(0,0,0,.05); }

/* ===== Layout ===== */
main { max-width: var(--max-w); margin: 0 auto; padding: var(--s8) var(--s5) var(--s10); }
.foot {
  color: var(--mut);
  font-size: 12px;
  letter-spacing: -.12px;
  text-align: center;
  padding: var(--s8) var(--s5);
  border-top: 1px solid rgba(0,0,0,.08);
  margin-top: var(--s10);
}
.foot a { color: var(--mut); }

/* ===== Typography ===== */
h1 {
  font-size: 40px;
  font-weight: 600;
  margin: 0 0 var(--s3);
  line-height: 1.1;
  letter-spacing: -.28px;
}
h2 {
  font-size: 21px;
  font-weight: 600;
  margin: var(--s10) 0 var(--s4);
  color: var(--fg);
  text-transform: none;
  letter-spacing: .231px;
  line-height: 1.19;
}
h3 { font-size: 17px; font-weight: 600; margin: var(--s4) 0 var(--s2); letter-spacing: -.374px; }
.sub { color: var(--mut); margin: 0 0 var(--s4); font-size: 17px; }
.legend { font-size: 14px; color: var(--mut); line-height: 1.43; letter-spacing: -.224px; }
.note {
  background: var(--warn-dim);
  border: 0;
  border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4);
  font-size: 14px;
  letter-spacing: -.224px;
  color: var(--warn);
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
  padding: var(--s6);
  margin-bottom: var(--s4);
  box-shadow: var(--shadow);
}

/* ===== Grid ===== */
.grid { display: grid; gap: var(--s3); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ===== Hero ===== */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s6);
  align-items: start;
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
  padding: var(--s8);
  margin-bottom: var(--s4);
  box-shadow: var(--shadow);
}
.hero-left { min-width: 0; }
.hero-meta { color: var(--mut); font-size: 14px; letter-spacing: -.224px; margin-bottom: var(--s3); }
.verdict-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -.12px;
  text-transform: none;
  padding: 4px var(--s3);
  border-radius: var(--pill);
  margin-bottom: var(--s3);
  border: 0;
}
.hero-title { font-size: 40px; font-weight: 600; margin: 0 0 var(--s2); line-height: 1.1; letter-spacing: -.28px; }
.hero-title .hero-sub { font-size: 17px; font-weight: 400; letter-spacing: -.374px; }
.hero-sub { color: var(--mut); font-size: 17px; margin: 0 0 var(--s3); }
.hero-phase {
  font-size: 14px;
  letter-spacing: -.224px;
  color: var(--fg-2);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s3);
}
.hero-thumb { flex-shrink: 0; display: block; }
.hero-thumb img {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 0;
  box-shadow: var(--shadow-lift);
}
.hero-flags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.hero-flags li {
  font-size: 14px;
  letter-spacing: -.224px;
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  line-height: 1.43;
}
.hero-flags li::before { content: ''; flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; margin-top: 7px; background: currentColor; }
.hero-flags li { color: var(--fg); }
.f-red::before { background: var(--bad); }
.f-amber::before { background: #ff9f0a; }
.f-green::before { background: #34c759; }

.verdict-on-track .verdict-badge  { background: var(--ok-dim); color: var(--ok); }
.verdict-attention .verdict-badge  { background: var(--warn-dim); color: var(--warn); }
.verdict-see-a-doctor .verdict-badge { background: var(--bad-dim); color: var(--bad); }
.verdict { font-weight: 600; font-size: 21px; letter-spacing: .231px; }
.verdict-on-track .verdict    { color: var(--ok); }
.verdict-attention .verdict   { color: var(--warn); }
.verdict-see-a-doctor .verdict { color: var(--bad); }
.flags, .acts { margin: var(--s2) 0 0; padding-left: var(--s5); }
.flags li { margin: 4px 0; }
.acts li { color: var(--fg); margin: 4px 0; font-size: 15px; }

/* ===== Metric Grid ===== */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
.metric {
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
  padding: var(--s5);
  box-shadow: var(--shadow);
}
.metric .v { font-size: 32px; font-weight: 600; line-height: 1.07; letter-spacing: -.28px; margin-bottom: 4px; }
.metric .v .unit { font-size: 14px; font-weight: 400; color: var(--mut); letter-spacing: -.224px; }
.metric .l { color: var(--mut); font-size: 12px; text-transform: none; letter-spacing: -.12px; margin-bottom: var(--s2); }
.metric .sub-v { font-size: 12px; letter-spacing: -.12px; margin-top: 4px; color: var(--mut); }
.trend { font-weight: 600; font-size: 13px; }
.trend-improving { color: var(--ok); }
.trend-worsening { color: var(--bad); }
.trend-plateau { color: var(--warn); }
.trend-insufficient-data { color: var(--mut); }

/* ===== Protocol Card ===== */
.protocol-card {
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
  padding: var(--s6);
  margin-bottom: var(--s4);
  box-shadow: var(--shadow);
}
.protocol-actions { list-style: none; margin: 0 0 var(--s4); padding: 0; display: flex; flex-direction: column; }
.protocol-actions li {
  font-size: 15px;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--bd);
  color: var(--fg-2);
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  line-height: 1.47;
}
.protocol-actions li::before { content: ''; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--acc); margin-top: 9px; }
.protocol-actions li:last-child { border-bottom: 0; }

.care-toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--s2); margin: var(--s3) 0; }
.care-toggle { position: relative; }
.care-toggle input[type=checkbox] { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.care-toggle label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--s3) var(--s2);
  border: 0;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  font-size: 14px;
  letter-spacing: -.224px;
  color: var(--fg-2);
  transition: background .15s, color .15s, transform .1s;
  min-height: 72px;
  user-select: none;
  margin: 0;
}
.care-toggle label .icon { font-size: 22px; line-height: 1; }
.care-toggle input:checked + label { background: var(--acc); color: #fff; font-weight: 600; }
.care-toggle label:active { transform: scale(.97); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  background: var(--acc);
  color: #fff;
  border: 0;
  border-radius: var(--pill);
  padding: var(--s2) var(--s5);
  font-weight: 400;
  cursor: pointer;
  font-size: 17px;
  letter-spacing: -.374px;
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
  transition: background .15s, transform .1s;
  font-family: inherit;
  line-height: 1;
}
.btn:hover { background: #0077ed; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.sec { background: transparent; color: var(--acc-link); box-shadow: inset 0 0 0 1px var(--acc-link); }
.btn.sec:hover { background: var(--acc-dim); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sm { padding: 5px var(--s4); min-height: 44px; font-size: 14px; letter-spacing: -.224px; }
.row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }

/* ===== Form Elements ===== */
input[type=text],
input[type=number],
input[type=date],
input[type=password],
textarea,
select {
  width: 100%;
  background: var(--card);
  border: 1px solid rgba(0,0,0,.14);
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4);
  font: inherit;
  letter-spacing: -.374px;
  min-height: 44px;
  font-size: 17px; /* iOS: no zoom on focus */
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236e6e73' stroke-width='1.6'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px rgba(0,113,227,.25); }
textarea { min-height: 96px; resize: vertical; }
label { display: flex; align-items: center; min-height: 44px; font-size: 14px; letter-spacing: -.224px; color: var(--mut); margin: var(--s3) 0 var(--s1); }

/* ===== Symptom Sliders ===== */
.symptom-group { margin-bottom: var(--s3); }
.symptom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--bd);
  flex-wrap: wrap;
}
.symptom-row:last-child { border-bottom: 0; }
.symptom-label { font-size: 17px; flex: 1; min-width: 130px; }
.symptom-label small { display: block; font-size: 14px; letter-spacing: -.224px; color: var(--mut); }
.symptom-ctrl { display: flex; align-items: center; gap: var(--s3); }
.symptom-val { font-size: 21px; font-weight: 600; min-width: 28px; text-align: right; }
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 150px;
  height: 44px;
  background: transparent;
  cursor: pointer;
  padding: 0;
  border: none;
}
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(0,0,0,.14); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(0,0,0,.14); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px; margin-top: -12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: 0;
  box-shadow: 0 0 0 .5px rgba(0,0,0,.04), 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06);
}
input[type=range]::-moz-range-thumb {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: 0;
  box-shadow: 0 3px 8px rgba(0,0,0,.15);
}

/* ===== Scale Items ===== */
.scale-item { display: grid; grid-template-columns: 1fr 88px; gap: var(--s2); align-items: center; padding: var(--s2) 0; border-bottom: 1px solid var(--bd); }
.scale-item:last-child { border-bottom: 0; }
.scale-item input[type=number], .scale-item select { min-height: 44px; }
.anch { font-size: 12px; letter-spacing: -.12px; color: var(--mut); margin-top: 2px; }
details.scale-section { border: 0; background: var(--card); border-radius: var(--radius-sm); margin-bottom: var(--s3); overflow: hidden; box-shadow: var(--shadow); }
details.scale-section summary {
  padding: var(--s4) var(--s5);
  cursor: pointer;
  font-weight: 600;
  font-size: 17px;
  background: var(--card);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
details.scale-section summary::-webkit-details-marker { display: none; }
details.scale-section summary::after { content: ''; width: 8px; height: 8px; border-right: 1.5px solid var(--mut); border-bottom: 1.5px solid var(--mut); transform: rotate(45deg); transition: transform .2s; margin-right: 4px; }
details.scale-section[open] summary::after { transform: rotate(-135deg); }
details.scale-section .scale-body { padding: 0 var(--s5) var(--s4); }

/* ===== Charts ===== */
.chart { width: 100%; height: 240px; display: block; }
.chart-container { position: relative; }

/* ===== Timeline ===== */
.timeline { display: flex; flex-direction: column; gap: var(--s3); }
.tl-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--s4);
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
  padding: var(--s4);
  transition: transform .15s, box-shadow .15s;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}
.tl-card:hover { text-decoration: none; box-shadow: var(--shadow-lift); }
.tl-left { display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.tl-thumb { width: 90px; height: 90px; object-fit: cover; border-radius: var(--radius-sm); border: 0; }
.tl-thumb-placeholder {
  width: 90px; height: 90px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--mut);
}
.tl-day { font-weight: 600; font-size: 17px; }
.tl-date { font-size: 12px; letter-spacing: -.12px; color: var(--mut); }
.tl-body { min-width: 0; }
.tl-header { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); flex-wrap: wrap; }
.tl-da { font-size: 15px; font-weight: 600; }
.tl-notes { font-size: 14px; letter-spacing: -.224px; color: var(--fg-2); margin-top: var(--s2); }

/* ===== Thumbs ===== */
.thumbs { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s2); }
.thumbs a { display: block; min-width: 44px; min-height: 44px; }
.thumbs img { height: 80px; border-radius: var(--radius-sm); border: 0; object-fit: cover; }

/* ===== Tags ===== */
.tags { display: flex; gap: var(--s1); flex-wrap: wrap; }
.tag {
  font-size: 12px;
  letter-spacing: -.12px;
  background: var(--bg);
  border: 0;
  border-radius: var(--pill);
  padding: 3px var(--s3);
  color: var(--mut);
  white-space: nowrap;
}
.tag.on { color: var(--ok); background: var(--ok-dim); }
.tag.warn { color: var(--warn); background: var(--warn-dim); }
.tag.bad { color: var(--bad); background: var(--bad-dim); }

/* ===== Compare ===== */
.compare-controls { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin-bottom: var(--s4); }
.cmp-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.cmp-side { min-width: 0; position: relative; }
.cmp-tag { position: absolute; top: calc(44px + var(--s2) + var(--s3)); left: var(--s3); z-index: 1; background: rgba(29,29,31,.72); color: #fff; font-size: 12px; font-weight: 600; letter-spacing: -.12px; padding: 4px 10px; border-radius: var(--pill); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.cmp-side img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius-sm); border: 0; background: #000; margin-top: var(--s2); }
.cmp-side .legend { margin-top: var(--s1); }
.cmp-sel { width: 100%; }
.cmp-overlay-lbl { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; color: var(--mut); font-size: 14px; }
.cmp-overlay-lbl input { width: 24px; height: 44px; }
.cmp-overlay { margin: var(--s3) 0; }
.cmp-overlay-stage { position: relative; aspect-ratio: 3 / 4; max-height: 70vh; border-radius: var(--radius-sm); overflow: hidden; border: 0; background: #000; }
.cmp-overlay-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cf-slider { width: 100%; }
.cmp-select-hint { font-size: 12px; color: var(--mut); margin-bottom: var(--s3); }
.cmp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s3); }
.cmp { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: var(--s3); }
.cmp figure { margin: 0; background: var(--card); border: 0; border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow); }
.cmp img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.cmp figcaption { padding: var(--s2) var(--s3); font-size: 13px; }
.cmp-figure {
  margin: 0;
  background: var(--card);
  border: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition: outline-color .15s;
}
.cmp-figure img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.cmp-figure figcaption { padding: var(--s2) var(--s3); font-size: 12px; letter-spacing: -.12px; color: var(--mut); }
.cmp-pick { display: flex; gap: var(--s1); padding: 0 var(--s2) var(--s2); }
.cmp-pick .btn { flex: 1; }
.cmp-figure.sel-a .pick-a, .cmp-figure.sel-b .pick-b { background: var(--acc); color: #fff; box-shadow: none; }
.cmp-figure.sel-a { outline-color: var(--acc); }
.cmp-figure.sel-b { outline-color: var(--purple); }
.cmp-figure.sel-b .pick-b { background: var(--purple); }
.sel-indicator { display: none; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--pill); margin-top: 2px; }
.cmp-figure.sel-a .sel-indicator-a { display: inline-block; background: var(--acc-dim); color: var(--acc); }
.cmp-figure.sel-b .sel-indicator-b { display: inline-block; background: rgba(137,68,171,.12); color: var(--purple); }

/* ===== Guide / Knowledge ===== */
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s3); margin: var(--s6) 0 var(--s8); }
.guide-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border-radius: var(--radius); padding: var(--s5) var(--s6);
  box-shadow: var(--shadow); color: var(--fg); text-decoration: none;
  transition: transform .15s, box-shadow .15s; min-height: 150px;
}
.guide-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.guide-num { font-size: 12px; font-weight: 600; color: var(--acc); letter-spacing: -.12px; }
.guide-title { font-size: 21px; font-weight: 600; letter-spacing: .231px; line-height: 1.19; }
.guide-sum { font-size: 14px; color: var(--mut); letter-spacing: -.224px; line-height: 1.43; flex: 1; }
.guide-meta { font-size: 12px; color: var(--mut); letter-spacing: -.12px; margin: 0 0 var(--s6); }
.guide-library summary { font-size: 17px; }
.guide-article { max-width: 680px; margin: 0 auto; }
.guide-crumb { font-size: 14px; margin: 0 0 var(--s3); }
.guide-crumb a { color: var(--acc-link); }
.guide-disclaimer { margin-top: var(--s8); padding-top: var(--s4); border-top: 1px solid var(--bd); }
.guide-nav { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s6); }
.guide-nav-link { display: flex; flex-direction: column; gap: 2px; background: var(--card); border-radius: var(--radius-sm); padding: var(--s4) var(--s5); box-shadow: var(--shadow); color: var(--fg); font-weight: 600; min-height: 64px; }
.guide-nav-link:hover { text-decoration: none; box-shadow: var(--shadow-lift); }
.guide-nav-link.next { text-align: right; align-items: flex-end; }
.md { line-height: 1.6; font-size: 17px; }
.md > p:first-child { font-size: 19px; color: var(--fg-2); }
.md h1 { font-size: 32px; }
.md h2 { font-size: 24px; margin: var(--s8) 0 var(--s3); letter-spacing: -.28px; line-height: 1.2; }
.md h3 { font-size: 19px; margin: var(--s6) 0 var(--s2); }
.md p, .md ul, .md ol { margin: 0 0 var(--s4); }
.md li { margin: 4px 0; }
.md li p { margin: 0; }
.md hr { border: 0; border-top: 1px solid var(--bd); margin: var(--s6) 0; }
.md table { font-size: 15px; margin: var(--s4) 0; }
.md code { background: var(--bg-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.md blockquote { border-left: 3px solid var(--acc); margin: 0 0 var(--s4); padding: 4px 16px; color: var(--mut); }
.md strong { font-weight: 600; }
.md sup { font-size: .7em; }
.md h2:has(+ ol):last-of-type, .md h2#sources { font-size: 17px; color: var(--mut); margin-top: var(--s10); }
.md h2#sources + ol { font-size: 13px; color: var(--mut); line-height: 1.5; padding-left: 20px; }
.md h2#sources + ol a { word-break: break-all; }
.guide-h2 { margin-top: var(--s8); }
.guide-group { font-size: 12px; font-weight: 600; color: var(--mut); letter-spacing: -.12px; text-transform: uppercase; margin: var(--s6) 0 var(--s2); }
.klist { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 var(--s5); }
.klist a { display: flex; flex-direction: column; gap: 2px; justify-content: center; min-height: 56px; padding: var(--s3) 0; border-bottom: 1px solid var(--bd); color: var(--fg); }
.klist a:hover { text-decoration: none; }
.klist a:last-child { border-bottom: 0; }
.klist-title { font-size: 17px; font-weight: 600; letter-spacing: -.374px; }
.klist-sum { font-size: 14px; color: var(--mut); letter-spacing: -.224px; line-height: 1.4; }

/* ===== References ===== */
.refgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: var(--s3); }
.refgrid .card img { width: 100%; height: 170px; object-fit: cover; border-radius: var(--radius-sm); }
.refgrid .card p { font-size: 13px; color: var(--mut); margin: 8px 0 0; }

/* ===== Photo page ===== */
.canvas-wrap { position: relative; display: inline-block; max-width: 100%; }
.canvas-wrap canvas { max-width: 100%; cursor: crosshair; border-radius: var(--radius-sm); }

/* ===== Tables ===== */
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { border-bottom: 1px solid var(--bd); padding: 10px var(--s2); text-align: left; vertical-align: top; }
th { color: var(--mut); font-weight: 600; font-size: 12px; letter-spacing: -.12px; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  main { padding: var(--s5) var(--s4) var(--s8); }
  .top { padding: 0 var(--s4); gap: var(--s2); }
  .nav-toggle { display: flex; }
  .nav-desktop { display: none; }
  .nav-mobile {
    display: none;
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0; bottom: 0;
    background: var(--bg);
    flex-direction: column;
    align-items: stretch;
    padding: var(--s5) var(--s5);
    overflow-y: auto;
    z-index: 99;
  }
  .nav-mobile.open { display: flex; }
  body.nav-open { overflow: hidden; }
  .nav-mobile a {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -.28px;
    padding: var(--s3) 0;
    border-radius: 0;
    min-height: 52px;
    display: flex;
    align-items: center;
    border: 0;
    border-bottom: 1px solid rgba(0,0,0,.08);
    color: var(--fg);
  }

  .hero { grid-template-columns: 1fr auto; gap: var(--s3); padding: var(--s5); }
  .hero-thumb img { width: 72px; height: 72px; }
  .hero-title { font-size: 32px; }
  .hero-title .hero-sub { display: block; margin-top: 2px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
  .metric { padding: var(--s4); }
  .metric .v { font-size: 28px; }
  .chart { height: 200px; }
  .tl-card { grid-template-columns: 70px 1fr; gap: var(--s3); }
  .tl-thumb, .tl-thumb-placeholder { width: 60px; height: 60px; }
  .tl-day { font-size: 15px; }
  .tl-header .btn { margin-left: auto; }
  .symptom-ctrl { flex-direction: column; align-items: flex-end; gap: 2px; }
  input[type=range] { width: 140px; }
  .compare-controls { grid-template-columns: 1fr; }
  .cmp-pair { grid-template-columns: 1fr; gap: var(--s5); }
  .cmp-side img { aspect-ratio: 4 / 5; }
  .cmp-grid { grid-template-columns: repeat(2, 1fr); }
  .care-toggles { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 32px; }
  .card { padding: var(--s5); }
  .g2 { grid-template-columns: 1fr; }
  table { font-size: 14px; }
  th, td { padding: 8px var(--s1); }
  .guide-grid { grid-template-columns: 1fr; gap: var(--s2); }
  .guide-card { min-height: 0; padding: var(--s4) var(--s5); }
  .guide-nav { grid-template-columns: 1fr; }
  .guide-nav-link.next { text-align: left; align-items: flex-start; }
}
.nav-toggle .ic-close { display: none; }
.nav-toggle.open .ic-open { display: none; }
.nav-toggle.open .ic-close { display: block; }
.nav-mobile { display: none; }
@media (min-width: 641px) { .nav-toggle, .nav-mobile { display: none !important; } }
@media (min-width: 641px) and (max-width: 1024px) {
  main { padding: var(--s6) var(--s5) var(--s8); }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .hero-thumb img { width: 110px; height: 110px; }
  .g2 { grid-template-columns: 1fr 1fr; }
}

/* ===== Print ===== */
@media print {
  .top, .nav-toggle, .foot, .btn, .protocol-card, .care-form { display: none !important; }
  body { background: #fff !important; color: #000 !important; font-size: 11pt; }
  .card, .metric, .tl-card, .hero { background: #fff !important; border: 1px solid #ccc !important; color: #000 !important; box-shadow: none !important; }
  main { max-width: 100%; padding: 0; }
  a { color: inherit !important; }
  canvas.chart { max-height: 180px; }
  .hero-thumb img { width: 100px; height: 100px; }
  * { color: #000 !important; background: #fff !important; }
}

/* inline links inside cards/tables keep tap room */
table a, .table-wrap a { display: inline-block; padding: 12px 0; }
.md a { color: var(--acc-link); }
.card a:not(.btn), .note a, .legend a, .photo-note a { display: inline-block; padding: 12px 0; margin: -12px 0; }
.care-toggle label { min-height: 44px; }

/* photo area (entry page) */
.photo-area { position: relative; width: 100%; max-width: 420px; aspect-ratio: 3 / 4; background: var(--bg-2); border: 0; border-radius: var(--radius); overflow: hidden; margin-bottom: var(--s3); cursor: pointer; }
.photo-area img.ghost { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .4; pointer-events: none; }
.photo-area img.preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.photo-area .placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--mut); font-size: 15px; letter-spacing: -.224px; }
.photo-area .file-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: none; cursor: pointer; min-height: 0; }
.linklike:hover { text-decoration: underline; }
