/* ==========================================================================
   Be In Sync — app.css
   Foundation stylesheet. Kinga's brand: black text on everything.
   HARD RULE: magenta / orange / pink are NEVER a fill behind text —
   border / icon / accent / dot only. Text-bearing fills = cream or
   yellow-green (both pass WCAG 4.5:1 with black ink).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Hind+Guntur:wght@400;500;600;700&family=Gochi+Hand&display=swap');

/* ---------- DESIGN TOKENS ------------------------------------------------- */
:root {
  /* Surfaces (safe behind black text) */
  --bg: #f5f0ea;          /* cream — app background */
  --ink: #111111;         /* black — ALL text */
  --surface: #fffdf9;     /* off-white card surface */

  /* Accents — border / icon / dot ONLY, never behind a text label */
  --magenta: #e61182;     /* ACCENT/BORDER/ICON ONLY — fails contrast w/ black */
  --pink: #ff539d;        /* accent only */
  --yellowgreen: #dadd42; /* signature; OK behind black text; use sparingly */
  --cyan: #2ec1ff;
  --brown: #9e6749;
  --teal: #04bc98;
  --orange: #fe6622;      /* accent only */

  /* Emotion colours (per week; accent role only) */
  --emo-anger: #e61182;
  --emo-joy: #dadd42;
  --emo-sadness: #2ec1ff;
  --emo-fear: #9e6749;
  --emo-disgust: #04bc98;
  --emo-surprise: #fe6622;

  /* Ink tints */
  --ink-70: rgba(17, 17, 17, 0.70);
  --ink-45: rgba(17, 17, 17, 0.45);
  --hairline: rgba(17, 17, 17, 0.12);
  --table-border: #948a77;  /* warm neutral, ~3:1 on cream — softer than black, legible in daylight */
  /* Hand-drawn sketch-card frame stroke. Warm dark grey — softer than black
     but still clearly defines the card edge on cream (it's decorative/brand,
     not a content divider, so it can sit lighter than --table-border).
     CANONICAL SOURCE: a data-URI SVG can't read a CSS var, so the .sketch
     border-image below hardcodes this same value (URL-encoded %237a7469).
     Change here AND there together. */
  --sketch-stroke: #7a7469;

  /* Type scale (px): 13 / 15 / 17 / 22 / 28 / 34 */
  --t-13: 0.8125rem;
  --t-15: 0.9375rem;
  --t-17: 1.0625rem;
  --t-22: 1.375rem;
  --t-28: 1.75rem;
  --t-34: 2.125rem;

  --font-body: 'Hind Guntur', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-hand: 'Gochi Hand', var(--font-body);

  /* Layout */
  --app-max: 430px;
  --pad: 20px;
  /* Card corner rounding. Two tokens, because the SAME radius reads sharper on
     a big surface than a small one: large primary cards (the tall sketch
     cards, the Today card, the roadmap) need a slightly larger radius to look
     as rounded as a small lesson table. Change these two, not per-screen.
     Pills/dots stay fully round; the sketch frame keeps its hand-drawn stroke
     but shares --card-radius-lg (its SVG corner arc is sized to match). */
  --card-radius: 12px;      /* small/medium surfaces: tables, day cells, fields, rows */
  --card-radius-lg: 16px;   /* large primary cards: sketch cards, Today card, roadmap */
  --nav-h: 68px;

  --shadow-card: 0 2px 10px rgba(17, 17, 17, 0.06);
  --focus: 0 0 0 3px var(--bg), 0 0 0 6px var(--magenta);
}

/* ---------- RESET --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* `hidden` must win over ID-level display rules (e.g. #nav, #main). */
[hidden] { display: none !important; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--t-17);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; color: var(--ink); cursor: pointer; }

