/* =========================================================================
   EczemaClues — styles (v5, "Home logbook"). Mobile-first.
   ONE cohesive type voice for all text: Nunito (self-hosted variable font,
   same-origin — nothing phones home). Warm, rounded, legible at every size;
   hierarchy comes from weight + size, not from a second font. No serif, no
   mono, no handwritten text. All the handmade personality lives in the DRAWN
   marks: the record strip's crayon dabs and the hand-circled "today" — the
   parent's pen circling the day, which is exactly the "clue" circle in the
   logo.
   ========================================================================= */

/* Self-hosted so the privacy promise holds: no request ever leaves the origin. */
@font-face {
  font-family: "Nunito";
  font-style: normal; font-weight: 400 800;   /* variable — one file, all weights */
  font-display: swap;
  src: url("fonts/nunito-var.woff2") format("woff2");
}

:root {
  /* One family for everything; system stack is only the pre-load fallback. */
  --font-body: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  --font-display: var(--font-body);

  /* Neutrals — warm-cool off-white, deep green-charcoal text */
  /* Neutrals — warm cream & clay ("Apricot & Clay") */
  --bg: #fbf4ec;
  --surface: #fffdfb;
  --surface-2: #f4e9de;
  --surface-3: #ecdfd1;
  --text: #3a2c24;
  --text-soft: #7a6557;
  --border: #eeddce;
  --border-strong: #dcc8b6;

  /* Brand — apricot / terracotta with a warm tint + sage accent */
  --primary: #d9744a;
  --primary-dark: #a8501f;     /* darker terracotta for link/chip text */
  --primary-hi: #e89468;       /* gradient top for buttons */
  --primary-soft: #f9e6d8;
  --primary-softer: #fef4ec;
  --accent: #5e9b7e;           /* sage green — quiet complement */
  --danger: #bf3b2c;
  --warning: #b5791a;

  /* Layered, soft (warm-tinted) shadows */
  --shadow-sm: 0 1px 2px rgba(74,43,25,.06);
  --shadow: 0 1px 2px rgba(74,43,25,.06), 0 10px 24px -12px rgba(74,43,25,.18);
  --shadow-lg: 0 8px 24px -6px rgba(74,43,25,.16), 0 24px 60px -12px rgba(74,43,25,.30);
  --ring: 0 0 0 3px var(--primary-soft);

  /* Frosted chrome */
  --chrome: rgba(255,251,246,.72);

  /* Severity scale */
  --sev-0: #5fb597;
  --sev-mild: #9ccb5a;
  --sev-mod: #e6b04a;
  --sev-sev: #e07a4e;
  --sev-max: #c9483a;

  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 11px;
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Warm "clay night" dark mode */
    --bg: #17110c;
    --surface: #211a13;
    --surface-2: #2b211a;
    --surface-3: #362a20;
    --text: #f2e7dd;
    --text-soft: #b7a392;
    --border: #352a20;
    --border-strong: #46372a;

    --primary: #e68a5b;
    --primary-dark: #f0a176;    /* lighter apricot reads on dark tints */
    --primary-hi: #f09a6a;
    --primary-soft: #3a241a;
    --primary-softer: #29190f;
    --accent: #6fae8b;
    --danger: #e0574a;
    --warning: #d59a45;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 28px -14px rgba(0,0,0,.6);
    --shadow-lg: 0 10px 30px -6px rgba(0,0,0,.6), 0 30px 70px -16px rgba(0,0,0,.7);
    --ring: 0 0 0 3px rgba(230,138,91,.28);
    --chrome: rgba(24,18,13,.72);
  }
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over class rules that set a
   display value (.modal-host, .tabbar). */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-weight: 500;   /* Nunito reads a touch light at 400 for UI */
  background:
    radial-gradient(1100px 520px at 108% -8%, var(--primary-softer), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: 92px; /* room for tabbar on mobile */
}

/* Hierarchy is weight + size in one family — no second face. */
h1, h2, h3 { font-family: var(--font-display); line-height: 1.18; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; margin: 0 0 .5rem; font-weight: 800; }
h2 { font-size: 1.3rem; margin: 0 0 .75rem; font-weight: 800; }
h3 { font-size: 1.05rem; margin: 0 0 .4rem; font-weight: 700; }
p { margin: 0 0 .75rem; }

/* ---------- Quiet labels + hand-drawn dividers ---------------------------- */
.eyebrow {
  font-family: var(--font-body); font-size: .8rem; font-weight: 700;
  letter-spacing: 0; text-transform: none; color: var(--text-soft);
}
/* Section divider: a gently wavy pencil line, not a hairline rule. Mid-warm
   stroke reads on both paper and lamplight themes. */
