/* Pain Tracker. See ../docs/DESIGN.md for the reasoning behind these tokens. */

@font-face {
  font-family: "Fredoka Variable";
  src: url(fonts/fredoka-latin-wght-normal.woff2) format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Nunito Variable";
  src: url(fonts/nunito-latin-wght-normal.woff2) format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --font-body: "Nunito Variable", Nunito, ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fredoka Variable", Fredoka, ui-rounded, "Nunito Variable", system-ui, sans-serif;

  /* the colour theme is one hue and one lightness; everything else is derived */
  --h: 222;
  --al: 46%;

  --bg: hsl(var(--h) 60% 96%);
  --surface: #ffffff;
  --ink: hsl(var(--h) 45% 14%);
  --muted: hsl(var(--h) 18% 37%);
  --line: hsl(var(--h) 30% 88%);
  --accent: hsl(var(--h) 72% var(--al));
  --accent-strong: hsl(var(--h) 72% calc(var(--al) - 10%));
  --accent-ink: #ffffff;
  --accent-soft: hsl(var(--h) 85% 94%);
  --sun: #ffc531;
  --sun-ink: #4a3200;
  --warn: #9a4a07;
  --warn-soft: #fdf0e1;
  --danger: #b3261e;
  --fx: #8a3fc4;
  --pain-l: 40%;
  --face-l: 58%;
  --face-ink: #1d2536;
  --face-idle: #c9d3e6;
  --ring: color-mix(in srgb, var(--ink) 7%, transparent);
  --shadow: 0 0 0 1px var(--ring), 0 2px 3px rgba(20, 30, 60, 0.04), 0 12px 28px -8px rgba(20, 30, 60, 0.12);
  --radius: 24px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}
:root[data-accent="sunset"] { --h: 14; --al: 46%; }
:root[data-accent="forest"] { --h: 158; --al: 30%; }
:root[data-accent="grape"] { --h: 265; --al: 50%; }