/* ---------- APP SHELL (mobile-first, centered, max 430px) ----------------- */
#app {
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---------- TYPOGRAPHY ---------------------------------------------------- */
h1, h2, h3 { font-weight: 700; line-height: 1.18; margin: 0 0 0.4em; color: var(--ink); }
h1 { font-size: var(--t-34); letter-spacing: -0.01em; }
h2 { font-size: var(--t-28); letter-spacing: -0.01em; }
h3 { font-size: var(--t-22); }
p { margin: 0 0 1em; }
.t-13 { font-size: var(--t-13); }
.t-15 { font-size: var(--t-15); }
.muted { color: var(--ink-70); }
.eyebrow {
  font-size: var(--t-13);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-70);
  margin: 0 0 0.4em;
}
/* Gochi Hand — handwritten accents ONLY (max 1–2 spots per screen) */
.hand {
  font-family: var(--font-hand);
  font-weight: 400;
  color: var(--ink);
  line-height: 1.15;
}

/* ---------- SIGNATURE SKETCH-BORDER --------------------------------------
   One reusable irregular hand-drawn border, like Kinga's Instagram tiles.
   PRIMARY cards only — do NOT put this on everything.
   Built from an SVG data-URI so the stroke wobble is real, not a box-shadow. */
.sketch {
  position: relative;
  background: var(--surface);
  border-radius: var(--card-radius-lg);
  padding: 20px;
  /* Irregular hand-drawn frame via border-image — hugs the real edges at ANY
     card height (a stretched square SVG would push the top/bottom strokes
     inward on tall cards and cross the content).
     KEY: border-image draws the VISIBLE corner from the SVG's own corner arc,
     NOT the CSS border-radius — and the corner slice renders at border-image-
     width, not border-width. So to make the drawn line trace the SAME 16px arc
     as the fill (--card-radius-lg) with no cream wedge between line and fill:
       - the SVG path is a rounded rect with a real 16px corner radius (in the
         90×90 viewBox), stroke sitting ~2px off the edge, plus wobble;
       - slice = 24 and border-image-width = 24px make the corner render 1:1,
         so the SVG's 16px arc lands at exactly 16px on screen.
     Change --card-radius-lg? Then also change the r=16 arcs in the path below.
     Stroke colour = --sketch-stroke (%237a7469); data-URI SVGs can't read a CSS
     var, so it's hardcoded here — keep it in sync with that token. */
  border: 4px solid var(--ink);
  border-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90' viewBox='0 0 90 90' fill='none' stroke='%237a7469' stroke-width='2' stroke-linejoin='round'><path d='M17 2.4 C 34 1.4 55 1.8 71 2.2 C 80.6 2.6 88.4 9 87.6 18.4 C 88.5 35 88.1 56 87.7 71 C 87.4 80.8 80.8 88.3 71 87.6 C 55 88.6 34 88.2 18 87.8 C 9 88.4 1.6 80.8 2.4 71 C 1.4 55 1.8 34 2.2 18 C 2.6 9 9 1.6 17 2.4 Z'/></svg>") 24 / 24px stretch;
}
/* Accent variant: colored irregular border via CSS var (border/icon role) */
.sketch--accent { --sketch-accent: var(--magenta); }

/* ---------- SCREENS / ROUTING -------------------------------------------- */
.screen { display: none; flex: 1 1 auto; padding: var(--pad) var(--pad) calc(var(--nav-h) + 28px); }
.screen.active { display: block; animation: fade 0.28s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen-header { margin: 8px 0 20px; }

/* ---------- BOTTOM NAV (4 slots) -----------------------------------------
   Labels black. Active = yellow-green dot/underline — NOT a magenta fill. */
#nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--app-max);
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1.5px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 40;
}
.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px 4px;
  font-size: var(--t-13);
  font-weight: 600;
  color: var(--ink);
  position: relative;
}
.nav-btn .nav-ico { width: 24px; height: 24px; stroke: var(--ink); fill: none; stroke-width: 1.8; }
.nav-btn .nav-dot {
  position: absolute;
  top: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: transparent;
}
.nav-btn.active { font-weight: 700; }
.nav-btn.active .nav-dot { background: var(--yellowgreen); }
.nav-btn.active::after {
  content: "";
  position: absolute;
  bottom: 6px;
  width: 22px; height: 3px;
  border-radius: 3px;
  background: var(--yellowgreen);   /* yellow-green underline, passes as pure accent */
}