.rule {
  display: flex; align-items: center; gap: 12px; margin: 26px 0 15px;
}
.rule::after {
  content: ""; flex: 1; height: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='6' viewBox='0 0 120 6'%3E%3Cpath d='M0 3 Q15 0 30 3 T60 3 T90 3 T120 3' fill='none' stroke='%23b89a7d' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x center / 120px 6px;
  opacity: .8;
}
.rule .eyebrow { flex: none; color: var(--text); }

.visually-hidden, .skip-link {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link:focus {
  position: fixed; top: 8px; left: 8px; width: auto; height: auto;
  background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 1000;
}

/* ---------- Header (frosted, sticky) ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--chrome);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.app-header__inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 11px 16px;
}
.brand { display: flex; align-items: center; gap: 9px; letter-spacing: -0.02em; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: block;
}
.brand__name { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em; }
.child-switcher { display: flex; align-items: center; gap: 6px; }
.child-switcher__select {
  font-size: .95rem; font-weight: 600; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  max-width: 42vw; box-shadow: var(--shadow-sm); cursor: pointer;
}

/* ---------- Main / views ---------- */
.app-main { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px; }
.view { animation: fade .22s cubic-bezier(.2,.7,.2,1); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

/* ---------- SIGNATURE: the record strip ----------------------------------
   The logo is a field of day-dots with one "clue" circled. Here that mark
   comes alive: each dot is a day. Hollow = not yet logged; filled + tinted =
   logged, colored by that day's severity. Today wears the clue-ring. The
   pattern the whole app hunts for literally forms in front of the parent. */
.record { margin: 2px 0 18px; }
.record__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 11px;
}
.record__title { display: flex; align-items: baseline; gap: 9px; }
.record__streak { font-family: var(--font-body); font-size: .84rem; font-weight: 600; letter-spacing: 0; color: var(--text-soft); }
.record__streak b { color: var(--primary-dark); font-weight: 800; }
/* The dots sit on a ruled calendar line, like marks on a wall calendar. */
.record__dots {
  display: grid; grid-template-columns: repeat(21, 1fr);
  gap: 6px 5px; max-width: 400px; margin: 0;
  padding-bottom: 9px; border-bottom: 1.5px solid var(--border-strong);
}
/* Crayon dabs, not data-viz dots: an organic (slightly wobbly) shape, waxy
   body. Hollow = an un-marked day in pencil outline. */
.rdot {
  width: 100%; aspect-ratio: 1; box-sizing: border-box;
  border-radius: 47% 53% 52% 48% / 53% 47% 52% 48%;
  border: 2px solid var(--border-strong); background: transparent;
  transition: transform .12s ease;
}
.rdot:nth-child(3n)   { border-radius: 53% 47% 48% 52% / 47% 53% 48% 52%; }
.rdot:nth-child(3n+1) { border-radius: 50% 50% 55% 45% / 55% 45% 50% 50%; }
.rdot.is-logged { border-color: transparent; box-shadow: inset 0 -2px 3px rgba(90,45,20,.16); }
/* Today: the parent's pen circling the day — a rough hand-drawn ring, which
   is exactly the "clue" circle in the logo. */
.rdot.is-today { position: relative; overflow: visible; }
.rdot.is-today::after {
  content: ""; position: absolute; inset: -6px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M22 4 C33 3 39 12 37 22 C35 33 24 39 14 36 C4 33 1 21 6 12 C10 5 17 3 25 5' fill='none' stroke='%23d9744a' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.rdot--pop { animation: dotpop .45s cubic-bezier(.2,.8,.2,1); }
@keyframes dotpop {
  0% { transform: scale(.3) rotate(-8deg); } 55% { transform: scale(1.24) rotate(3deg); } 100% { transform: scale(1) rotate(0); }
}

/* ---------- Entry card header (the specimen label) ----------------------- */
.entry-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 12px; margin-bottom: 6px; }
.entry-head__date { font-family: var(--font-display); font-weight: 800; font-size: 1.45rem; letter-spacing: -.01em; line-height: 1.12; margin: 3px 0 0; }
.entry-head__when { margin-bottom: 3px; }
.entry-head__control { flex: none; }
/* The date input shrinks to a quiet "change the day" control in the header. */
.entry-head__control input[type="date"] {
  width: auto; padding: 8px 10px; font-size: .85rem; background: var(--surface-2);
  color: var(--text-soft); border-radius: var(--radius-sm);
}
.entry-head__control input[type="date"]:focus { color: var(--text); }
@media (max-width: 420px) {
  .record__dots { gap: 4px; }
  .entry-head__date { font-size: 1.45rem; }
}

/* ---------- Welcome / hero ---------- */
.welcome { position: relative; overflow: hidden; }
.welcome::before {
  content: ""; position: absolute; inset: -40% -30% auto auto; width: 340px; height: 340px;
  background: radial-gradient(circle at 30% 30%, var(--primary-soft), transparent 70%);
  pointer-events: none;
}
.welcome h1 { font-size: 1.9rem; }
.welcome__lead { font-size: 1.06rem; color: var(--text-soft); max-width: 52ch; }
.welcome__points { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 8px; }
.welcome__points li {
  background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); font-weight: 500;
}
.welcome__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ---------- Buttons ---------- */
.btn {
  /* display + text-decoration matter for <a class="btn"> — inline anchors let
     vertical padding overlap surrounding text */
  display: inline-block; text-align: center; text-decoration: none;
  font: inherit; font-weight: 640; cursor: pointer; letter-spacing: -.01em;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 11px 17px; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.99); box-shadow: var(--shadow-sm); }