/* Dark follows the device, unless the viewer has explicitly chosen light or dark (data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: hsl(var(--h) 35% 9%);
    --surface: hsl(var(--h) 28% 14%);
    --ink: hsl(var(--h) 30% 94%);
    --muted: hsl(var(--h) 15% 69%);
    --line: hsl(var(--h) 22% 25%);
    --accent: hsl(var(--h) 80% 70%);
    --accent-strong: hsl(var(--h) 85% 80%);
    --accent-ink: hsl(var(--h) 50% 10%);
    --accent-soft: hsl(var(--h) 35% 22%);
    --warn: #f0b36b;
    --warn-soft: #3a2a14;
    --danger: #ff8a80;
    --fx: #c9a0f5;
    --pain-l: 62%;
    --face-l: 64%;
    --face-idle: #56637f;
    --ring: color-mix(in srgb, #fff 9%, transparent);
    --shadow: 0 0 0 1px var(--ring), 0 12px 28px -10px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: hsl(var(--h) 35% 9%);
  --surface: hsl(var(--h) 28% 14%);
  --ink: hsl(var(--h) 30% 94%);
  --muted: hsl(var(--h) 15% 69%);
  --line: hsl(var(--h) 22% 25%);
  --accent: hsl(var(--h) 80% 70%);
  --accent-strong: hsl(var(--h) 85% 80%);
  --accent-ink: hsl(var(--h) 50% 10%);
  --accent-soft: hsl(var(--h) 35% 22%);
  --warn: #f0b36b;
  --warn-soft: #3a2a14;
  --danger: #ff8a80;
  --fx: #c9a0f5;
  --pain-l: 62%;
  --face-l: 64%;
  --face-idle: #56637f;
  --ring: color-mix(in srgb, #fff 9%, transparent);
  --shadow: 0 0 0 1px var(--ring), 0 12px 28px -10px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(52rem 26rem at 105% -8%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 70%),
    radial-gradient(36rem 22rem at -12% 108%, color-mix(in srgb, var(--sun) 13%, transparent), transparent 70%);
  background-attachment: fixed;
  color: var(--ink);
  font: 17px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.noscroll { overflow: hidden; }
#app { max-width: 560px; margin: 0 auto; padding: 8px 16px calc(112px + env(safe-area-inset-bottom)); }
#screen:focus { outline: none; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; letter-spacing: 0.005em; }
p { text-wrap: pretty; }
h1 { font-size: 31px; line-height: 1.12; font-weight: 600; }
h2 { font-size: 20px; line-height: 1.25; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 18px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button svg, h2 svg, .ico svg, label svg { width: 20px; height: 20px; flex: none; }
.hide { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 0 8px; }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent-strong); margin-bottom: 4px; }
.saved { opacity: 0; transition: opacity 0.2s ease; margin-left: 4px; text-transform: none; letter-spacing: 0; font-weight: 700; color: var(--muted); }
.saved.on { opacity: 1; }
.sub { color: var(--muted); margin-top: 4px; font-size: 16px; font-weight: 600; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 800;
  background: var(--accent-soft); color: var(--accent-strong);
}
.pill.sun { background: color-mix(in srgb, var(--sun) 35%, var(--surface)); color: var(--sun-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.sun { color: #ffe9a6; } }
:root[data-theme="dark"] .pill.sun { color: #ffe9a6; }
.datenav { display: flex; gap: 6px; padding-top: 4px; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  background: var(--surface); border: 0; border-radius: 14px; color: var(--ink); font-size: 24px; line-height: 1; padding: 0;
  box-shadow: var(--shadow); transition: transform 0.15s var(--out);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn[disabled] { opacity: 0.35; cursor: default; }
.icon-btn input[type="date"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.link { background: none; border: 0; color: var(--accent-strong); font-weight: 700; padding: 10px 0; text-decoration: underline; text-underline-offset: 3px; }
.link.small { font-size: 15px; padding: 4px 0; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; margin: 14px 0; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card > h2 + .hint { margin-top: 6px; }
.hint { color: var(--muted); font-size: 15px; margin-top: 8px; }
.hint.center { text-align: center; }
.label { font-size: 14px; font-weight: 800; color: var(--muted); margin: 18px 0 8px; }
.label .muted { font-weight: 600; }
.empty-line { color: var(--muted); padding: 4px 0 12px; }
.fineprint { color: var(--muted); font-size: 14px; text-align: center; margin: 22px 8px 0; }
.note-card { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface) 80%); }
.note-card textarea { margin-top: 12px; }
.empty { text-align: center; display: grid; gap: 12px; justify-items: center; padding: 28px 20px; }
.empty p { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px;
  border-radius: 16px; border: 0; font-weight: 800; text-align: center; background: none;
  transition: transform 0.12s var(--out), box-shadow 0.12s var(--out), background-color 0.15s ease;
}
.btn:active { transform: translateY(2px) scale(0.985); }
.btn.wide { width: 100%; }
.btn.primary {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 3px 0 var(--accent-strong), 0 10px 18px -6px color-mix(in srgb, var(--accent) 55%, transparent);
}
.btn.primary:active { box-shadow: 0 1px 0 var(--accent-strong); }
.btn.secondary { background: var(--accent-soft); color: var(--accent-strong); }
.btn.ghost { box-shadow: inset 0 0 0 2px var(--line); background: var(--surface); }
.btn.danger { box-shadow: inset 0 0 0 2px var(--danger); color: var(--danger); background: transparent; }
.btn.danger-ghost { color: var(--danger); box-shadow: inset 0 0 0 2px var(--line); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn.big { min-height: 58px; font-size: 18px; font-family: var(--font-display); font-weight: 600; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn.icon-only { width: 50px; padding: 0; }
.btn.rec { background: var(--danger); color: #fff; animation: rec 1.1s ease-in-out infinite; }
.row { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.actions { display: flex; gap: 10px; margin: 16px 0 0; flex-wrap: wrap; }
.actions .btn { flex: 1 1 160px; }
.card .btn.wide { margin-top: 14px; }

/* ---------- inputs ---------- */
.field { display: grid; gap: 6px; margin-top: 14px; }
.field > span { font-size: 14px; font-weight: 800; color: var(--muted); }
input[type="text"], input[type="number"], input[type="time"], input[type="date"], select, textarea {
  width: 100%; min-height: 50px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.check { display: flex; gap: 12px; align-items: center; margin-top: 18px; min-height: 44px; font-weight: 600; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); }