/* ---------- BUTTONS ------------------------------------------------------
   Every button label is BLACK. Primary = yellow-green fill (passes 4.5:1). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  font-size: var(--t-17);
  font-weight: 600;
  color: var(--ink);              /* HARD RULE */
  background: var(--yellowgreen); /* text-bearing fill: OK with black */
  /* Primary buttons read as a solid shape: border matches the fill, no frame.
     Label stays black; contrast unaffected. Light-fill variants below re-add a
     black outline so they stay visible on cream. */
  border: 1.5px solid var(--yellowgreen);
  border-radius: 14px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn--ghost { background: var(--surface); border-color: var(--ink); }
.btn--cream { background: var(--bg); border-color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- FORM FIELDS --------------------------------------------------- */
label { display: block; font-size: var(--t-15); font-weight: 600; margin: 0 0 6px; color: var(--ink); }
.field {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: var(--t-17);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--card-radius);
}
.field::placeholder { color: var(--ink-45); }
.help { font-size: var(--t-13); color: var(--ink-70); margin: 6px 0 0; }

/* ---------- FOCUS (visible keyboard focus everywhere) --------------------- */
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 12px;
}
.nav-btn:focus-visible { box-shadow: var(--focus); }

/* ---------- SPLASH -------------------------------------------------------- */
#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  text-align: center;
  padding: var(--pad);
}
#splash img { width: 148px; height: 148px; animation: pop 0.6s ease both; }
#splash .hand { font-size: var(--t-28); }
@keyframes pop { from { opacity: 0; transform: scale(0.86); } to { opacity: 1; transform: none; } }
#splash.hide { opacity: 0; visibility: hidden; transition: opacity 0.4s ease, visibility 0s 0.4s; }

/* ---------- ONBOARDING ---------------------------------------------------- */
#onboarding { display: none; flex: 1 1 auto; padding: var(--pad); }
#onboarding.active { display: flex; flex-direction: column; }
.ob-logo { width: 92px; height: 92px; margin: 12px auto 4px; }
.stack > * + * { margin-top: 16px; }
.grow { flex: 1 1 auto; }

/* Italic pull-quote (onboarding welcome) — black text, magenta accent border only */
.pull-quote {
  font-style: italic;
  font-size: var(--t-17);
  line-height: 1.45;
  color: var(--ink);
  border-left: 3px solid var(--magenta);
  padding: 2px 0 2px 14px;
  margin: 6px 0 0;
}

/* 6-week roadmap accordion */
.roadmap { border: 1.5px solid var(--ink); border-radius: var(--card-radius-lg); background: var(--surface); overflow: hidden; }
.roadmap > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 16px;
  font-weight: 600;
  font-size: var(--t-15);
  color: var(--ink);
  display: flex; align-items: center; justify-content: space-between;
}
.roadmap > summary::-webkit-details-marker { display: none; }
.roadmap > summary::after {
  content: "";
  width: 9px; height: 9px;
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  transform: rotate(45deg); transition: transform 0.2s ease; margin-left: 10px;
}
.roadmap[open] > summary::after { transform: rotate(-135deg); }
.roadmap > summary:focus-visible { box-shadow: var(--focus); border-radius: 12px; }
.roadmap-list { list-style: none; margin: 0; padding: 0 16px 12px; }
.roadmap-list li {
  display: flex; align-items: baseline; gap: 10px;
  font-size: var(--t-15); line-height: 1.4; color: var(--ink);
  padding: 6px 0; border-top: 1px solid var(--hairline);
}
.roadmap-list li .emo-dot { flex: 0 0 auto; transform: translateY(1px); }
.roadmap-list strong { font-weight: 700; }

/* "Fully anonymous" pill — yellow-green fill + black text (passes 4.5:1) */
.pill--anon { background: var(--yellowgreen); border-color: var(--ink); }
.pill-ico { width: 15px; height: 15px; stroke: var(--ink); fill: none; stroke-width: 1.8; flex: 0 0 auto; }