.btn--primary {
  background: linear-gradient(180deg, var(--primary-hi), var(--primary));
  border-color: var(--primary-dark); color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 6px 16px -6px var(--primary);
}
.btn--primary:hover { filter: brightness(1.03); box-shadow: 0 1px 0 rgba(255,255,255,.3) inset, 0 10px 22px -6px var(--primary); }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--primary-dark); }
.btn--ghost:hover { background: var(--primary-soft); box-shadow: none; }
.btn--lg { padding: 14px 22px; font-size: 1.03rem; border-radius: var(--radius); }
.btn--icon {
  width: 42px; height: 42px; padding: 0; font-size: 1.3rem; line-height: 1; border-radius: 12px;
  display: inline-grid; place-items: center;
}
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: transparent; box-shadow: none; }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn--block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.linkbtn {
  background: none; border: none; color: var(--primary-dark); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; padding: 0;
}

/* ---------- Tabbar (frosted bottom nav on mobile) ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; gap: 2px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--chrome);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar__btn {
  flex: 1; background: none; border: none; cursor: pointer; color: var(--text-soft);
  padding: 8px 4px; font-size: .72rem; font-weight: 640; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background .15s ease, color .15s ease;
}
.tabbar__icon { font-size: 1.25rem; transition: transform .15s ease; }
.tabbar__btn:hover { color: var(--text); }
.tabbar__btn.is-active { color: var(--primary-dark); background: var(--primary-soft); }
.tabbar__btn.is-active .tabbar__icon { transform: translateY(-1px) scale(1.06); }

/* ---------- Forms ---------- */
.field { margin-bottom: 22px; }
.field__label { display: block; font-weight: 640; margin-bottom: 9px; letter-spacing: -.01em; }
.field__hint { color: var(--text-soft); font-size: .85rem; font-weight: 450; }
/* Hints never take the handwritten face, even inside a penned label. */
.field__label .field__hint { font-family: var(--font-body); letter-spacing: 0; }

/* The one hero question (severity) is big and bold; every other question drops
   to a quiet, lighter label. That weight contrast is the page's hierarchy —
   one thing matters most, and it looks like it. */
.field__label--hero {
  font-family: var(--font-display); font-weight: 800; font-size: 1.3rem;
  letter-spacing: -.01em; margin-bottom: 13px;
}
.field__label--hero .field__hint { display: block; margin-top: 5px; font-size: .82rem; font-weight: 500; }
.field__label--mini {
  font-family: var(--font-body); font-weight: 700; font-size: 1rem;
  letter-spacing: 0; text-transform: none; color: var(--text);
  margin-bottom: 11px;
}
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="date"], input[type="password"], textarea, select {
  width: 100%; font: inherit; color: var(--text);
  padding: 12px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-soft); opacity: .8; }
textarea { resize: vertical; min-height: 68px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary); background: var(--surface); box-shadow: var(--ring);
}
.btn:focus-visible, .chip:focus-visible, .tabbar__btn:focus-visible, .linkbtn:focus-visible {
  outline: none; box-shadow: var(--ring);
}