.form-error { color: var(--danger); font-weight: 700; min-height: 1.4em; margin-top: 10px; }

/* ---------- chips + segmented ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 46px; padding: 0 16px; border-radius: 999px;
  border: 0; background: var(--surface); font-weight: 700; box-shadow: inset 0 0 0 2px var(--line);
  transition: transform 0.15s var(--out), background-color 0.15s ease, box-shadow 0.15s ease;
}
.chip:active { transform: scale(0.95); }
.chip svg { width: 16px; height: 16px; }
.chip .e { font-size: 20px; line-height: 1; }
.chip.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2.5px var(--accent); color: var(--accent-strong); }
.chip.on::after {
  content: "✓"; position: absolute; top: -6px; right: -4px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 900; line-height: 1;
}
.chip.add { background: var(--accent-soft); box-shadow: none; color: var(--accent-strong); }
.chip .amt { opacity: 0.8; font-weight: 600; }
.seg { display: inline-flex; padding: 4px; background: color-mix(in srgb, var(--ink) 7%, var(--surface)); border-radius: 18px; gap: 4px; }
.seg.wide { display: flex; margin: 12px 0; }
.seg button { flex: 1; min-height: 44px; padding: 0 14px; border: 0; background: none; border-radius: 14px; font-weight: 800; color: var(--muted); transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s var(--out); }
.seg button:active { transform: scale(0.96); }
.seg button.on { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 0 var(--accent-strong); }
.fx-rows { margin-top: 16px; display: grid; gap: 10px; }
.fx-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 10px; border-top: 2px dashed var(--line); }
.fx-name { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.fx-name .e { font-size: 22px; }
.fx-row .seg button { padding: 0 12px; }

/* ---------- pain ---------- */
.pain-card {
  --pc: var(--accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 15%, var(--surface)), var(--surface) 62%);
  transition: background-color 0.3s ease;
}
.pain-read { display: flex; align-items: center; gap: 16px; margin: 6px 0 4px; }
.pain-num { font-family: var(--font-display); font-size: 76px; line-height: 0.95; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 1.15ch; text-align: center; }
.pain-num.unset { color: color-mix(in srgb, var(--ink) 22%, var(--surface)); }
.pain-of { display: block; color: var(--muted); font-size: 14px; font-weight: 700; }
.pain-word { display: block; font-family: var(--font-display); font-size: 25px; font-weight: 600; line-height: 1.15; }
.pain-say { display: block; color: var(--muted); font-size: 15px; font-weight: 600; margin-top: 2px; }

/* The pain slider game. Drag handling lives in app.js (pointer events, so the face follows your finger smoothly).
   The <input type="range"> underneath stays for keyboards and screen readers. The invisible thumb and the face are both 56px. */