/* Anonymity card (icon + text rows) */
.anon-card { padding: 4px 16px; }
.anon-row {
  display: flex; align-items: flex-start; gap: 12px;
  font-size: var(--t-15); line-height: 1.45; color: var(--ink);
  padding: 12px 0; border-top: 1px solid var(--hairline);
}
.anon-row:first-child { border-top: 0; }
.anon-ico { width: 22px; height: 22px; stroke: var(--ink); fill: none; stroke-width: 1.7; flex: 0 0 auto; margin-top: 1px; }

/* Mood screen intro — quiet helper text, not a card (doesn't crowd the slider) */
.mood-intro { margin: 0 0 10px; }

/* ---------- Consent screen ---------------------------------------------- */
.consent-card { padding: 20px; }
.consent-card h3 {
  font-size: var(--t-17); font-weight: 700; color: var(--ink);
  margin: 18px 0 6px;
}
.consent-card h3:first-child { margin-top: 0; }
.consent-card p { font-size: var(--t-15); line-height: 1.55; color: var(--ink); margin: 0 0 4px; }
.consent-card ul { margin: 4px 0 4px; padding-left: 1.2em; }
.consent-card li { font-size: var(--t-15); line-height: 1.5; color: var(--ink); margin: 0 0 4px; }

/* Checkbox row — black text, black accent tick, visible focus */
.consent-check {
  display: flex; align-items: flex-start; gap: 12px;
  font-size: var(--t-15); line-height: 1.45; color: var(--ink);
  cursor: pointer;
}
.consent-check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  margin: 0;
  accent-color: var(--ink);         /* black tick when checked */
  cursor: pointer;
}
.consent-check input[type="checkbox"]:focus-visible { box-shadow: var(--focus); border-radius: 4px; }

/* ---------- MISC ---------------------------------------------------------- */
.card { background: var(--surface); border-radius: var(--card-radius-lg); padding: 18px; box-shadow: var(--shadow-card); }
.emo-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink); vertical-align: middle; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-13); font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--ink); color: var(--ink);
}
.center { text-align: center; }
.hidden { display: none !important; }

/* ==========================================================================
   ASSESSMENT MODULE
   Full-screen overlay. One question per card, brand 7-point slider,
   only 1/4/7 labelled. Black text on cream, sketch-border primary card.
   ========================================================================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.overlay-inner {
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0));
}

.assess-head { margin: 6px 0 16px; }
.assess-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  overflow: hidden;
  margin: 8px 0 6px;
}
.assess-bar {
  height: 100%;
  width: 0;
  background: var(--yellowgreen);   /* pure accent fill, no text on it */
  transition: width 0.3s ease;
}

.assess-card { margin-bottom: auto; }
.assess-qnum { font-size: var(--t-13); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-70); margin: 0 0 8px; }
.assess-qtext { font-size: var(--t-17); font-weight: 500; line-height: 1.45; margin: 0 0 22px; color: var(--ink); }

/* ---- Brand 7-point slider ---- */
.slider-wrap { margin: 8px 0 4px; }
.slider-value {
  text-align: center;
  font-size: var(--t-34);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  margin: 0 0 4px;
}
.slider-value-label {
  text-align: center;
  font-size: var(--t-13);
  font-weight: 600;
  min-height: 1.2em;
  color: var(--ink-70);
  margin: 0 0 14px;
}
.slider-value-label.strong { color: var(--ink); }