/* Severity */
.sev { display: flex; flex-direction: column; gap: 14px; }
.sev__row { display: flex; align-items: center; gap: 14px; }
.sev__value {
  font-size: 1.5rem; font-weight: 800; min-width: 58px; height: 52px; text-align: center;
  border-radius: 14px; padding: 0 10px; color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 16px -8px rgba(0,0,0,.5), 0 1px 0 rgba(255,255,255,.25) inset;
}
.sev__label { font-weight: 680; font-size: 1.05rem; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 10px; border-radius: 99px;
  background: linear-gradient(90deg, var(--sev-0), var(--sev-mild), var(--sev-mod), var(--sev-sev), var(--sev-max));
  box-shadow: inset 0 1px 2px rgba(0,0,0,.15);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; background: #fff;
  border: 4px solid var(--primary); cursor: pointer; box-shadow: var(--shadow); margin-top: 0;
}
input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 4px solid var(--primary);
  cursor: pointer; box-shadow: var(--shadow);
}

/* Segmented quick-answer buttons (fast logging) */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg--3 { grid-template-columns: repeat(3, 1fr); }
.seg__btn {
  font: inherit; cursor: pointer; text-align: center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius); padding: 12px 6px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: border-color .12s, background .12s, transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.seg__btn { padding-top: 14px; padding-bottom: 14px; }
.seg__btn b { font-weight: 700; font-size: .97rem; letter-spacing: -.01em; }
.seg__btn small { color: var(--text-soft); font-size: .68rem; line-height: 1.25; }
.seg__dot { width: 15px; height: 15px; border-radius: 47% 53% 52% 48% / 53% 47% 52% 48%; margin-bottom: 4px; box-shadow: inset 0 -2px 3px rgba(90,45,20,.18); }
.seg__btn:active { transform: scale(.97); }
.seg__btn.is-on { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
@media (max-width: 420px) {
  .seg { grid-template-columns: repeat(2, 1fr); }
  .seg--3 { grid-template-columns: repeat(3, 1fr); }
}

/* Collapsed "More detail" section */
.more { margin-bottom: 22px; }
.more__toggle {
  font-family: var(--font-body); font-size: .95rem; font-weight: 700; letter-spacing: 0;
  text-transform: none; color: var(--primary-dark); background: none; border: none;
  cursor: pointer; padding: 11px 0; width: 100%; text-align: left;
}
.more__body { display: none; padding-top: 10px; border-top: 1px dashed var(--border-strong); }
.more__body.is-open { display: block; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  /* weight stays constant across states so toggling never reflows the layout */
  font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; user-select: none;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 999px; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, color .12s, transform .08s;
}
.chip:hover { border-color: var(--primary); transform: translateY(-1px); }
.chip:active { transform: translateY(0) scale(.97); }
.chip.is-on {
  background: var(--primary-soft); border-color: var(--primary);
  color: var(--primary-dark); box-shadow: inset 0 0 0 1px var(--primary);
}
.chip--add { border-style: dashed; color: var(--text-soft); box-shadow: none; }

.tag-input-row { display: flex; gap: 8px; margin-top: 11px; }
.tag-input-row input { flex: 1; }

.subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.subgrid label { font-weight: 600; font-size: .9rem; display: grid; gap: 6px; }
@media (max-width: 420px) { .subgrid { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- History ---------- */
.history-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.entry {
  display: flex; gap: 13px; align-items: stretch;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow-sm);
  cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit;
  transition: box-shadow .15s ease, transform .08s ease, border-color .15s ease;
}
.entry:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--border-strong); }
.entry__sev {
  flex: 0 0 48px; border-radius: 12px; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; box-shadow: 0 1px 0 rgba(255,255,255,.2) inset;
}
.entry__sev small { font-weight: 650; font-size: .58rem; opacity: .92; }
.entry__body { flex: 1; min-width: 0; }
.entry__date { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.entry__meta { color: var(--text-soft); font-size: .85rem; }
.entry__tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; }
.minitag { font-size: .72rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 2px 8px; color: var(--text-soft); }

.empty-note { color: var(--text-soft); text-align: center; padding: 30px 14px; }

/* Timeline */
.timeline { display: flex; align-items: flex-end; gap: 3px; height: 74px; padding: 10px 0; }
.timeline__bar { flex: 1; min-width: 3px; border-radius: 4px 4px 2px 2px; background: var(--sev-0); opacity: .9; transition: opacity .15s; }
.timeline__bar:hover { opacity: 1; }
.timeline__bar[data-empty="1"] { background: var(--border-strong); opacity: .5; height: 5px !important; }