.pslider {
  position: relative; height: 104px; margin: 6px -4px 0; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab;
  --v: 0; --s: 1; --cy: 42px;
}
.pslider.down { cursor: grabbing; --s: 1.22; }
.pbar {
  position: absolute; left: 28px; right: 28px; top: var(--cy); height: 22px; transform: translateY(-50%); border-radius: 999px;
  background: linear-gradient(90deg, hsl(172 62% var(--pain-l)), hsl(110 62% var(--pain-l)), hsl(52 80% var(--pain-l)), hsl(28 80% var(--pain-l)), hsl(4 70% var(--pain-l)));
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.2), inset 0 -3px 5px rgba(255, 255, 255, 0.28), 0 0 0 4px var(--surface), 0 0 0 5px var(--ring);
}
/* the part of the meter beyond the face is dimmed, so it fills up like a health bar */
.pdim {
  position: absolute; top: var(--cy); right: 28px; height: 22px; transform: translateY(-50%); border-radius: 0 999px 999px 0;
  width: calc((100% - 56px) * (10 - var(--v)) / 10);
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  transition: width 0.3s var(--spring);
}
.ptick {
  position: absolute; top: var(--cy); left: calc(28px + (100% - 56px) * var(--n) / 10); width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.7); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1); transition: transform 0.18s var(--spring), background-color 0.15s ease;
}
.ptick.lit { background: #fff; transform: scale(1.35); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 0 8px rgba(255, 255, 255, 0.9); }
.ptick.hop { animation: hop 0.3s var(--spring); }
.pnum {
  position: absolute; top: calc(var(--cy) + 34px); left: calc(28px + (100% - 56px) * var(--n) / 10); transform: translateX(-50%);
  font-size: 12px; font-weight: 800; color: color-mix(in srgb, var(--muted) 75%, transparent); font-variant-numeric: tabular-nums; line-height: 1;
  transition: color 0.15s ease, transform 0.2s var(--spring);
}
.pnum.lit { color: var(--ink); transform: translateX(-50%) scale(1.15); }
.pnum.hop { animation: hopnum 0.3s var(--spring); }
.pslider input[type="range"] {
  -webkit-appearance: none; appearance: none; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0;
  opacity: 0; pointer-events: none; background: transparent; border: 0; min-height: 0; box-shadow: none;
}
.pslider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 56px; height: 56px; }
.pslider input[type="range"]::-moz-range-thumb { width: 56px; height: 56px; border: 0; }
.pface {
  position: absolute; top: var(--cy); left: calc((100% - 56px) * var(--v) / 10); width: 56px; height: 56px; pointer-events: none;
  transform: translateY(-50%) scale(var(--s)) rotate(var(--rot, 0deg)) scale(var(--sx, 1), var(--sy, 1));
  transition: left 0.38s var(--spring), transform 0.22s var(--spring);
  filter: drop-shadow(0 5px 7px rgba(10, 20, 50, 0.28));
}
.pslider.down .pface { transition: left 0s, transform 0.16s var(--out); filter: drop-shadow(0 8px 10px rgba(10, 20, 50, 0.32)) drop-shadow(0 0 12px color-mix(in srgb, var(--pc) 70%, transparent)); }
.pslider.down .pdim { transition: none; }
.pface .face, .fbtn .face { display: block; width: 100%; height: 100%; stroke: none; }
.pslider.unset .pface { animation: nudge 2.4s ease-in-out infinite; }
.pslider:has(input:focus-visible) .pface { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 50%; }
.pain-num.tickpop { animation: tickpop 0.22s var(--spring); }
.spark {
  position: fixed; z-index: 70; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; pointer-events: none;
  animation: spark 0.6s var(--out) forwards;
}

.faces { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 6px; }
.fbtn {
  display: grid; justify-items: center; gap: 4px; padding: 6px 0 4px; min-height: 64px; background: none; border: 0; border-radius: 16px;
  font-size: 11px; font-weight: 800; color: var(--muted); transition: background-color 0.15s ease, transform 0.15s var(--out);
}
.fbtn .face { width: 32px; height: 32px; }
.fbtn:active { transform: scale(0.92); }
.fbtn.on { background: color-mix(in srgb, var(--pc) 18%, var(--surface)); color: var(--ink); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--pc) 60%, transparent); }

.where { display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: start; }
.body { width: 112px; height: auto; stroke: none; --c: var(--accent); }
.decor { fill: color-mix(in srgb, var(--ink) 8%, var(--surface)); pointer-events: none; }
.eye { fill: var(--ink); opacity: 0.6; pointer-events: none; }
.zone { fill: color-mix(in srgb, var(--ink) 13%, var(--surface)); cursor: pointer; transition: fill 0.15s ease; outline: none; }
.zone .eyez { stroke: color-mix(in srgb, var(--ink) 30%, transparent); stroke-width: 1.2; }
.zone:hover { fill: color-mix(in srgb, var(--c) 40%, var(--surface)); }
.zone:focus-visible { stroke: var(--accent); stroke-width: 3; }
.zone.on { fill: var(--c); animation: glow 1.8s ease-in-out infinite; }