input[type="range"].likert {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
/* track */
input[type="range"].likert::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
}
input[type="range"].likert::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
}
/* thumb — yellow-green fill, black border (accent, no text) */
input[type="range"].likert::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 30px; height: 30px;
  margin-top: -12px;
  border-radius: 50%;
  background: var(--yellowgreen);
  border: 2px solid var(--ink);
  box-shadow: 0 1px 3px rgba(17,17,17,0.25);
}
input[type="range"].likert::-moz-range-thumb {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--yellowgreen);
  border: 2px solid var(--ink);
  box-shadow: 0 1px 3px rgba(17,17,17,0.25);
}
input[type="range"].likert:focus-visible { outline: none; }
input[type="range"].likert:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus); }
input[type="range"].likert:focus-visible::-moz-range-thumb { box-shadow: var(--focus); }
/* Unset (no selection yet) — hollow dashed thumb, no "chosen" look */
input[type="range"].likert.unset::-webkit-slider-thumb {
  background: var(--bg);
  border-style: dashed;
}
input[type="range"].likert.unset::-moz-range-thumb {
  background: var(--bg);
  border-style: dashed;
}
.slider-value.unset { color: var(--ink-45); }

/* tick marks 1..7 */
.slider-ticks {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin: 8px 4px 0;
}
.slider-ticks span {
  text-align: center;
  font-size: var(--t-13);
  font-weight: 600;
  color: var(--ink-45);
}
.slider-ticks span.on { color: var(--ink); font-weight: 700; }
/* only 1 / 4 / 7 carry worded labels */
.slider-ends {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 2px 0;
  font-size: var(--t-13);
  font-weight: 600;
  color: var(--ink);
}
.slider-ends span:nth-child(2) { text-align: center; }
.slider-ends span:nth-child(3) { text-align: right; }

.assess-textarea {
  width: 100%;
  min-height: 130px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: var(--t-17);
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--card-radius);
  resize: vertical;
}
.assess-textarea::placeholder { color: var(--ink-45); }

.assess-nav {
  display: flex;
  gap: 12px;
  padding-top: 20px;
}
.assess-nav .btn { flex: 1 1 0; }
.assess-nav .btn--ghost { flex: 0 0 34%; }

/* ---- Weekly check-in ---- */
.weekly-card { margin: 4px 0 0; }        /* Q1 slider card (sketch frame) */
.weekly-field { margin-top: 22px; }      /* Q2 / Q3 open-text fields */
.weekly-field .field-label { margin-bottom: 8px; display: block; }

/* intro / ritual panel */
.ritual-line { font-size: var(--t-28); margin: 0 0 14px; }

/* ---------- RADAR / RESULTS ---------------------------------------------- */
.radar-wrap { margin: 8px 0 4px; }
.radar-wrap svg { width: 100%; height: auto; display: block; }
.radar-legend {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin: 6px 0 18px;
  font-size: var(--t-13);
  font-weight: 600;
  color: var(--ink);
}
.radar-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch {
  width: 16px; height: 16px; border-radius: 4px;
  border: 1.5px solid var(--ink);
  display: inline-block;
}
.legend-swatch.pre { background: transparent; border-color: var(--pink); border-width: 2.5px; }
.legend-swatch.post { background: rgba(218, 221, 66, 0.5); }
.score-rows { margin-top: 4px; }
.score-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.score-row:last-child { border-bottom: 0; }
.score-row .sr-name { font-weight: 700; }
.score-row .sr-vals { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ==========================================================================
   CONTENT / CHALLENGE ENGINE
   ========================================================================== */

/* ---- Today header + progress ring ---- */
.today-head { display: flex; align-items: center; gap: 14px; margin: 8px 0 18px; }
.ring-wrap { flex: 0 0 auto; width: 104px; height: 104px; }
.ring-wrap svg { width: 104px; height: 104px; display: block; }
.today-greet { min-width: 0; }
.today-greet h1 { margin: 0; }
.today-greet .eyebrow { margin: 0 0 2px; }

/* ---- Lesson eyebrow + card ---- */
.lesson-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--t-13); font-weight: 600;
  color: var(--ink-70); margin: 0 0 12px;
}
.lesson-eyebrow .emo-dot { flex: 0 0 auto; }
.lesson-card { margin: 0; }
.placeholder { text-align: center; padding: 10px 0; }

