/* ==========================================================================
   Nini — cozy pixel UI. Mobile-first (390px), RTL-aware, light + dark.
   ========================================================================== */

/* ---------- Fonts (self-hosted, no third-party requests) ----------
   TITLES: Alagard (Latin, ASCII only; user-supplied) with Jacquarda Bastarda 9 (OFL) catching
   accented letters Alagard lacks; PixelAE Bold (Arabic; user-supplied) for Arabic titles.
   BODY: IBM Plex Sans (Latin, OFL) + Tajawal (Arabic, OFL, user's pick). */
@font-face {
  font-family: 'NiniTitle';
  src: url('../assets/fonts/alagard.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Jacquarda Bastarda 9';
  src: url('../assets/fonts/jacquarda-bastarda-9.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'PixelAE';
  src: url('../assets/fonts/pixelae-bold.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Sans Arabic';
  font-weight: 400;
  src: url('../assets/fonts/plex-arabic-latin-ext-400.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Sans Arabic';
  font-weight: 400;
  src: url('../assets/fonts/plex-arabic-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Sans Arabic';
  font-weight: 500;
  src: url('../assets/fonts/plex-arabic-latin-ext-500.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Sans Arabic';
  font-weight: 500;
  src: url('../assets/fonts/plex-arabic-latin-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Sans Arabic';
  font-weight: 700;
  src: url('../assets/fonts/plex-arabic-latin-ext-700.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Sans Arabic';
  font-weight: 700;
  src: url('../assets/fonts/plex-arabic-latin-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}

@font-face {
  font-family: 'Tajawal';
  font-weight: 400;
  src: url('../assets/fonts/tajawal-arabic-400.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
  font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  font-weight: 500;
  src: url('../assets/fonts/tajawal-arabic-500.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
  font-display: swap;
}
@font-face {
  font-family: 'Tajawal';
  font-weight: 700;
  src: url('../assets/fonts/tajawal-arabic-700.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --font-title: 'NiniTitle', 'Jacquarda Bastarda 9', 'PixelAE', Georgia, serif;
  --font-title-ar: 'PixelAE', 'NiniTitle', 'Jacquarda Bastarda 9', serif;
  --font-body: 'Plex Sans Arabic', 'Tajawal', system-ui, sans-serif;
  --font-body-ar: 'Tajawal', 'Plex Sans Arabic', system-ui, sans-serif;
  --font-plain-ar: 'Tajawal', system-ui, sans-serif;
  --font-plain: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --u: 4px;            /* base unit */
  --px: 2px;           /* pixel border thickness (thin, like retro OS windows) */
  --sx: 1;             /* shadow direction (mirrored in RTL) */
  --gutter: 16px;

  --bg: #f3fbf7;
  --surface: #ffffff;
  --surface-2: #e4f6ed;
  --ink: #3a1725;
  --muted: #6a5855;
  --line: #3a1725;
  --shadow: #a1e0c3;
  --primary: #c94459;
  --primary-ink: #ffffff;
  --link: #2f6fc4;
  --focus: #2f6fc4;
  --panel: #7dd4ac;
  --panel-ink: #3a1725;
  --panel-muted: #2a4a3c;
  --gold: #fec803;
  --gold-shadow: #3a1725;
  --good: #2b7a52;
  --good-bg: #dcf5e7;
  --bad: #b23d4f;
  --bad-bg: #fde8ea;
  --alert: #b23d4f;
  --alert-bg: #fde8ea;
  --note-bg: #e3f4fd;
  --warn-bg: #fff1c2;
  --warn-ink: #6b4b00;
  --spark-o: 0.55;
  color-scheme: light;
}

/* Night garden ("lights out") */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14202a; --surface: #1d2c37; --surface-2: #243745;
    --ink: #eef8f3; --muted: #a9c2b9; --line: #070c10; --shadow: #070c10;
    --primary: #ff8fa3; --primary-ink: #2a0f18; --link: #8cc8ff; --focus: #8cc8ff;
    --panel: #1b4a3c; --panel-ink: #eef8f3; --panel-muted: #a8d8c4;
    --gold: #fec803; --gold-shadow: #070c10;
    --good: #8de0b0; --good-bg: #183327; --bad: #ffadb8; --bad-bg: #3a1d24;
    --alert: #ffb3bd; --alert-bg: #3a1d24; --note-bg: #1c2f42; --warn-bg: #3b3212; --warn-ink: #f7dc8c;
    --spark-o: 0.25;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14202a; --surface: #1d2c37; --surface-2: #243745;
  --ink: #eef8f3; --muted: #a9c2b9; --line: #070c10; --shadow: #070c10;
  --primary: #ff8fa3; --primary-ink: #2a0f18; --link: #8cc8ff; --focus: #8cc8ff;
  --panel: #1b4a3c; --panel-ink: #eef8f3; --panel-muted: #a8d8c4;
  --gold: #fec803; --gold-shadow: #070c10;
  --good: #8de0b0; --good-bg: #183327; --bad: #ffadb8; --bad-bg: #3a1d24;
  --alert: #ffb3bd; --alert-bg: #3a1d24; --note-bg: #1c2f42; --warn-bg: #3b3212; --warn-ink: #f7dc8c;
  --spark-o: 0.25;
  color-scheme: dark;
}

[dir="rtl"] { --sx: -1; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
}
/* Sparse pastel pixel sparkles, like the reference screens; they drift only on onboarding.
   A fixed layer moved with transform, so it stays cheap on phones. */
body::before {
  content: ''; position: fixed; inset: -24px; z-index: -1; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='192' height='192' shape-rendering='crispEdges'%3E%3Cg fill='%23ef7b91'%3E%3Crect x='27' y='21' width='3' height='9'/%3E%3Crect x='24' y='24' width='9' height='3'/%3E%3C/g%3E%3Cg fill='%23fec803'%3E%3Crect x='141' y='51' width='3' height='9'/%3E%3Crect x='138' y='54' width='9' height='3'/%3E%3C/g%3E%3Cg fill='%2366e29e'%3E%3Crect x='75' y='117' width='3' height='9'/%3E%3Crect x='72' y='120' width='9' height='3'/%3E%3C/g%3E%3Cg fill='%2374d2f7'%3E%3Crect x='165' y='159' width='3' height='9'/%3E%3Crect x='162' y='162' width='9' height='3'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 192px 192px; opacity: var(--spark-o);
  animation: bg-drift 12s linear infinite;
}
body:not(.is-onboarding)::before { animation: none; }
[dir="rtl"] body { font-family: var(--font-body-ar); font-size: 19px; line-height: 1.75; }
html.plain body { font-family: var(--font-plain); font-size: 17px; }
[dir="rtl"].plain body { font-family: var(--font-plain-ar); }

img { max-width: 100%; }
a { color: var(--link); text-underline-offset: 3px; }
p { margin: 0 0 calc(var(--u) * 3); }
p:last-child { margin-bottom: 0; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; inset-inline-start: 8px; top: -100px; z-index: 100;
  background: var(--surface); color: var(--ink); padding: 12px 16px;
}
.skip:focus { top: 8px; }

.sprite { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.ico { flex: none; display: inline-block; vertical-align: middle; }
.flip-x { transform: scaleX(-1); }
[dir="rtl"] .dir-icon { transform: scaleX(-1); }
[dir="rtl"] .flip-x.dir-icon { transform: none; }
.rot-90 { transform: rotate(90deg); }

/* ---------- Pixel frame (notched corners + hard drop shadow) ---------- */
.card, .btn, .bar, .choice, .type-card, .input, .seg__opt > span, .dialog, .chip, .toast, .hero {
  --frame: var(--line);
  --drop: var(--shadow);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--frame),
    0 var(--px) 0 0 var(--frame),
    calc(var(--px) * -1) 0 0 0 var(--frame),
    var(--px) 0 0 0 var(--frame),
    calc(var(--sx) * 4px) 4px 0 0 var(--drop);
}

/* ---------- Titles ---------- */
.title {
  font-family: var(--font-title);
  font-weight: 400;
  letter-spacing: 0;
  -webkit-font-smoothing: none;
  font-smooth: never;
  text-rendering: optimizeSpeed;
}
/* Alagard's pixel grid is 16px: keep Latin title sizes at integer multiples. */
.title--xl { font-size: 48px; line-height: 1.1; }
.title--lg { font-size: 32px; line-height: 1.2; margin-bottom: calc(var(--u) * 4); }
.title--hero { font-size: 32px; line-height: 1.2; }
.title:focus { outline: none; }
.title:focus-visible { outline: 3px solid var(--focus); }

/* Hero/onboarding titles: leaf green with a hard plum shadow (night: yellow). */
.hero .title, .onboard .title {
  color: var(--title-c, #2f8a5c);
  text-shadow: calc(var(--sx) * 2px) 2px 0 var(--gold-shadow);
}
.onboard .title { padding: 8px 12px; background: var(--surface); display: inline-block; box-shadow: 0 -3px 0 var(--line), 0 3px 0 var(--line), -3px 0 0 var(--line), 3px 0 0 var(--line), calc(var(--sx) * 6px) 6px 0 var(--shadow); }
.page > .title--lg { color: var(--ink); text-shadow: calc(var(--sx) * 2px) 2px 0 var(--shadow); }

[dir="rtl"] .title { font-family: var(--font-title-ar); letter-spacing: 0; }
/* PixelAE is drawn on a 0.1em grid: sizes must be multiples of 10px or its pixels come out uneven. */
[dir="rtl"] .title--xl { font-size: 40px; line-height: 1.4; }
[dir="rtl"] .title--lg { font-size: 30px; line-height: 1.5; }
[dir="rtl"] .title--hero { font-size: 30px; line-height: 1.5; }
.latin-title { font-family: var(--font-title); }
.ar-title { font-family: var(--font-title-ar); }

/* ---------- Shell ---------- */
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px var(--gutter);
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); color: var(--panel-ink);
  border-bottom: var(--px) solid var(--line);
}
.topbar__brand { font-family: var(--font-title); font-size: 32px; color: var(--brand, #fff); text-shadow: calc(var(--sx) * 2px) 2px 0 var(--gold-shadow); -webkit-font-smoothing: none; }
[dir="rtl"] .topbar__brand { font-family: var(--font-title-ar); font-size: 30px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 70%;
  padding: 4px 12px 4px 6px; background: var(--surface-2); color: var(--ink); text-decoration: none;
  --drop: transparent;
}
.chip__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn--bar { color: var(--ink); background: var(--surface); --frame: var(--line); --drop: transparent; gap: 4px; padding: 0 10px; }
.lang-code { font-size: 14px; font-weight: 700; }

main { padding: 20px var(--gutter) calc(96px + env(safe-area-inset-bottom)); outline: none; }
body.is-onboarding main { padding-bottom: 40px; }

.tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  max-width: 560px; margin: 0 auto;
  background: var(--panel); border-top: var(--px) solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; padding: 6px 4px; color: var(--panel-muted); text-decoration: none;
  font-size: 13px; line-height: 1.2; text-align: center;
}
[dir="rtl"] .tab { font-size: 13px; }
.tab.is-active { color: var(--ink); font-weight: 700; background: color-mix(in srgb, var(--surface) 60%, transparent); box-shadow: inset 0 3px 0 var(--line); }
.tab.is-active .ico { animation: hop 420ms steps(4) 1; }
.tab:focus-visible { outline-offset: -4px; }

/* ---------- Layout helpers ---------- */
.page > * + * { margin-top: 20px; }
.page > .title--lg + * { margin-top: 0; }
.lead { font-size: 1.1em; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.stack { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.row-links { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 14px; }
.subhead { font-size: 17px; font-weight: 700; margin: 16px 0 8px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); padding: 18px 18px 20px; margin-inline: var(--px); }
.card__title {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 700; margin-bottom: 12px; color: var(--ink);
}
[dir="rtl"] .card__title { font-size: 19px; }
.card__title .ico { color: var(--primary); }
.card__title--plain { display: block; }
.card--note { background: var(--note-bg); }
.card--good { background: var(--good-bg); }
.card--good .card__title .ico, .list--good .list__ico { color: var(--good); }
.card--bad { background: var(--bad-bg); }
.card--bad .card__title .ico, .list--bad .list__ico { color: var(--bad); }
.card--quiet { background: var(--surface-2); --drop: transparent; }
.card--quiet .card__title { font-size: 17px; color: var(--muted); }
.card--quiet .card__title .ico { color: var(--muted); }
.card--mood { background: var(--note-bg); }
.card--soon { text-align: center; }
.card--soon .card__title { justify-content: center; }
.card--soon__art { margin: 0 auto 12px; }
.card--soon .row-links { justify-content: center; }
.duo { display: grid; gap: 20px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list li { display: flex; gap: 10px; align-items: flex-start; }
.list li > span { flex: 1; }
.list:not(.list--good):not(.list--bad) li::before {
  content: ''; flex: none; width: 8px; height: 8px; margin-top: 0.65em; background: var(--primary);
}
[dir="rtl"] .list:not(.list--good):not(.list--bad) li::before { margin-top: 0.8em; }
.list__ico { margin-top: 0.2em; }

/* ---------- Hero = pixel garden (Today header) ---------- */
.hero { position: relative; color: var(--ink); padding: 20px 18px 22px; margin-inline: var(--px); background: var(--surface); }
.hero > * { position: relative; }
.hero__eyebrow { color: var(--muted); font-size: 15px; margin-bottom: 6px; }
.hero__big { font-size: 20px; font-weight: 700; margin: 8px 0 2px; }
.hero__meta { color: var(--muted); font-size: 15px; margin: 4px 0 0; }
.hero__action { margin-top: 14px; }

/* Garden palette. Day: pale sky, white clouds, mint grass. Night: navy sky, stars, deep green. */
:root {
  --sky: #b6eeff; --sky-2: #cff5ff; --cloud: #ffffff; --cloud-d: #8ae1ff;
  --grass: #4eb37e; --grass-l: #66e29e; --ground: #7dd4ac; --ground-d: #57a376;
  --cb-line: #3a1725; --cb-in: #ffffff; --cb-in-2: #f1fbf6; --cb-lip: #dbf3e8; --cb-n: #6a5855; --cb-q: #c94459;
  --sign: #ffffff; --sign-ink: #c94459;
  --cap-ink: #3a1725; --cap-muted: #4c3733; --title-c: #2f8a5c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky: #1b2350; --sky-2: #222c62; --cloud: #3a4680; --cloud-d: #2a3366;
    --grass: #24584a; --grass-l: #2f7360; --ground: #1d4a3d; --ground-d: #163a30;
    --cb-line: #070c10; --cb-in: #1d2c37; --cb-in-2: #22343f; --cb-lip: #243745; --cb-n: #a9c2b9; --cb-q: #ff8fa3;
    --sign: #1d2c37; --sign-ink: #ff8fa3;
    --cap-ink: #eef8f3; --cap-muted: #c7dcd3; --title-c: #fec803;
  }
}
:root[data-theme="dark"] {
  --sky: #1b2350; --sky-2: #222c62; --cloud: #3a4680; --cloud-d: #2a3366;
  --grass: #24584a; --grass-l: #2f7360; --ground: #1d4a3d; --ground-d: #163a30;
  --cb-line: #070c10; --cb-in: #1d2c37; --cb-in-2: #22343f; --cb-lip: #243745; --cb-n: #a9c2b9; --cb-q: #ff8fa3;
  --sign: #1d2c37; --sign-ink: #ff8fa3;
  --cap-ink: #eef8f3; --cap-muted: #c7dcd3; --title-c: #fec803;
}

.room {
  overflow: hidden; isolation: isolate; padding: 0; text-align: center;
  background: linear-gradient(var(--sky) 0 62%, var(--sky-2) 62%);
}
.sky { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.cloud { position: absolute; display: block; }
.cloud--a { top: 16px; left: -10px; animation: cloud-drift 40s steps(36) infinite alternate; }
.cloud--b { top: 64px; right: 8px; animation: cloud-drift 52s steps(36) -20s infinite alternate; }
.cloud--c { top: 150px; left: 4px; animation: cloud-drift 46s steps(36) -34s infinite alternate; }
.sky__sun { position: absolute; top: 18px; inset-inline-end: 22px; width: 16px; height: 16px; background: #fec803;
  box-shadow: 0 -8px 0 -4px #ffb966, 0 8px 0 -4px #ffb966, -8px 0 0 -4px #ffb966, 8px 0 0 -4px #ffb966; }
.sky__star { display: none; position: absolute; left: var(--x); top: var(--y); width: 3px; height: 3px; background: #fff6c8; animation: twinkle 4s steps(1) var(--d) infinite; }
.spark { position: absolute; left: var(--x); top: var(--y); line-height: 0; animation: twinkle 4.4s steps(1) var(--d) infinite; }
.spark .pix, .cloud.pix { display: block; }

.room__caption { padding: 26px 16px 0; color: var(--cap-ink); }
.room .hero__eyebrow, .room .title--hero { padding-inline: 44px; }
.room .hero__eyebrow { color: var(--cap-muted); margin-bottom: 4px; font-weight: 500; }
.room .hero__big { color: var(--cap-ink); margin-top: 6px; }
.room__caption > *, .room .hero__meta { text-wrap: balance; }
.room .title--hero { color: var(--title-c); text-shadow: calc(var(--sx) * 2px) 2px 0 var(--gold-shadow); }

.room__stage { display: grid; grid-template-columns: max-content; justify-content: center; margin-top: 14px; }
.room__wall { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding-inline: 6px; }

/* Sign: white tile with a plum pixel outline and pink pixel text, like the reference buttons. */
.chalk {
  align-self: center; margin: 0 0 16px; padding: 2px 12px; min-width: 64px; max-width: 140px;
  background: var(--sign); color: var(--sign-ink); font-family: var(--font-title); font-weight: 400; font-size: 16px; line-height: 1.6; text-align: center;
  box-shadow: 0 -3px 0 var(--cb-line), 0 3px 0 var(--cb-line), -3px 0 0 var(--cb-line), 3px 0 0 var(--cb-line), calc(var(--sx) * 4px) 6px 0 var(--ground-d);
}
[dir="rtl"] .chalk { font-family: var(--font-title-ar); font-size: 20px; line-height: 1.4; }
html.plain .chalk { font-family: var(--font-plain); }

.perch { flex: none; display: block; width: 64px; height: 64px; }
.perch__mascot { width: 64px; height: 64px; animation: bob 2s steps(2, jump-none) infinite; }

/* The planter shelf: white cubbies with plum pixel lines; items land in them as the weeks pass. */
.cubbies {
  --cell: 48px;
  position: relative; z-index: 2;
  display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); gap: 3px; padding: 3px;
  background: var(--cb-line); box-shadow: calc(var(--sx) * 4px) 6px 0 0 var(--ground-d);
}
.cubbies[style*="--cols:6"] { --cell: 42px; }
@media (max-width: 359px) {
  .cubbies { --cell: 44px; }
  .cubbies[style*="--cols:6"] { --cell: 40px; }
}
.cubby {
  position: relative; height: 52px; display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(var(--cb-in) 0 70%, var(--cb-in-2) 70%);
}
.cubby__item, .cubby__q { flex: 1; display: grid; place-items: center; }
.cubby__n {
  order: 2; height: 12px; background: var(--cb-lip); text-align: center;
  font-family: var(--font-body); font-weight: 700; font-size: 10px; line-height: 12px; color: var(--cb-n);
}
.cubby__item .sprite { width: 32px; height: 32px; }
.cubby.is-full .cubby__item { animation: drop 560ms steps(8) calc(260ms + var(--i) * 80ms) both; }
.room--settled .cubby.is-full:not(.is-new) .cubby__item { animation: none; }
.room--settled .cubby.is-new .cubby__item { animation-delay: 160ms; }
.cubby.is-new::after {
  content: ''; position: absolute; top: 8px; left: 50%; width: 3px; height: 3px; background: #ef7b91; pointer-events: none;
  box-shadow: -14px 6px 0 #fec803, 14px 2px 0 #66e29e, -10px 22px 0 #74d2f7, 12px 20px 0 #ef7b91;
  opacity: 0; animation: sparkle 1.6s steps(2, jump-none) calc(900ms + var(--i) * 80ms) 3;
}
.room--settled .cubby.is-new::after { animation-delay: 700ms; }
.cubby__q { font-family: var(--font-title); font-size: 20px; line-height: 1; color: var(--cb-q); padding-top: 4px; animation: twinkle 4s steps(1) infinite; }

/* Grass blades along the top of the mint ground; the small print sits on the ground. */
.room__table { height: 18px; margin-top: 4px; position: relative; overflow: hidden; }
.room__table .grass { position: absolute; bottom: 0; left: 0; display: block; }
.room__foot {
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 22px;
  padding: 10px 16px 16px; background: var(--ground);
  box-shadow: inset 0 -6px 0 var(--ground-d);
}
.room__foot:empty { padding: 0 0 10px; }
.room .hero__meta { margin: 0; color: var(--cap-ink); font-weight: 500; }
.room__foot .hero__action { margin-top: 4px; }

/* Night: stars and a moon replace the sun; clouds dim. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sky__star { display: block; }
  :root:not([data-theme="light"]) .sky__sun { background: #fff3c4; box-shadow: inset -5px 0 0 #d9c88a; }
  :root:not([data-theme="light"]) .spark { opacity: 0.5; }
}
:root[data-theme="dark"] .sky__star { display: block; }
:root[data-theme="dark"] .sky__sun { background: #fff3c4; box-shadow: inset -5px 0 0 #d9c88a; }
:root[data-theme="dark"] .spark { opacity: 0.5; }

/* Pixel blinds for the light/dark switch ("lights out"). */
.blinds { position: fixed; inset: 0; z-index: 100; display: flex; pointer-events: none; }
.blinds i { flex: 1; background: var(--blind); transform-origin: top; animation: blind-in 420ms steps(6) both; }
.blinds i:nth-child(2n) { transform-origin: bottom; }
.blinds i:nth-child(1) { animation-delay: 0ms; } .blinds i:nth-child(2) { animation-delay: 30ms; } .blinds i:nth-child(3) { animation-delay: 60ms; }
.blinds i:nth-child(4) { animation-delay: 90ms; } .blinds i:nth-child(5) { animation-delay: 120ms; } .blinds i:nth-child(6) { animation-delay: 150ms; }
.blinds i:nth-child(7) { animation-delay: 180ms; } .blinds i:nth-child(8) { animation-delay: 210ms; }
.blinds.is-open i { animation: blind-out 420ms steps(6) both; }
.blinds--night { --blind: #1b2350; }
.blinds--day { --blind: #b6eeff; }

/* Bunting hanging under the top bar on every screen. */
.topbar { position: sticky; }
.bunting {
  position: absolute; inset-inline: 0; top: 100%; height: 26px; margin-top: var(--px);
  display: flex; justify-content: space-between; padding-inline: 4px; pointer-events: none; overflow: hidden;
}
.flag { display: block; transform: translateY(var(--sag)); }
.flag .pix { display: block; transform-origin: 50% 0; animation: flutter 2.4s steps(2, jump-none) calc(var(--i) * -1.2s) 2; }
.flag::before { content: ''; display: block; height: 2px; width: 22px; margin-inline-start: -4px; background: color-mix(in srgb, var(--line) 55%, transparent); }
:root[data-theme="dark"] .flag .pix { filter: brightness(0.6) saturate(0.7); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .flag .pix { filter: brightness(0.6) saturate(0.7); } }
main { padding-top: 34px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.chip { min-width: 0; }
.btn--bar[aria-current="page"] { background: var(--gold); color: #3a1725; }

/* ---------- Stage navigation ---------- */
.stagenav { display: flex; align-items: center; gap: 12px; }
.stagenav__mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; }
.stagenav__label { font-weight: 700; }
.link-today { font-size: 15px; min-height: 32px; display: inline-flex; align-items: center; }

/* ---------- Size card ---------- */
.card--size { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.size__art { background: var(--surface-2); padding: 8px; box-shadow: inset 0 0 0 3px var(--surface-2), inset 0 0 0 5px var(--shadow); }
.size__art .sprite { width: 112px; height: 112px; }
.size__text .card__title { margin-bottom: 8px; }
.stats { display: flex; gap: 16px; margin: 0 0 6px; flex-wrap: wrap; }
.stats div { display: flex; flex-direction: column; }
.stats dt { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
[dir="rtl"] .stats dt { text-transform: none; letter-spacing: 0; }
.stats dd { margin: 0; font-size: 20px; font-weight: 700; }
.size__note { font-size: 14px; color: var(--muted); }
@media (max-width: 359px) { .card--size { grid-template-columns: 1fr; justify-items: center; text-align: center; } .stats { justify-content: center; } }

/* ---------- Hormones / milestones / vaccines ---------- */
.hormones { display: grid; gap: 12px; margin-top: 12px; }
.hormone { background: var(--surface-2); padding: 12px 14px; border-inline-start: 4px solid var(--gold); }
.hormone__name { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.hormone__name .ico { color: #c98a12; }
.hormone p { margin: 0; }
.milestones { display: grid; gap: 16px; margin-bottom: 12px; }
.ms__title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.ms__title .ico { color: var(--primary); }
.vax { margin-bottom: 10px; }
.vax__age { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.vax .list__ico { color: var(--muted); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 8px; font-size: 13px; font-weight: 700; line-height: 1.5;
  background: var(--surface-2); color: var(--ink); white-space: nowrap;
  box-shadow: 0 -2px 0 var(--line), 0 2px 0 var(--line), -2px 0 0 var(--line), 2px 0 0 var(--line);
  margin: 2px;
}
.badge--now { background: var(--gold); color: #3a1725; }
.badge--ready { background: var(--good-bg); color: var(--good); }
.badge--soon { background: transparent; color: var(--muted); box-shadow: 0 -2px 0 var(--muted), 0 2px 0 var(--muted), -2px 0 0 var(--muted), 2px 0 0 var(--muted); }
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); }
p.badge { margin-bottom: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 10px 18px; margin: var(--px);
  background: var(--surface); color: var(--ink);
  border: 0; border-radius: 0; cursor: pointer; text-decoration: none; font-weight: 700; text-align: center;
  transition: transform 60ms steps(1), filter 60ms;
}
.btn:hover { filter: brightness(1.05); }
@media (hover: hover) {
  .btn:not(.is-disabled):not(.btn--bar):hover { transform: translateY(-2px); }
  .btn:not(.is-disabled):not(.btn--bar):active { transform: translate(calc(var(--sx) * 3px), 3px); }
}
.btn:active { transform: translate(calc(var(--sx) * 3px), 3px); --drop: transparent; }
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--ghost { background: var(--surface-2); }
.btn--danger { color: var(--alert); }
.btn--block { display: flex; width: calc(100% - var(--px) * 2); }
.btn--small { min-height: 44px; padding: 6px 14px; font-size: 16px; }
.btn--icon { min-width: 48px; padding: 0; }
.btn.is-disabled { opacity: 0.35; cursor: default; --drop: transparent; }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 4px; }

/* ---------- Onboarding ---------- */
.onboard { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 20px; padding-top: 12px; }
.onboard .card { text-align: start; width: calc(100% - 6px); }
.onboard__q { font-size: 20px; font-weight: 700; }
.choice-list { display: grid; gap: 14px; width: 100%; }
.choice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px; padding: 10px 18px; margin: var(--px); background: var(--surface); border: 0; cursor: pointer;
  font-size: 20px; font-weight: 700;
}
.choice[lang="ar-MA"] { font-family: var(--font-body-ar); }
.choice[lang="fr"], .choice[lang="en"] { font-family: var(--font-body); }
.choice.is-selected { background: var(--gold); color: #3a1725; }

.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.type-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 18px 12px; margin: var(--px); background: var(--surface); color: var(--ink); text-decoration: none;
}
.type-card:hover { background: var(--surface-2); }
.type-card__name { font-size: 20px; font-weight: 700; }
.type-card__hint { font-size: 15px; color: var(--muted); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 18px; }
.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.field__label { display: block; font-weight: 700; margin-bottom: 8px; padding: 0; }
.input {
  display: block; width: calc(100% - var(--px) * 2); min-height: 48px; margin: var(--px);
  padding: 10px 12px; background: var(--surface); border: 0; border-radius: 0; --drop: transparent;
}
.input:focus-visible { outline-offset: 5px; }
.input[aria-invalid="true"] { --frame: var(--alert); background: var(--alert-bg); }
.field__error { color: var(--alert); font-weight: 700; margin: 8px 0 0; }
.computed { margin: 10px 0 0; font-weight: 600; color: var(--good); min-height: 1.6em; }
.form__actions { display: flex; flex-wrap: wrap; gap: 14px; }
.form__actions .btn { flex: 1; }

.seg { display: flex; flex-wrap: wrap; gap: 12px; }
.seg__opt { position: relative; flex: 1 1 140px; display: flex; }
.seg--3 .seg__opt { flex-basis: 90px; }
.seg__opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg__opt > span {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 8px 12px; margin: var(--px); background: var(--surface-2); font-weight: 600; --drop: transparent;
}
.seg__opt input:checked + span { background: var(--primary); color: var(--primary-ink); --drop: var(--shadow); }
.seg__opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 5px; }

/* ---------- Timeline ---------- */
.tl { list-style: none; padding: 0; margin: 0; }
.tl__group h2 { font-size: 18px; font-weight: 700; color: var(--muted); margin: 24px 0 8px; }
.tl__group:first-child h2 { margin-top: 4px; }
.tl__link {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 10px;
  color: var(--ink); text-decoration: none; border-bottom: 2px dashed var(--shadow);
}
.tl__link:hover { background: var(--surface); }
.tl__item.is-now .tl__link { background: var(--surface); box-shadow: inset 0 0 0 3px var(--gold); border-bottom-color: transparent; }
.tl__art { width: 32px; height: 32px; flex: none; display: grid; place-items: center; }
.tl__dot { width: 12px; height: 12px; background: var(--shadow); }
.tl__item.is-now .tl__dot { background: var(--gold); }
.tl__text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tl__label { font-weight: 700; }
.tl__sub { font-size: 14px; color: var(--muted); }

/* ---------- Profiles ---------- */
.profiles { list-style: none; padding: 0; margin: 0; display: grid; gap: 20px; }
.profile { padding: 12px; }
.profile.is-active { --frame: var(--primary); }
.profile__main {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 4px;
  background: none; border: 0; text-align: start; cursor: pointer;
}
.profile__text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.profile__name { font-weight: 700; font-size: 19px; }
.profile__sum { font-size: 15px; color: var(--muted); }
.profile__actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }

/* ---------- Misc ---------- */
.fineprint { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--muted); margin-top: 28px; }
.fineprint .ico { margin-top: 0.2em; }
.status { min-height: 1.6em; margin-top: 10px; font-weight: 700; }

.dialog {
  border: 0; padding: 20px; width: min(92vw, 400px); background: var(--surface); color: var(--ink);
}
.dialog::backdrop { background: rgba(20, 12, 8, 0.6); }
.dialog .choice-list { margin: 8px 0 16px; }

.toast {
  position: fixed; inset-inline: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 528px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: var(--panel); color: var(--panel-ink); --frame: var(--line);
}
.toast[hidden] { display: none; }

/* ---------- Gentle help link + "when to get help" page ---------- */
.soft-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 4px;
  color: var(--link); font-size: 16px; font-weight: 600; text-decoration: none;
}
.soft-link span { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.soft-link .ico:first-child { color: var(--primary); }
.help-line { text-align: center; margin: 4px 0 0; }

.fold { padding: 0; }
.fold__summary {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 12px 18px;
  font-weight: 700; font-size: 18px; cursor: pointer; list-style: none;
}
.fold__summary::-webkit-details-marker { display: none; }
.fold__summary > span { flex: 1; }
.fold__summary .ico:first-child { color: var(--primary); }
.fold__chev { transform: rotate(90deg); transition: transform 160ms steps(2); color: var(--muted); }
.fold[open] .fold__chev { transform: rotate(-90deg); }
.fold > .list { padding: 0 18px 20px; animation: pop 280ms steps(3) both; }

.numbers { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.num {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 4px;
  color: var(--ink); text-decoration: none; border-bottom: 2px dashed var(--shadow);
}
.num__tel { font-size: 20px; font-weight: 700; min-width: 3ch; }
.num__label { flex: 1; font-size: 15px; color: var(--muted); }
.num .ico { color: var(--muted); }

/* ---------- Pixel motion ----------
   Everything moves in hard steps (steps()), never smooth easing, so it feels like a
   sprite-based game. All of it is switched off under prefers-reduced-motion. */
@keyframes bg-drift { to { transform: translate(24px, 24px); } }
@keyframes twinkle { 0%, 100% { opacity: 0.85; } 40% { opacity: 0.2; } 55% { opacity: 1; } 70% { opacity: 0.5; } }
@keyframes cloud-drift { from { transform: translateX(-24px); } to { transform: translateX(48px); } }
@keyframes swing { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
@keyframes flutter { 0%, 100% { transform: none; } 50% { transform: skewX(8deg); } }
@keyframes drop { 0% { opacity: 0; transform: translateY(-140px); } 12% { opacity: 1; } 70% { transform: translateY(0); } 82% { transform: translateY(2px) scale(1.15, 0.85); } 100% { transform: none; } }
@keyframes sparkle { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
@keyframes blind-in { from { transform: scaleY(0); } }
@keyframes blind-out { to { transform: scaleY(0); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-5px); } 70% { transform: translateY(-2px); } }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }
@keyframes title-drop { from { opacity: 0; transform: translateY(-12px); } }
@keyframes pulse-now { 0%, 100% { filter: none; } 50% { filter: brightness(1.15); } }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } 45% { transform: scale(1.15); } }
@keyframes spin-sparkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Idle "breathing" bob for mascots and the size sprite (2 frames, like a game idle loop). */
.onboard__art, .card--soon__art, .size__art .sprite, .type-card .sprite {
  animation: bob 2s steps(2, jump-none) infinite;
}
.type-card:hover .sprite { animation-duration: 0.8s; }

/* Page entrance: blocks pop in one after another. */
.page > *, .onboard > * { animation: pop 320ms steps(4) both; }
.page > :nth-child(2), .onboard > :nth-child(2) { animation-delay: 60ms; }
.page > :nth-child(3), .onboard > :nth-child(3) { animation-delay: 120ms; }
.page > :nth-child(4), .onboard > :nth-child(4) { animation-delay: 180ms; }
.page > :nth-child(5), .onboard > :nth-child(5) { animation-delay: 240ms; }
.page > :nth-child(6), .onboard > :nth-child(6) { animation-delay: 300ms; }
.page > :nth-child(n+7), .onboard > :nth-child(n+7) { animation-delay: 360ms; }

.hero .title--hero { animation: title-drop 360ms steps(4) 120ms both; }
.no-enter .page > *, .no-enter .onboard > *, .no-enter .hero .title--hero,
.no-enter .cubby.is-full .cubby__item, .no-enter .cubby.is-new::after, .no-enter .flag .pix { animation: none; }

.badge--now { animation: pulse-now 1.6s steps(2, jump-none) 3; }
.tl__item.is-now .tl__dot { animation: bob 0.9s steps(2, jump-none) infinite; }
.card--mood .card__title .ico { animation: beat 2.4s steps(6) 600ms 2; }
.hormone__name .ico { animation: spin-sparkle 2s steps(2, jump-none) 2; }
.soft-link:hover .ico:first-child { animation: beat 1.2s steps(6) infinite; }

@media (min-width: 600px) {
  :root { --gutter: 24px; }
  #app { box-shadow: 0 0 0 3px var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Colour pixel icons ---------- */
/* Inactive tabs show their icon muted, so the active tab (full colour + hop) stands out. */
.tab:not(.is-active) .ico--color { filter: saturate(0.45) brightness(0.8); opacity: 0.8; }
.btn.is-disabled .ico--color { filter: grayscale(1); }

/* ---------- Retro windows (panels) ----------
   Every card reads like a little pixel OS window: white body, thin dark outline, light offset
   shadow, and a tinted title bar with a pixel-font title. The square box at the end of the bar
   holds the card's icon (a real control box would suggest it can be closed; it can't). */
:root { --bar: #e4f6ed; --bar-good: #d4f5e2; --bar-bad: #fde3e7; --bar-note: #def2fd; --grid: #dcefe5;
  --brand: #ffffff; --field-line: #3a1725; --rule: #a1e0c3; }
:root[data-theme="dark"] { --bar: #243745; --bar-good: #1d3a2d; --bar-bad: #3a2129; --bar-note: #1f3346; --grid: #1a2a35;
  --brand: #fec803; --field-line: #6f8a83; --rule: #33495a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bar: #243745; --bar-good: #1d3a2d; --bar-bad: #3a2129; --bar-note: #1f3346; --grid: #1a2a35;
    --brand: #fec803; --field-line: #6f8a83; --rule: #33495a; }
}

/* grid paper */
body::before {
  background:
    linear-gradient(var(--grid) 0 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--grid) 0 1px, transparent 1px) 0 0 / 24px 24px;
  opacity: 1; animation: none;
}

.card { background: var(--surface); padding: 0 16px 18px; }
.card--good, .card--bad, .card--note, .card--mood, .card--quiet { background: var(--surface); }
.card__title {
  margin: 0 -16px 14px; padding: 6px 8px 6px 14px; min-height: 40px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bar); border-bottom: var(--px) solid var(--line);
  /* Latin: bold caps of the body face (Alagard can't do French accents cleanly at this size). */
  font-family: var(--font-body); font-weight: 700; font-size: 14px; line-height: 1.3; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink);
}
[dir="rtl"] .card__title { padding: 6px 14px 6px 8px; font-family: var(--font-title-ar); font-weight: 400; font-size: 20px; line-height: 1.4; letter-spacing: 0; text-transform: none; }
html.plain .card__title { font-family: var(--font-plain); font-weight: 700; font-size: 17px; }
[dir="rtl"].plain .card__title { font-family: var(--font-plain-ar); }
.card__title > span { flex: 1; }
/* the "control box" at the end of the title bar holds the icon */
.card__title > .ico {
  order: 2; flex: none; box-sizing: content-box; padding: 2px; background: var(--surface);
  box-shadow: 0 0 0 var(--px) var(--line);
}
.card__title > .ico { width: 20px; height: 20px; padding: 4px; }
.card__title > .ico--obj { width: 32px; height: 32px; padding: 0; }
.card--good .card__title { background: var(--bar-good); }
.card--bad .card__title { background: var(--bar-bad); }
.card--note .card__title, .card--mood .card__title { background: var(--bar-note); }
.card--quiet .card__title { font-size: 14px; color: var(--ink); }
[dir="rtl"] .card--quiet .card__title { font-size: 20px; }

/* Cards whose art sits above the title, and the size card, keep a plain centred heading. */
.card--soon, .card--size { padding-top: 18px; }
.card--soon .card__title, .card__title--plain {
  margin: 0 0 10px; padding: 0; min-height: 0; background: none; border: 0;
  font-family: var(--font-body); font-weight: 700; font-size: 20px; letter-spacing: 0; text-transform: none;
}
[dir="rtl"] .card--soon .card__title, [dir="rtl"] .card__title--plain { font-family: var(--font-body-ar); font-weight: 700; font-size: 19px; }
.card--soon .card__title { justify-content: center; }

/* Folding groups on the help page use the same bar. */
.fold { padding: 0; }
.fold__summary {
  background: var(--bar); min-height: 44px; padding: 6px 14px;
  font-family: var(--font-body); font-weight: 700; font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase;
}
[dir="rtl"] .fold__summary { font-family: var(--font-title-ar); font-weight: 400; font-size: 20px; letter-spacing: 0; text-transform: none; }
.fold[open] .fold__summary { border-bottom: var(--px) solid var(--line); margin-bottom: 14px; }
html.plain .fold__summary { font-family: var(--font-plain); font-weight: 700; }

/* Week headline as a speech bubble (like the "HI, I'M ..." labels). */
.page--home > .lead {
  position: relative; justify-self: start; width: fit-content; max-width: calc(100% - 12px);
  margin-inline: var(--px); padding: 8px 14px; background: var(--surface); font-weight: 600;
  box-shadow: 0 calc(var(--px) * -1) 0 var(--line), 0 var(--px) 0 var(--line), calc(var(--px) * -1) 0 0 var(--line), var(--px) 0 0 var(--line);
}
.page--home > .lead::after {
  content: ''; position: absolute; top: 100%; inset-inline-start: 18px; width: 12px; height: 8px; margin-top: var(--px);
  background: var(--line); clip-path: polygon(0 0, 100% 0, 0 100%);
}
[dir="rtl"] .page--home > .lead::after { clip-path: polygon(0 0, 100% 0, 100% 100%); }
.page--home > .lead + * { margin-top: 26px; }

.hormone { background: var(--bar); border-inline-start-color: var(--gold); }

/* ---------- Screen polish (forms, timeline, profiles, dialog) ----------
   Follow-ups to the retro-window restyle for the screens around Today. */

/* Buttons that sit directly in a page keep the page rhythm (.btn's own margin used to win). */
.page > * + .btn { margin-top: 20px; }

/* Windows without a title bar still need breathing room at the top. */
.form.card { padding-top: 18px; }

/* Empty text fields need a visible edge in the night theme too (WCAG 1.4.11). */
.input { --frame: var(--field-line); }
.input[aria-invalid="true"] { --frame: var(--alert); }

/* Theme choice: give the long "Dark (night feeds)" label its own row instead of three cramped lines. */
.seg:has(input[name="theme"]) .seg__opt { flex-basis: 120px; }

/* Add-profile choice: on very narrow phones, stack the two tiles as rows (art beside the text). */
@media (max-width: 359px) {
  .type-grid { grid-template-columns: 1fr; gap: 16px; }
  .type-card {
    display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto;
    column-gap: 14px; row-gap: 2px; align-items: center; text-align: start; padding: 12px 14px;
  }
  .type-card .sprite { grid-row: span 2; width: 64px; height: 64px; }
  .type-card__name { align-self: end; }
  .type-card__hint { align-self: start; }
}

/* Language dialog: the title bar runs edge to edge like every other window. */
.dialog { padding: 0 16px 18px; }
.dialog .choice-list { margin: 0 0 16px; }

/* Profiles: the "current" badge becomes a sticker on the window frame, so the summary keeps its width. */
.profiles { gap: 24px; }
.profile.card { position: relative; padding: 14px; }
.profile .badge--now { position: absolute; top: -12px; inset-inline-end: 12px; margin: 0; }

/* Timeline: one window, with each trimester / period as a title bar. */
.tl {
  margin-inline: var(--px); background: var(--surface);
  box-shadow: 0 calc(var(--px) * -1) 0 0 var(--line), 0 var(--px) 0 0 var(--line), calc(var(--px) * -1) 0 0 0 var(--line),
    var(--px) 0 0 0 var(--line), calc(var(--sx) * 4px) 4px 0 0 var(--shadow);
}
.tl .tl__group h2 {
  margin: 0; padding: 8px 14px; min-height: 40px; display: flex; align-items: center;
  background: var(--bar); border-block: var(--px) solid var(--line); color: var(--ink);
  font-family: var(--font-body); font-weight: 700; font-size: 14px; line-height: 1.3; letter-spacing: 0.06em; text-transform: uppercase;
}
.tl .tl__group:first-child h2 { border-top: 0; }
[dir="rtl"] .tl .tl__group h2 { font-family: var(--font-title-ar); font-weight: 400; font-size: 20px; line-height: 1.4; letter-spacing: 0; text-transform: none; }
html.plain .tl .tl__group h2 { font-family: var(--font-plain); font-weight: 700; font-size: 16px; letter-spacing: 0; text-transform: none; }
[dir="rtl"].plain .tl .tl__group h2 { font-family: var(--font-plain-ar); }
.tl__link { padding: 6px 14px; border-bottom-color: var(--rule); }
.tl__item:last-child .tl__link, .tl__item:has(+ .tl__group) .tl__link { border-bottom-color: transparent; }
.tl__link:hover { background: var(--surface-2); }
.tl__dot { background: var(--grass-l); }