/* ---------- doses ---------- */
.doses { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.dose {
  width: 100%; display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 14px; text-align: left;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border: 0; border-radius: 18px; box-shadow: inset 0 0 0 2px var(--line);
  transition: transform 0.12s var(--out);
}
.dose:active { transform: scale(0.985); }
.dose .time { flex: none; min-width: 72px; font-size: 14px; font-weight: 800; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.dose .dname { flex: 1; font-weight: 800; }
.brand { color: var(--muted); font-weight: 600; font-size: 0.92em; white-space: nowrap; }
.brand::before { content: "("; }
.brand::after { content: ")"; }
.amt { white-space: nowrap; }
.dose .amt, .dl .amt { color: var(--muted); font-weight: 600; margin-left: 4px; }
.dose svg { color: var(--muted); width: 18px; height: 18px; }
.dose.skipped .dname { opacity: 0.6; text-decoration: line-through; text-decoration-thickness: 1px; }
.tag { font-style: normal; font-size: 12px; font-weight: 800; margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); text-decoration: none; display: inline-block; }
.totals { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; padding: 10px 14px; background: var(--accent-soft); border-radius: 16px; font-size: 15px; }
.totals .k { font-weight: 800; color: var(--accent-strong); width: 100%; font-size: 13px; }
.totals i { color: var(--muted); font-style: normal; }
.chips.stack { display: grid; grid-template-columns: 1fr; gap: 8px; }
.med-chip { justify-content: flex-start; padding: 8px 16px; border-radius: 18px; text-align: left; }
.med-chip span { display: grid; line-height: 1.25; }
.med-chip small { color: var(--muted); font-weight: 600; font-size: 13px; }
.suggest { display: grid; margin-top: 6px; border-radius: 14px; overflow: hidden; box-shadow: inset 0 0 0 2px var(--line); }
.suggest:empty { display: none; }
.sug { display: flex; flex-direction: column; align-items: flex-start; min-height: 54px; padding: 8px 14px; background: var(--surface); border: 0; border-top: 2px solid var(--line); text-align: left; width: 100%; }
.sug:first-child { border-top: 0; }
.sug:hover, .sug:focus-visible { background: var(--accent-soft); }
.sug span { color: var(--muted); font-size: 14px; }
.label.tight { margin: 10px 0 8px; }
.chips.tight { margin-top: 0; }

/* ---------- review of sorted note ---------- */
.review { margin-top: 16px; padding: 14px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 2.5px var(--accent); animation: rise 0.3s var(--out) both; }
.review h3 { margin-bottom: 8px; }
.rv { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rv li { display: grid; grid-template-columns: 82px 1fr; gap: 8px; }
.rv .k { font-size: 13px; font-weight: 800; color: var(--muted); padding-top: 2px; }
.rv i { color: var(--muted); font-style: normal; }
.warn { display: block; font-style: normal; color: var(--warn); font-size: 14px; font-weight: 700; }

/* ---------- chart ---------- */
.chart-card { padding: 14px 8px 12px; }
.chart { display: block; width: 100%; height: auto; stroke: none; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.ch-title { font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; font-size: 10.5px !important; fill: var(--accent-strong) !important; }
.chart .ch-label { fill: var(--ink); font-size: 12.5px; font-weight: 700; }
.chart .ch-axis.b { fill: var(--ink); font-weight: 800; }
.chart .ch-val { font-size: 10px; font-weight: 800; fill: var(--ink); }
.ch-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.ch-area { fill: var(--accent); opacity: 0.12; stroke: none; }
.ch-line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { stroke: var(--surface); stroke-width: 2; }
.ch-med { fill: var(--accent); }
.chart .ch-medn { fill: var(--accent-ink); font-size: 9.5px; font-weight: 900; }
.ch-skip { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 2.5 2.5; }
.ch-fx { fill: var(--fx); }
.ch-fx.s1 { opacity: 0.32; }
.ch-fx.s2 { opacity: 0.62; }
.ch-fx.s3 { opacity: 1; }
.ch-band { fill: var(--accent-soft); stroke: none; }
.ch-hit { fill: transparent; cursor: pointer; }
.ch-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.insight ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 8px; }
.insight li::marker { color: var(--accent); }

/* ---------- day block ---------- */
.dayblock .db-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.pain-badge {
  font-size: 14px; font-weight: 800; padding: 4px 12px; border-radius: 999px; color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 40%, transparent); white-space: nowrap;
}
.line { display: grid; grid-template-columns: 92px 1fr; gap: 8px; margin-top: 8px; font-size: 16px; }
.line .k { color: var(--muted); font-size: 13px; font-weight: 800; padding-top: 2px; }
.dl { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dl li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.dl .dl-name { font-weight: 800; }
.dl .mult { font-weight: 800; color: var(--accent-strong); font-size: 14px; }
.dl .times { flex-basis: 100%; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.notes-text { white-space: pre-wrap; }
.dayblock .btn { margin-top: 14px; }

/* ---------- medicines ---------- */
.medlist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; }
.med { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 2px dashed var(--line); }
.med:first-child { border-top: 0; }
.med-main { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px 0; display: grid; }
.med-main strong { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.med-main span { color: var(--muted); font-size: 15px; }
.med.off .med-main { opacity: 0.6; }
.top + .btn.wide { margin-top: 6px; }

/* ---------- summary ---------- */
.print-head { padding: 4px 0 10px; }
.print-head h2 { font-size: 23px; }
.print-head p { margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 10px 0 6px; }
.stats div { background: var(--surface); box-shadow: var(--shadow); border-radius: 18px; padding: 12px 14px; display: grid; }
.stats b { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 13px; font-weight: 700; }
.daylist .card { margin: 10px 0; break-inside: avoid; box-shadow: var(--shadow); }
.printable > .line { margin-top: 12px; }

/* ---------- fun extras ---------- */
.done-card { text-align: center; }
.stickers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.sticker { display: grid; justify-items: center; gap: 6px; padding: 4px 0; background: none; border: 0; font-size: 12px; font-weight: 800; color: var(--muted); line-height: 1.2; min-height: 44px; }
.s-emoji {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; font-size: 28px; line-height: 1;
  background: color-mix(in srgb, var(--ink) 8%, var(--surface)); color: var(--muted); font-family: var(--font-display); font-weight: 600;
  transition: transform 0.2s var(--spring);
}
.sticker:active .s-emoji { transform: scale(0.9); }
.sticker.on { color: var(--ink); }
.sticker.on .s-emoji {
  background: radial-gradient(circle at 30% 25%, #fff6c9, var(--sun) 70%); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--sun), 0 6px 10px -2px rgba(0, 0, 0, 0.25);
  transform: rotate(-6deg);
}
.sticker.on:nth-child(even) .s-emoji { transform: rotate(5deg); }
.count { margin-left: auto; font-family: var(--font-body); font-size: 14px; font-weight: 800; color: var(--muted); }
.swatches { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.swatch { display: grid; justify-items: center; gap: 6px; background: none; border: 0; font-size: 13px; font-weight: 800; color: var(--muted); min-height: 44px; }
.swatch i { width: 44px; height: 44px; border-radius: 50%; background: var(--sw); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px transparent; transition: box-shadow 0.15s ease, transform 0.2s var(--spring); }
.swatch:active i { transform: scale(0.9); }
.swatch[aria-pressed="true"] { color: var(--ink); }
.swatch[aria-pressed="true"] i { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--sw); }
.switch { display: flex; align-items: center; gap: 12px; margin-top: 18px; min-height: 48px; font-weight: 700; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .tr { flex: none; width: 52px; height: 30px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 20%, var(--surface)); position: relative; transition: background-color 0.2s ease; }
.switch .tr::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); transition: transform 0.22s var(--spring); }
.switch input:checked + .tr { background: var(--accent); }
.switch input:checked + .tr::after { transform: translateX(22px); }
.switch input:focus-visible + .tr { outline: 3px solid var(--accent); outline-offset: 2px; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 -1px 0 var(--ring), 0 -10px 30px -12px rgba(20, 30, 60, 0.18);
  padding-bottom: env(safe-area-inset-bottom); border-radius: 22px 22px 0 0;
}
.tabs-in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 8px; }
.tabs button { background: none; border: 0; display: grid; justify-items: center; gap: 2px; padding: 4px 0 2px; font-size: 12px; font-weight: 800; color: var(--muted); min-height: 58px; }
.tabs .ico { display: grid; place-items: center; width: 58px; height: 32px; border-radius: 999px; transition: background-color 0.18s ease, color 0.18s ease, transform 0.25s var(--spring); }
.tabs .ico svg { width: 24px; height: 24px; }
.tabs button:active .ico { transform: scale(0.9); }
.tabs button[aria-current="page"] { color: var(--accent-strong); }
.tabs button[aria-current="page"] .ico { background: var(--accent); color: var(--accent-ink); }

/* ---------- sheet + toast ---------- */
#sheet { display: none; position: fixed; inset: 0; z-index: 40; }
#sheet.on { display: block; }
.scrim { position: absolute; inset: 0; background: rgba(8, 14, 34, 0.5); animation: fade 0.18s ease-out; }
.sheet {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 28px 28px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); animation: sheetUp 0.26s var(--out);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { font-size: 23px; }
#toast {
  position: fixed; left: 0; right: 0; margin: 0 auto; width: fit-content; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateY(16px) scale(0.96); opacity: 0; pointer-events: none; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 18px; display: flex; gap: 16px; align-items: center; max-width: min(520px, calc(100% - 32px));
  transition: opacity 0.2s ease, transform 0.25s var(--spring); font-size: 16px; font-weight: 700; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
#toast.on { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
#toast button { background: none; border: 0; color: var(--accent); font-weight: 800; padding: 8px; filter: brightness(1.6); }

/* ---------- motion ---------- */
.enter > * { animation: rise 0.34s var(--out) both; }
.enter > :nth-child(2) { animation-delay: 45ms; }
.enter > :nth-child(3) { animation-delay: 90ms; }
.enter > :nth-child(4) { animation-delay: 135ms; }
.enter > :nth-child(5) { animation-delay: 180ms; }
.enter > :nth-child(6) { animation-delay: 225ms; }
.enter > :nth-child(7) { animation-delay: 270ms; }
.enter > :nth-child(n+8) { animation-delay: 300ms; }
.pop { animation: pop 0.3s var(--spring); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translate(-50%, 28px); opacity: 0; } }
@keyframes pop { from { transform: scale(0.86); } }
@keyframes hop { 50% { transform: scale(2.1); } }
@keyframes hopnum { 50% { transform: translateX(-50%) scale(1.6); } }
@keyframes tickpop { from { transform: scale(1.25); } }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; } }
@keyframes nudge { 0%, 55%, 100% { transform: translateY(-50%) translateX(0); } 15% { transform: translateY(-50%) translateX(14px) rotate(8deg); } 30% { transform: translateY(-50%) translateX(-3px) rotate(-5deg); } 42% { transform: translateY(-50%) translateX(6px); } }
@keyframes glow { 0%, 100% { opacity: 1; } 50% { opacity: 0.72; } }
@keyframes rec { 50% { opacity: 0.7; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) { h1 { font-size: 35px; } #app { padding-top: 24px; } }

/* ---------- print ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #ccc; --accent-soft: #eee; --pain-l: 30%; --shadow: 0 0 0 1px #ccc; color-scheme: light; }
  body { background: #fff; background-image: none; font-size: 12pt; }
  .tabs, .noprint, #toast, #sheet, #confetti { display: none !important; }
  #app { max-width: none; padding: 0; }
  .daylist .card { padding: 10px 12px; }
}

/* ---------- sharing + consent ---------- */
.more { margin-top: 16px; }
.more summary { cursor: pointer; font-weight: 800; color: var(--accent-strong); min-height: 44px; display: flex; align-items: center; }
.code-box { margin-top: 16px; padding: 14px; border-radius: 18px; background: var(--accent-soft); }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 19px; font-weight: 800; letter-spacing: 0.05em; user-select: all; -webkit-user-select: all; margin: 4px 0 8px; color: var(--ink); }
.consent { margin-top: 10px; font-size: 16px; }
.consent p { margin-top: 12px; }
.consent ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 6px; }
.code span { display: inline-block; }