/* ---- Rendered markdown body ---- */
.lesson-body { font-size: var(--t-17); line-height: 1.6; color: var(--ink); overflow-wrap: break-word; }
.lesson-body > *:first-child { margin-top: 0; }
.lesson-body > *:last-child { margin-bottom: 0; }
.lesson-body h1 { font-size: var(--t-28); line-height: 1.2; margin: 0 0 0.5em; }
.lesson-body h2 { font-size: var(--t-22); margin: 1.1em 0 0.4em; }
.lesson-body h3 { font-size: var(--t-17); margin: 1.1em 0 0.4em; }
.lesson-body p { margin: 0 0 1em; }
.lesson-body strong { font-weight: 700; }
.lesson-body em { font-style: italic; }
.lesson-body ul, .lesson-body ol { padding-left: 1.25em; margin: 0 0 1em; }
.lesson-body li { margin: 0 0 0.4em; }
.lesson-body a { color: var(--ink); text-decoration: underline; }
.lesson-body hr { border: 0; border-top: 1px solid var(--hairline); margin: 18px 0; }
.lesson-body code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9em; background: var(--bg);
  padding: 1px 5px; border-radius: 5px;
}
/* Blockquotes — distinct callout, magenta accent BORDER only (no fill behind text) */
.lesson-body blockquote {
  margin: 16px 0; padding: 10px 14px;
  border-left: 3px solid var(--magenta);
  background: var(--surface);
  font-style: italic;
}

/* Tables — real GFM tables. Warm-neutral borders (softer than black, still
   legible on a phone), rounded outer corners via a clipping wrapper so the
   round works reliably on iOS Safari as well as Chrome. Black text throughout. */
.lesson-table {
  margin: 16px 0;
  border: 1px solid var(--table-border);
  border-radius: var(--card-radius);
  overflow: hidden;                 /* clips the cell fills to the rounded corners */
}
.lesson-body .lesson-table table {
  width: 100%;
  border-collapse: collapse;
  border: 0;
  margin: 0;
  font-size: var(--t-15);
  line-height: 1.45;
}
.lesson-body th, .lesson-body td {
  /* internal grid only — the wrapper draws the outer frame */
  border-right: 1px solid var(--table-border);
  border-bottom: 1px solid var(--table-border);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
  color: var(--ink);
  overflow-wrap: break-word;
}
.lesson-body th:last-child, .lesson-body td:last-child { border-right: 0; }
.lesson-body tr:last-child > th, .lesson-body tr:last-child > td { border-bottom: 0; }
.lesson-body thead th { background: var(--bg); font-weight: 700; }  /* cream fill + black text: passes */
.lesson-body tbody td { background: var(--surface); }
.lesson-body th[align="center"], .lesson-body td[align="center"] { text-align: center; }
.lesson-body th[align="right"], .lesson-body td[align="right"] { text-align: right; }
/* Single-column callout tables (research citations) read as centered notes */
.lesson-body table:not(:has(td)) thead th { font-weight: 500; }

/* Quiet journaling note after the YOUR PRACTICE box — muted helper text, not a
   card. Injected by renderMarkdown() (see PRACTICE_NOTE in app.js). */
.lesson-body .practice-note {
  margin: 16px 2px 0;
  font-size: var(--t-13);
  line-height: 1.55;
  color: var(--ink-70);
}