/* ---------- Insights ---------- */
.insight {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
}
.insight--strong { border-left-color: var(--sev-sev); background: linear-gradient(180deg, color-mix(in srgb, var(--sev-sev) 5%, var(--surface)), var(--surface)); }
.insight__headline { font-weight: 720; font-size: 1.06rem; margin-bottom: 5px; letter-spacing: -.01em; }
.insight__detail { color: var(--text-soft); font-size: .93rem; }
.insight__stats { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 9px 13px; }
.stat__num { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat__lab { font-family: var(--font-body); font-size: .7rem; color: var(--text-soft); text-transform: none; letter-spacing: 0; font-weight: 600; margin-top: 2px; }
.confidence { display: inline-block; font-size: .72rem; font-weight: 720; padding: 3px 11px; border-radius: 999px; }
.confidence--low { background: var(--surface-3); color: var(--text-soft); }
.confidence--med { background: color-mix(in srgb, var(--warning) 16%, var(--surface)); color: var(--warning); }
.confidence--high { background: var(--primary-soft); color: var(--primary-dark); }

.progress-banner { background: linear-gradient(180deg, var(--primary-soft), var(--surface)); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 16px; }
.progress-bar { height: 9px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress-bar__fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-hi)); border-radius: 99px; transition: width .4s ease; }

/* ---------- Photos ---------- */
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.photo-grid:empty { display: none; }
.photo-thumb {
  width: 74px; height: 74px; object-fit: cover; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .15s ease;
}
.photo-thumb:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.viewer-img { max-width: 100%; max-height: 62vh; display: block; margin: 0 auto; border-radius: 12px; }
.report-photos { display: flex; flex-wrap: wrap; gap: 10px; }
.report-photos figure { margin: 0; width: 150px; }
.report-photos img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.report-photos figcaption { font-size: .72rem; color: var(--text-soft); text-align: center; margin-top: 3px; }
.synccode {
  display: block; word-break: break-all; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; font-size: .85rem; user-select: all;
}

/* ---------- Sign-in gate (hard-require sign-in) ---------- */
.gate {
  position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px; overflow: auto;
}
.gate__card { max-width: 420px; width: 100%; }
.gate__title { margin: 0 0 12px; font-size: 1.35rem; letter-spacing: -.02em; display: flex; align-items: center; gap: 9px; }
.gate__logo { width: 28px; height: 28px; border-radius: 8px; flex: none; }
.gate h2 { margin-top: 0; }

/* ---------- Modal ---------- */
.modal-host {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(10,20,16,.42); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 16px; animation: fade .16s ease;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; max-width: 440px; width: 100%; box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow: auto; animation: pop .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.modal h2 { margin-top: 0; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px;
  font-weight: 640; z-index: 200; box-shadow: var(--shadow-lg); max-width: 90vw;
  animation: pop .2s cubic-bezier(.2,.8,.2,1);
}

/* ---------- Footer ---------- */
.app-footer { max-width: var(--maxw); margin: 28px auto 0; padding: 16px; color: var(--text-soft); font-size: .85rem; text-align: center; }
.app-footer a { color: var(--primary-dark); }
.app-footer__disclaimer { font-size: .78rem; opacity: .85; }

/* ---------- Report (export) ---------- */
.report__head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.report-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.report-table th, .report-table td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; vertical-align: top; }
.report-table th { background: var(--surface-2); font-weight: 650; }
.report-section { margin-bottom: 22px; }

/* ---------- Desktop ---------- */
@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .app-main { padding: 24px 16px; }
  .tabbar {
    position: static; border-top: none; padding: 6px;
    max-width: var(--maxw); margin: 18px auto 0; border-radius: var(--radius-lg);
    box-shadow: var(--shadow); background: var(--surface); border: 1px solid var(--border);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .tabbar__btn { flex-direction: row; gap: 8px; font-size: .95rem; padding: 12px 14px; }
  .toast { bottom: 28px; }
}

/* Quality floor: honor reduced-motion everywhere (view fades, dot pop, etc.) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* =========================================================================
   PRINT — clean dermatologist report
   ========================================================================= */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #fff; --text: #000; --text-soft: #333; --border: #999; --border-strong: #999; --shadow: none; --shadow-sm: none; --shadow-lg: none; }
  body { padding: 0; background: #fff; }
  .app-header, .tabbar, .app-footer, .modal-host, .toast,
  .no-print, #view-log, #view-history, #view-insights { display: none !important; }
  .app-main { max-width: none; padding: 0; }
  #view-export { display: block !important; }
  .card { box-shadow: none; border: none; padding: 0; }
  .report-table { font-size: 10pt; }
  .report-table th, .report-table td { border: 1px solid #999; }
  .insight { break-inside: avoid; border: 1px solid #999; }
  .report-section { break-inside: avoid; }
  .report-photos figure { break-inside: avoid; }
  .report-photos img { border: 1px solid #999; }
  h1 { font-size: 18pt; }
  a { color: #000; text-decoration: none; }
}