/* ---------- switch between patient app and clinic page ---------- */
.view-switch { display: block; width: fit-content; margin: 10px max(16px, calc((100% - 560px) / 2 + 16px)) 0 auto; padding: 5px 12px; border-radius: 999px; font: 800 12px/1.2 var(--font-body); letter-spacing: 0.02em; color: var(--muted); background: color-mix(in srgb, var(--accent) 8%, transparent); text-decoration: none; transition: background-color 0.18s ease, color 0.18s ease; }
.view-switch:hover, .view-switch:focus-visible { color: var(--accent-strong); background: var(--accent-soft); }
@media print { .view-switch { display: none; } }

/* ---------- Claude's follow-up questions ---------- */
.ask { margin: 10px 0 14px; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); }
.ask h3 { font-size: 16px; margin-bottom: 2px; }
.ask .row { margin-top: 12px; }
.ai-note { font-size: 13px; margin-top: 8px; margin-bottom: 12px; }
.ai-note svg { width: 13px; height: 13px; vertical-align: -2px; }

/* ---------- Today: the important bits first, extras on a second page ---------- */
.pg-seg { margin: 4px 0 14px; }
.tpage.on-more > section:not(.pg-more) { display: none; }
.tpage:not(.on-more) .pg-more { display: none; }
.pg-next { margin-top: 4px; }