/* ---- Journey week cards + day cells ---- */
.week-card { margin-bottom: 14px; }
.week-head { display: flex; align-items: center; gap: 10px; }
.week-head > div { flex: 1 1 auto; min-width: 0; }
.week-head .emo-dot { flex: 0 0 auto; }
.week-title { font-weight: 700; margin: 0; }
.week-theme { margin: 0; font-size: var(--t-13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-head .pill { flex: 0 0 auto; }

.day-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 14px; }
.day-cell {
  aspect-ratio: 1 / 1;
  border: 1.5px solid var(--ink);
  border-radius: var(--card-radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: var(--t-17);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.day-cell.done-fill { background: var(--emo); border-color: var(--ink); }
.day-cell.done-border { background: var(--surface); border: 2.5px solid var(--emo); }
.day-cell.current {
  background: var(--bg);
  border: 2.5px solid var(--emo);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.05);
}
.day-cell.todo { border-style: dashed; color: var(--ink-45); }
.day-cell.locked { background: var(--bg); color: var(--ink-45); border-color: var(--hairline); }
.day-cell.done { cursor: pointer; }
.day-cell:disabled { cursor: default; }
.day-cell:focus-visible { box-shadow: var(--focus); }
.day-check { color: var(--ink); font-weight: 700; }
.ico-lock { width: 16px; height: 16px; stroke: var(--ink-45); fill: none; stroke-width: 1.8; }

/* ---- Reader overlay ---- */
.reader-topbar { margin: 0 0 12px; }
.reader-back { width: auto; min-height: 44px; padding: 8px 16px; }

/* ---------- Research citations (Me tab) ---------------------------------- */
.research-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left;
  margin-top: 16px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--card-radius);
  padding: 16px 18px;
  font-size: var(--t-17); font-weight: 600; color: var(--ink);
}
.research-row .row-chevron { width: 20px; height: 20px; stroke: var(--ink); fill: none; stroke-width: 1.8; flex: 0 0 auto; }
.research-row:focus-visible { box-shadow: var(--focus); }

.citations-intro { font-size: var(--t-15); color: var(--ink-70); margin: 4px 0 18px; }
.citation {
  font-size: var(--t-15);
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 14px;
  padding-left: 20px;
  text-indent: -20px;                 /* hanging indent for references */
  overflow-wrap: break-word;
  word-break: break-word;             /* wrap long DOIs/titles — never scroll sideways */
}

/* ==========================================================================
   MOOD TRACKER
   ========================================================================== */
.mood-banner {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--card-radius);
  padding: 10px 14px;
  font-size: var(--t-15);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 16px;
}
.mood-card { margin: 0; }
.mood-field { margin-top: 18px; }
.field-label {
  font-size: var(--t-15);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 8px;
}
.field-label .muted { font-weight: 400; }

/* Prominent mood slider */
.mood-slider-block { text-align: center; }
.mood-value {
  font-size: 3.4rem;
  line-height: 1;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}
.mood-word { font-size: var(--t-28); margin: 2px 0 14px; }
.mood-range { max-width: 100%; }

/* Segmented control — black text; selected = yellow-green fill (passes 4.5:1) */
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1 1 0;
  min-height: 46px;
  padding: 10px 8px;
  font-size: var(--t-15);
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--card-radius);
}
.seg-btn[aria-pressed="true"] { background: var(--yellowgreen); }
.seg-btn:focus-visible { box-shadow: var(--focus); }

/* ---- Mood graph / progress ---- */
.mood-graph-title { font-weight: 700; margin: 0 0 4px; }
.mood-dots { display: flex; gap: 10px; justify-content: center; margin: 16px 0 6px; }
.mood-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--surface);
}
.mood-dot.on { background: var(--yellowgreen); }
.mood-view-toggle { margin: 8px 0 12px; }
.mood-view-toggle .seg-btn { min-height: 38px; font-size: var(--t-13); }
.mood-chart-wrap { margin: 6px 0 4px; }
.mood-chart-wrap svg { width: 100%; height: auto; display: block; }
.mood-trend { font-size: var(--t-15); font-weight: 600; color: var(--ink); margin: 10px 0 0; }
.mood-legend { font-size: var(--t-13); color: var(--ink-70); margin: 4px 0 0; }

/* ---------- RESPONSIVE (down to 380px) ------------------------------------ */
@media (max-width: 380px) {
  :root { --pad: 16px; --t-34: 1.95rem; --t-28: 1.6rem; }
  .sketch { padding: 18px; }
  .today-head { gap: 10px; }
  .ring-wrap, .ring-wrap svg { width: 88px; height: 88px; }
  .day-row { gap: 6px; }
  .lesson-body th, .lesson-body td { padding: 7px 8px; }
  .mood-value { font-size: 2.9rem; }
  .seg { gap: 6px; }
  .seg-btn { padding: 10px 4px; }
}

/* ---------- REDUCED MOTION ------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