/* ---------- what the AI helper just added, beside the box ---------- */
.added { margin-top: 14px; padding: 12px 14px; border-radius: 16px; background: color-mix(in srgb, var(--accent) 9%, var(--surface)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 40%, transparent); animation: rise 0.3s var(--out) both; }
.added-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.added ul { list-style: none; margin: 8px 0 6px; padding: 0; display: grid; gap: 4px; }
.added li { padding-left: 22px; position: relative; font-weight: 700; }
.added li::before { content: "✓"; position: absolute; left: 0; color: var(--accent-strong); font-weight: 900; }
.added .hint { font-size: 13px; margin: 0; }

/* ---------- Summary: settings tucked away ---------- */
.settings { margin: 16px 0; }
.settings > summary { cursor: pointer; font: 600 18px var(--font-display); padding: 14px 18px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 52px; }
.settings > summary::-webkit-details-marker { display: none; }
.settings > summary::after { content: "+"; font-size: 24px; color: var(--accent-strong); }
.settings[open] > summary::after { content: "–"; }
.settings[open] > summary { margin-bottom: 14px; }

/* ---------- bigger screens: a roomier column and a floating tab bar ---------- */
@media (min-width: 900px) {
  #app { max-width: 680px; }
  .view-switch { margin-right: max(16px, calc((100% - 680px) / 2 + 16px)); }
  .tabs { left: 50%; right: auto; width: 520px; transform: translateX(-50%); bottom: 16px; border-radius: 26px; box-shadow: var(--shadow); }
  .tabs-in { max-width: none; }
  #app { padding-bottom: 140px; }
}

/* ---------- a question from the clinic ---------- */
.clinic-q { background: color-mix(in srgb, var(--sun) 16%, var(--surface)); }
.cq-text { font: 600 19px/1.35 var(--font-display); margin: 6px 0 12px; }
.clinic-q .chip { min-height: 46px; padding: 0 20px; font-weight: 800; }
.clinic-q .chips.scale .chip { min-width: 46px; padding: 0 12px; justify-content: center; }
.clinic-q .row { align-items: center; justify-content: space-between; margin-top: 10px; }
