/*
 * Mia's one shared stylesheet. No web fonts, nothing from the internet.
 *
 * Two themes, picked on <html> before the first paint (the inline snippet in each page's <head> reads localStorage
 * "mia_theme"):  no attribute / data-theme="dark"  the dark look, the default (deep blue-black, soft off-white text)
 *                data-theme="light"               the earlier bright look (cream and white)
 * Components only use the tokens below, so every component works in both themes. Dark surfaces get lighter as they
 * come forward (page < card < hover); depth comes from a lighter border, not a dark shadow.
 *
 * Two looks, picked by a class on <body> (or on any container):
 *   .child  big round targets (>= 88 px), the rounded font, coral actions, the bunny's purple as accent
 *   .grown  calm cards for the grown-ups' pages
 *
 * Grown-up kit (Task 5 builds every grown-up page from these):
 *   Page       body.grown > .topbar + main.page
 *   Top bar    .topbar > .topbar-in > a.brand (img/svg + text) + nav.nav (a, a[aria-current="page"]) + .nav-end
 *              .nav-toggle (button shown below 760 px; toggles .topbar.open)   .nav-who (the family's number tail)
 *   Layout     .page (max 880 px)  .page-wide (max 1120 px)  .page-head > h1 + p.lede + .page-actions
 *              .stack (vertical gap)  .row (wrap, gap)  .grid-2 / .grid-3 (cards side by side, 1 column on phones)
 *              .spacer (push to the end of a .row)
 *   Cards      .card  .card-head (h2 + actions)  .card-foot  .card.muted-card  .section-title (small caps heading)
 *              .box (a quiet inset box inside a card)
 *   Text       .lede  .muted  .small  .mono  .nowrap  .sr-only  .truncate
 *   Buttons    .btn (+ .btn-primary | .btn-secondary | .btn-danger | .btn-ghost | .btn-link) (+ .btn-sm | .btn-lg | .btn-block)
 *              disabled works; .btn.busy shows a spinner; .btn-icon for an icon-only button (needs aria-label)
 *   Forms      .field > label + input/select/textarea + p.hint + p.error   (.field.invalid turns it red; set
 *              aria-invalid="true" on the control)   .field-row (fields side by side)   .check > input[type=checkbox] + span
 *              .radio-list > label.check   .input-suffix (input with a unit after it)   fieldset.fieldset > legend
 *   Segmented  .seg > label > input[type=radio] + span   (or .seg > button[aria-pressed])
 *   Choices    .choices > label.choice > input[type=radio] + span.choice-face   (animal and colour pickers)
 *              .swatch (a round colour dot: paintColour() it)
 *   Tables     .table-wrap > table.table   (th, td, td.num, tr.is-muted)
 *   Lists      ul.list > li.list-item > .list-main (.list-title + .list-meta) + .list-actions
 *   Tags       .tag (+ .tag-ok | .tag-warn | .tag-danger | .tag-accent | .tag-muted)
 *   Notices    .notice (+ .notice-ok | .notice-warn | .notice-error | .notice-info) > strong + p   (inline status)
 *   Status     p.status[role=status] (+ .ok | .err) for "Saved" / "Couldn't save" next to a button
 *   Toast      .toast (fixed, bottom centre; add .show; + .toast-ok | .toast-err)
 *   Modal      dialog.modal > h2 + p + .modal-actions (use showModal(); ::backdrop is styled)
 *   Empty      .empty > svg + p
 *   PIN pad    .pin-dots > span (+ .on)   .pinpad > button (digits)   .pinpad .pin-wide
 *   Avatar     .chip (animal emoji on the child's colour; app.js avatarChip()) (+ .chip-sm | .chip-lg)
 *   Added for the grown-up pages (parent.js): .kids > a.kid (child switcher)  .brand-mia  label.switch > input +
 *              span.switch-track + span  .shake  .form-sec(-title) .pick .pick-preview (profile form)  .privacy-sec
 *
 * Child kit: .c-screen .c-mia .c-title .c-line .c-talk .c-btn (.c-btn-sky .c-btn-purple .c-btn-quiet) .c-badge .c-shelf
 *   .c-sticker .c-new-sticker .c-corner .c-switch .c-help .c-endlink .c-grownups .c-problem .c-art .c-askgrownup
 *   .c-detail .c-panel .c-card .c-picker .c-link
 *
 * Phones: every page works from 360 px wide; full screens use 100dvh and the safe-area insets; grown-up targets are
 * at least 44 px and child targets at least 88 px; inputs are 16 px or more (iOS does not zoom).
 */

/* ---------- tokens: dark (the default) ---------- */
:root {
  color-scheme: dark;
  --font-round: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Varela Round", "Quicksand",
                system-ui, sans-serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* surfaces, back to front */
  --bg: #14152b;            /* child pages (the read-aloud screen's family) */
  --bg-grown: #121327;      /* grown-up pages */
  --surface-2: #191a34;     /* quiet boxes, card feet, table heads */
  --surface: #1d1f3b;       /* cards, panels, buttons */
  --surface-3: #272a50;     /* hover, chips, stickers */
  --field: #15162f;         /* inputs (set into the card) */
  --paper: var(--surface);
  --cream: var(--bg);

  --ink: #ecebf5;           /* soft off-white */
  --ink-2: #c9c7dc;
  --muted: #a3a0bf;         /* >= 5.7:1 on every surface */
  --line: #2c2f55;          /* dividers */
  --line-2: #3d416d;        /* borders of controls */
  --line-3: #585d92;        /* hovered borders */
  --field-line: #4b4f82;    /* input borders (>= 3:1 against the field) */

  --purple: #a874f5;        /* the bunny: focus rings, checked borders, small fills */
  --purple-700: #7a45dc;    /* filled buttons with white text (5.7:1) */
  --purple-press: #6634c4;
  --purple-deep: #3f1f73;   /* the lip under a purple child button */
  --purple-dark: #dccbff;   /* strong accent text */
  --accent-text: #c5a6ff;   /* links */
  --purple-soft: #2b2552;   /* soft accent backgrounds */
  --purple-soft-2: #352d63;
  --purple-line: #4a3f80;
  --purple-line-2: #5d4f9c;

  --coral: #e4532f;         /* the child's action colour (white text 3.8:1, used for large bold text only) */
  --coral-hi: #ff7a55;
  --coral-dark: #9e341a;    /* the lip under a coral button */
  --coral-soft: #3d2430;
  --coral-line: #6b3a3a;
  --coral-ink: #ffb39c;
  --sky: #3a7fd6;
  --sky-dark: #1f5296;
  --sky-ink: #9cc8ff;
  --sun: #f2c14e;
  --mint: #7bd8a5;
  --on-accent: #fff;

  --ok: #6fdba0;   --ok-soft: #15322a;   --ok-line: #245a43;   --ok-fill: #23774c;
  --warn: #f2c46d; --warn-soft: #2e2717; --warn-line: #5e4a22;
  --err: #ff9b9b;  --err-soft: #3b1c24;  --err-line: #6e2f3a;  --err-fill: #c43c3c; --err-fill-2: #a83131;
  --info: #8fbcff; --info-soft: #172a47; --info-line: #2b4a78;

  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-xl: 28px; --r-2xl: 40px; --pill: 999px;
  --shadow-sm: 0 0 0 0 transparent;
  --shadow: 0 1px 2px rgba(0, 0, 0, .22);
  --shadow-lg: 0 0 0 1px var(--line-2), 0 24px 60px rgba(0, 0, 0, .45);
  --focus-gap: var(--bg);
  --focus: 0 0 0 3px var(--focus-gap), 0 0 0 6px var(--purple);
  --ring-soft: rgba(168, 116, 245, .32);
  --ease: cubic-bezier(.2, .7, .3, 1);
  --t: .16s;

  --topbar-bg: rgba(18, 19, 39, .88);
  --backdrop: rgba(6, 7, 18, .72);
  --toast-bg: #2e3158;  --toast-ink: var(--ink);   --toast-line: var(--line-3);
  --toast-ok-bg: var(--ok-soft); --toast-ok-ink: var(--ok); --toast-ok-line: var(--ok-line);
  --toast-err-bg: var(--err-soft); --toast-err-ink: var(--err); --toast-err-line: var(--err-line);
  --glass: rgba(29, 31, 59, .82);
  --glass-2: rgba(29, 31, 59, .94);
  --chip-ring: rgba(255, 255, 255, .10);
  --glow-1: rgba(151, 85, 237, .17);
  --glow-2: rgba(151, 85, 237, .10);
  --glow-3: rgba(242, 100, 63, .08);
  --panel-lip: #0e0f22;
  --card-lip: #0e0f22;
  --sticker: var(--surface-3);
  --sticker-new: #3b3219;
  --mia-ground: #262850;    /* the bunny's ground shadow: a soft step lighter than the page, never a bright blob */
  --mia-floor: rgba(0, 0, 0, .28);
  --switch-off: #3d416d;
  --knob: #ecebf5;
  --seg-bg: #15162f;
  --seg-on: #30335c;
  --tag-bg: #2a2d52;
  --tag-muted-bg: #23264a;
  --empty-ico: #5a5e8f;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3a0bf' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- tokens: light (Settings > Look > Light) ---------- */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #fff7ec;
  --bg-grown: #f6f4f9;
  --surface-2: #fbfafc;
  --surface: #fff;
  --surface-3: #f3f0f7;
  --field: #fff;
  --paper: #fffdf9;
  --cream: #fff7ec;

  --ink: #2b2340;
  --ink-2: #4a4263;
  --muted: #6f6886;
  --line: #ebe5f0;
  --line-2: #dcd4e6;
  --line-3: #c5bbd4;
  --field-line: #dcd4e6;

  --purple: #9755ed;
  --purple-700: #7436d0;
  --purple-press: #582891;
  --purple-deep: #582891;
  --purple-dark: #582891;
  --accent-text: #7436d0;
  --purple-soft: #f3ebfe;
  --purple-soft-2: #ebdefd;
  --purple-line: #e3d4fb;
  --purple-line-2: #d4bdf8;

  --coral: #f2643f;
  --coral-hi: #ff8a66;
  --coral-dark: #c4472a;
  --coral-soft: #ffe7de;
  --coral-line: #f3d3c4;
  --coral-ink: #c4472a;
  --sky: #4b96f0;
  --sky-dark: #2f6fc0;
  --sky-ink: #2f6fc0;
  --sun: #ffd66b;

  --ok: #23774c;   --ok-soft: #e4f5ec;   --ok-line: #b9e3cb;   --ok-fill: #23774c;
  --warn: #9a5a07; --warn-soft: #fff4e2; --warn-line: #f6d39d;
  --err: #b42b2b;  --err-soft: #fdecec;  --err-line: #f4c2c2;  --err-fill: #b42b2b; --err-fill-2: #962222;
  --info: #2f5f9e; --info-soft: #eaf2fd; --info-line: #c4daf6;

  --shadow-sm: 0 1px 2px rgba(43, 35, 64, .06), 0 1px 3px rgba(43, 35, 64, .06);
  --shadow: 0 1px 2px rgba(43, 35, 64, .05), 0 6px 20px rgba(43, 35, 64, .07);
  --shadow-lg: 0 4px 10px rgba(43, 35, 64, .06), 0 18px 48px rgba(43, 35, 64, .12);
  --focus-gap: #fff;
  --ring-soft: rgba(151, 85, 237, .22);

  --topbar-bg: rgba(255, 255, 255, .92);
  --backdrop: rgba(43, 35, 64, .42);
  --toast-bg: #2b2340;  --toast-ink: #fff;   --toast-line: transparent;
  --toast-ok-bg: #23774c; --toast-ok-ink: #fff; --toast-ok-line: transparent;
  --toast-err-bg: #b42b2b; --toast-err-ink: #fff; --toast-err-line: transparent;
  --glass: rgba(255, 255, 255, .7);
  --glass-2: rgba(255, 255, 255, .85);
  --chip-ring: rgba(255, 255, 255, .55);
  --glow-1: #ffe9c2;
  --glow-2: #f6e3ff;
  --glow-3: #ffe3d8;
  --panel-lip: #f6dccd;
  --card-lip: rgba(88, 40, 145, .08);
  --sticker: #fff7ec;
  --sticker-new: #fff3c9;
  --mia-ground: rgb(229, 222, 242);
  --mia-floor: rgba(88, 40, 145, .13);
  --switch-off: #d7d0e0;
  --knob: #fff;
  --seg-bg: #efecf3;
  --seg-on: #fff;
  --tag-bg: #f0edf4;
  --tag-muted-bg: #f3f1f5;
  --empty-ico: #c3b8d3;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f6886' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink); background: var(--bg);
       -webkit-tap-highlight-color: transparent; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
           clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ico { width: 1.25em; height: 1.25em; flex: none; }
.ico .knock { stroke: var(--knock, var(--surface)); }  /* the gap behind a slash in micOff / cloudOff */
::selection { background: var(--purple-soft-2); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; }
                 80% { transform: scale(.96); } 100% { transform: scale(1); } }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(242, 100, 63, .28); }
                     50% { box-shadow: 0 0 0 22px rgba(242, 100, 63, 0); } }

/* ---------- avatar chip (both looks) ---------- */
/* avatarChip() sets --chip-bg/--chip-ink (light look) and --chip-bg-d/--chip-ink-d (dark look). */
.chip { --chip-bg: var(--coral-soft); --chip-ink: var(--coral-ink);
        display: inline-grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 50%;
        background: var(--chip-bg-d, var(--chip-bg)); box-shadow: inset 0 0 0 3px var(--chip-ring);
        font-size: 26px; line-height: 1; user-select: none; -webkit-user-select: none; }
html[data-theme="light"] .chip { background: var(--chip-bg); }
.chip-sm { width: 32px; height: 32px; font-size: 18px; box-shadow: inset 0 0 0 2px var(--chip-ring); }
.chip-lg { width: 128px; height: 128px; font-size: 72px; box-shadow: inset 0 0 0 6px var(--chip-ring); }

/* =====================================================================
   CHILD LOOK
   ===================================================================== */
body.child, .child {
  font: 700 22px/1.35 var(--font-round);
  letter-spacing: .005em;
}
body.child {
  background:
    radial-gradient(60vmax 40vmax at 12% -8%, var(--glow-1) 0, transparent 60%),
    radial-gradient(50vmax 40vmax at 100% 105%, var(--glow-2) 0, transparent 60%),
    radial-gradient(40vmax 30vmax at 95% 10%, var(--glow-3) 0, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* One centred column for every child screen. */
.c-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
            justify-content: center; gap: 20px; text-align: center;
            padding: calc(96px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
                     calc(72px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
.c-screen > * { animation: fade-up .35s var(--ease) both; }
.c-mia { position: relative; display: grid; place-items: center; }
.c-mia::before { content: ""; position: absolute; left: 50%; bottom: 1%; width: 70%; height: 7%; transform: translateX(-50%);
                 border-radius: 50%; background: radial-gradient(closest-side, var(--mia-floor), transparent); }
.c-mia svg { position: relative; }
.c-title { margin: 0; font-size: clamp(30px, 6vw, 44px); line-height: 1.15; color: var(--purple-dark); letter-spacing: .01em; }
.c-line { margin: 0; font-size: clamp(22px, 4.4vw, 28px); color: var(--ink-2); max-width: 22ch; }
.c-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }

/* The big round Talk button. */
.c-talk { position: relative; display: grid; place-items: center; align-content: center; gap: 2px;
          width: 176px; height: 176px; border: 0; border-radius: 50%; padding: 0;
          background: radial-gradient(circle at 35% 28%, var(--coral-hi), var(--coral) 62%);
          color: var(--on-accent); font-size: 30px; letter-spacing: .02em;
          box-shadow: 0 9px 0 var(--coral-dark), 0 18px 36px rgba(196, 71, 42, .28);
          transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), filter var(--t);
          touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.c-talk::after { content: ""; position: absolute; inset: 0; border-radius: 50%; animation: breathe 2.8s ease-out infinite; }
.c-talk .ico { width: 68px; height: 68px; }
.c-talk:active { transform: translateY(7px); box-shadow: 0 2px 0 var(--coral-dark), 0 6px 14px rgba(196, 71, 42, .25); }
.c-talk:focus-visible { box-shadow: 0 9px 0 var(--coral-dark), 0 0 0 6px var(--focus-gap), 0 0 0 11px var(--purple); }
.c-talk:disabled { filter: saturate(.6) brightness(1.05); transform: none; }
.c-talk:disabled::after { animation: none; }

/* Big pill buttons: Home, Try again, practice choices. */
.c-btn { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 88px; min-width: 200px;
         padding: 14px 40px; border: 0; border-radius: var(--pill); background: var(--coral); color: var(--on-accent);
         font: inherit; font-size: 28px; text-decoration: none; letter-spacing: .02em;
         box-shadow: 0 7px 0 var(--coral-dark), 0 14px 28px rgba(196, 71, 42, .22);
         transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), filter var(--t);
         touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.c-btn .ico { width: 38px; height: 38px; }
.c-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--coral-dark), 0 4px 10px rgba(196, 71, 42, .2); }
.c-btn:focus-visible { box-shadow: 0 7px 0 var(--coral-dark), 0 0 0 5px var(--focus-gap), 0 0 0 10px var(--purple); }
.c-btn:disabled { opacity: .55; transform: none; filter: none; }
.c-btn-sky { background: var(--sky); box-shadow: 0 7px 0 var(--sky-dark), 0 14px 28px rgba(47, 111, 192, .22); }
.c-btn-sky:active { box-shadow: 0 2px 0 var(--sky-dark); }
.c-btn-sky:focus-visible { box-shadow: 0 7px 0 var(--sky-dark), 0 0 0 5px var(--focus-gap), 0 0 0 10px var(--purple); }
.c-btn-purple { background: var(--purple-700); box-shadow: 0 7px 0 var(--purple-deep), 0 14px 28px rgba(88, 40, 145, .22); }
.c-btn-purple:active { box-shadow: 0 2px 0 var(--purple-deep); }
.c-btn-purple:focus-visible { box-shadow: 0 7px 0 var(--purple-deep), 0 0 0 5px var(--focus-gap), 0 0 0 10px var(--purple); }
/* Quiet buttons for grown-ups on child screens (Skip, Stop, Hide). */
.c-btn-quiet { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 8px 20px;
               border: 2px solid var(--line-2); border-radius: var(--pill); background: var(--glass);
               color: var(--muted); font: inherit; font-size: 17px; text-decoration: none; touch-action: manipulation;
               transition: background var(--t), border-color var(--t), color var(--t); }
.c-btn-quiet:disabled { opacity: .5; }

/* The state badge under Mia: one icon and one word. */
.c-badge { display: inline-flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 28px 10px 18px;
           border-radius: var(--pill); background: var(--surface); color: var(--purple-dark); font-size: 26px;
           box-shadow: var(--shadow), inset 0 0 0 2px var(--purple-line); transition: background .3s, color .3s; }
.c-badge .ico { width: 40px; height: 40px; }
.c-badge[data-state="listening"] { background: var(--purple-soft); }
.c-badge[data-state="talking"] { background: var(--coral-soft); color: var(--coral-ink);
                                 box-shadow: var(--shadow), inset 0 0 0 2px var(--coral-line); }
.c-badge[data-state="calling"] .ico, .c-badge[data-state="thinking"] .ico { animation: dots-fade 1.2s ease-in-out infinite; }
@keyframes dots-fade { 50% { opacity: .45; } }

/* Corners: switch child (left), grown-up helping (right), End talk (bottom left), Grown-ups (bottom right). */
.c-corner { position: fixed; top: calc(12px + env(safe-area-inset-top)); z-index: 5; display: flex; gap: 8px; }
.c-corner-left { left: calc(12px + env(safe-area-inset-left)); }
.c-corner-right { right: calc(12px + env(safe-area-inset-right)); }
.c-switch { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 50%; text-decoration: none;
            transition: transform var(--t) var(--ease); touch-action: manipulation; }
.c-switch .chip { width: 68px; height: 68px; font-size: 38px; box-shadow: var(--shadow), inset 0 0 0 4px var(--chip-ring); }
.c-switch:active { transform: scale(.95); }
.c-help { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 18px 8px 14px;
          border: 2px solid var(--purple-line); border-radius: var(--pill); background: var(--glass-2);
          color: var(--accent-text); font: 600 15px/1.2 var(--font-ui); box-shadow: var(--shadow-sm); touch-action: manipulation;
          transition: background var(--t), border-color var(--t); font-variant-numeric: tabular-nums; }
.c-help .ico { width: 22px; height: 22px; }
.c-help.on { background: var(--purple-soft); border-color: var(--purple); color: var(--purple-dark); }
.c-endlink, .c-grownups { position: fixed; bottom: calc(6px + env(safe-area-inset-bottom)); z-index: 5;
                          display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 12px;
                          border: 0; background: none; color: var(--muted);
                          font: 500 14px/1.2 var(--font-ui); text-decoration: underline; text-underline-offset: 3px;
                          border-radius: var(--r-sm); touch-action: manipulation; }
.c-endlink { left: calc(6px + env(safe-area-inset-left)); }
.c-grownups { right: calc(6px + env(safe-area-inset-right)); text-decoration: none; }
.c-grownups .ico { width: 18px; height: 18px; }
.c-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); font: 500 15px/1.4 var(--font-ui);
          text-underline-offset: 3px; border-radius: var(--r-sm); padding: 6px 8px; }

/* Stickers: each on a chip a step lighter than the shelf, so the emoji reads on the dark look. */
.c-new-sticker { display: grid; place-items: center; width: 148px; height: 148px; border-radius: 50%; background: var(--surface-3);
                 font-size: 84px; line-height: 1; box-shadow: var(--shadow-lg), inset 0 0 0 6px var(--sun);
                 animation: pop .7s var(--ease) .25s both; }
.c-shelf { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: min(560px, 100%); margin: 0;
           padding: 16px; border-radius: var(--r-xl); background: var(--glass);
           box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--line); list-style: none; }
html[data-theme="light"] .c-shelf { box-shadow: var(--shadow-sm), inset 0 0 0 2px rgba(255, 255, 255, .9); }
.c-sticker { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--sticker);
             font-size: 30px; line-height: 1; }
.c-sticker.is-new { background: var(--sticker-new); box-shadow: inset 0 0 0 3px var(--sun); }

/* Problem screens: a big picture, Mia's short line, "get a grown-up", Try again, a small detail for the grown-up. */
.c-art { --knock: var(--surface); display: grid; place-items: center; width: 168px; height: 168px; border-radius: 50%;
         background: var(--surface); color: var(--purple); box-shadow: var(--shadow-lg), inset 0 0 0 6px var(--purple-soft); }
.c-art .ico { width: 92px; height: 92px; }
.c-askgrownup { display: inline-flex; align-items: center; gap: 14px; padding: 10px 24px 10px 14px;
                border-radius: var(--pill); background: var(--purple-soft); color: var(--purple-dark); font-size: 22px; }
.c-askgrownup .ico { width: 52px; height: 52px; padding: 6px; border-radius: 50%; background: var(--surface); }
.c-detail { margin: 0; max-width: 52ch; color: var(--muted); font: 400 14px/1.5 var(--font-ui); }

/* Panels and cards (picker, practice). */
.c-panel { width: min(560px, 100%); padding: 32px 28px; border-radius: var(--r-2xl); background: var(--paper);
           box-shadow: 0 10px 0 var(--panel-lip), var(--shadow-lg); }
html:not([data-theme="light"]) .c-panel { box-shadow: 0 10px 0 var(--panel-lip), inset 0 0 0 1px var(--line); }
.c-picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; width: min(920px, 100%); padding: 0; margin: 0;
            list-style: none; }
.c-card { --chip-bg: var(--coral-soft); --chip-ink: var(--coral-ink);
          display: flex; flex-direction: column; align-items: center; gap: 14px; width: 196px; min-height: 216px;
          padding: 24px 16px 20px; border-radius: var(--r-2xl); background: var(--surface); color: var(--chip-ink-d, var(--chip-ink));
          text-decoration: none; font-size: 26px; box-shadow: 0 8px 0 var(--card-lip), inset 0 0 0 1px var(--line);
          transition: transform .2s var(--ease), box-shadow .2s var(--ease); touch-action: manipulation;
          -webkit-tap-highlight-color: transparent; }
html[data-theme="light"] .c-card { color: var(--chip-ink); box-shadow: 0 8px 0 var(--card-lip), var(--shadow); }
.c-card .chip { width: 128px; height: 128px; font-size: 72px; box-shadow: inset 0 0 0 6px var(--chip-ring); }
.c-card span.name { max-width: 100%; overflow-wrap: anywhere; }
.c-card:active, .c-card.is-pressed { transform: translateY(4px) scale(.98); }
.c-card:focus-visible { box-shadow: 0 8px 0 var(--card-lip), 0 0 0 5px var(--focus-gap), 0 0 0 10px var(--purple); }

/* Hover lifts only where there is a real pointer (no sticky hover after a tap). */
@media (hover: hover) {
  .c-talk:hover, .c-btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
  .c-btn-quiet:hover { background: var(--surface); border-color: var(--purple-line); color: var(--purple-dark); }
  .c-switch:hover { transform: scale(1.05); }
  .c-help:hover { background: var(--surface); border-color: var(--purple); }
  .c-endlink:hover, .c-grownups:hover { color: var(--ink); }
  .c-link:hover { color: var(--accent-text); }
  .c-card:hover { transform: translateY(-4px); }
}

@media (max-width: 520px) {
  body.child, .child { font-size: 20px; }
  .c-screen { gap: 16px; padding-top: calc(88px + env(safe-area-inset-top)); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .c-picker { gap: 16px; }
  .c-card { width: calc(50% - 8px); min-width: 140px; min-height: 184px; padding: 20px 10px 16px; font-size: 22px; }
  .c-card .chip { width: 100px; height: 100px; font-size: 56px; }
  .c-btn { min-width: 0; padding: 12px 32px; font-size: 26px; }
  .c-panel { padding: 24px 18px; border-radius: var(--r-xl); }
  .c-new-sticker { width: 124px; height: 124px; font-size: 70px; }
  .c-sticker { width: 46px; height: 46px; font-size: 26px; }
  .c-badge { font-size: 24px; min-height: 60px; }
}
@media (max-width: 380px) {
  .c-card { min-width: 0; width: calc(50% - 8px); }
  .c-card .chip { width: 88px; height: 88px; font-size: 50px; }
}

/* =====================================================================
   GROWN-UP LOOK
   ===================================================================== */
body.grown { background: var(--bg-grown); }
html:has(body.grown) { background: var(--bg-grown); }
.grown { font: 400 16px/1.55 var(--font-ui); color: var(--ink); }
.grown h1, .grown h2, .grown h3 { color: var(--ink); line-height: 1.25; margin: 0; }
.grown h1 { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.grown h2 { font-size: 19px; font-weight: 650; }
.grown h3 { font-size: 16px; font-weight: 650; }
.grown p { margin: 0; }
.grown a { color: var(--accent-text); text-underline-offset: 2px; }
.grown a:hover { color: var(--purple-dark); }
.grown .lede { color: var(--ink-2); font-size: 17px; max-width: 62ch; }
.grown .muted { color: var(--muted); }
.grown .small { font-size: 14px; }
.grown .mono { font-family: var(--font-mono); font-size: .92em; }
.grown .nowrap { white-space: nowrap; }
.grown .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--topbar-bg); border-bottom: 1px solid var(--line);
          padding-top: env(safe-area-inset-top);
          backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); }
.topbar-in { display: flex; align-items: center; gap: 20px; max-width: 1120px; margin: 0 auto; min-height: 64px;
             padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left)); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink) !important; font-weight: 700; font-size: 17px;
         text-decoration: none; white-space: nowrap; min-height: 44px; }
.brand img, .brand svg { width: 32px; height: 32px; }
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav a { padding: 8px 12px; border-radius: var(--r-sm); color: var(--ink-2) !important; text-decoration: none; font-size: 15px;
         font-weight: 500; transition: background var(--t), color var(--t); }
.nav a:hover { background: var(--surface-3); color: var(--ink) !important; }
.nav a[aria-current="page"] { background: var(--purple-soft); color: var(--purple-dark) !important; font-weight: 600; }
.nav-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-who { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 4px; }
.nav-toggle { display: none; }

/* Layout */
.page { max-width: 880px; margin: 0 auto;
        padding: 32px max(20px, env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
body > main.page:first-child { padding-top: calc(32px + env(safe-area-inset-top)); }  /* no top bar above it (setup) */
.page-wide { max-width: 1120px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin: 0 0 24px; }
.page-head > div { display: grid; gap: 6px; min-width: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stack { display: grid; gap: 16px; }
.stack > * { min-width: 0; }
.stack-sm { display: grid; gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.spacer { flex: 1; }
.grid-2, .grid-3 { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 680px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page { padding-top: 24px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
          padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
  .grown h1 { font-size: 24px; }
}

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.stack > .card + .card, .grid-2 > .card + .card, .grid-3 > .card + .card { margin-top: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 0 0 14px; }
.card-foot { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px -22px -20px; padding: 14px 22px; border-top: 1px solid var(--line);
             background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card.muted-card { background: var(--surface-2); box-shadow: none; }
.box { padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.section-title { margin: 28px 0 10px !important; font-size: 13px !important; font-weight: 650 !important; letter-spacing: .07em;
                 text-transform: uppercase; color: var(--muted) !important; }
@media (max-width: 520px) {
  .card { padding: 18px 16px; }
  .card-foot { margin: 16px -16px -18px; padding: 12px 16px; }
}

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 18px;
       border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--ink) !important;
       font: 600 15px/1.2 var(--font-ui); text-decoration: none; white-space: nowrap; cursor: pointer; touch-action: manipulation;
       box-shadow: var(--shadow-sm); transition: background var(--t), border-color var(--t), box-shadow var(--t), transform .08s; }
.btn:hover { background: var(--surface-3); border-color: var(--line-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; box-shadow: none; }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--purple-700); border-color: var(--purple-700); color: var(--on-accent) !important; }
.btn-primary:hover { background: var(--purple-press); border-color: var(--purple-press); }
.btn-secondary { background: var(--purple-soft); border-color: var(--purple-line); color: var(--purple-dark) !important; box-shadow: none; }
.btn-secondary:hover { background: var(--purple-soft-2); border-color: var(--purple-line-2); }
.btn-danger { background: var(--surface); border-color: var(--err-line); color: var(--err) !important; }
.btn-danger:hover { background: var(--err-soft); border-color: var(--err); }
.btn-danger.btn-solid { background: var(--err-fill); border-color: var(--err-fill); color: #fff !important; }
.btn-danger.btn-solid:hover { background: var(--err-fill-2); border-color: var(--err-fill-2); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2) !important; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-link { min-height: 0; padding: 2px 4px; border: 0; background: none; box-shadow: none; color: var(--accent-text) !important;
            text-decoration: underline; text-underline-offset: 2px; font-weight: 500; }
.btn-link:hover { background: none; color: var(--purple-dark) !important; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: var(--r-sm); }
.btn-lg { min-height: 50px; padding: 12px 24px; font-size: 16px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: 0; width: 42px; }
.btn-icon.btn-sm { width: 34px; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor;
                   border-color: var(--line-2) var(--line-2) var(--accent-text) var(--accent-text); animation: spin .7s linear infinite; }
.btn-primary.busy::after, .btn-solid.busy::after { border-color: rgba(255, 255, 255, .4) rgba(255, 255, 255, .4) #fff #fff; }
/* Touch screens and phones: every grown-up target at least 44 px. */
@media (max-width: 760px), (pointer: coarse) {
  .btn, .btn-sm { min-height: 44px; }
  .btn-icon, .btn-icon.btn-sm { width: 44px; }
  .btn-link { min-height: 44px; }
}

/* Forms */
.field { display: grid; gap: 6px; margin: 0 0 18px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > .label, fieldset.fieldset > legend { font-weight: 600; font-size: 15px; color: var(--ink); }
.field .optional { font-weight: 400; color: var(--muted); font-size: 14px; }
.grown input[type="text"], .grown input[type="number"], .grown input[type="password"], .grown input[type="email"],
.grown input[type="search"], .grown input[type="tel"], .grown input:not([type]), .grown select, .grown textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--field-line); border-radius: var(--r);
  background: var(--field); color: var(--ink); font: 400 16px/1.4 var(--font-ui);
  transition: border-color var(--t), box-shadow var(--t); }
.grown input::placeholder, .grown textarea::placeholder { color: var(--muted); opacity: .8; }
.grown textarea { min-height: 96px; resize: vertical; }
.grown select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
.grown select option { background: var(--surface); color: var(--ink); }
.grown input:hover, .grown select:hover, .grown textarea:hover { border-color: var(--line-3); }
.grown input:focus, .grown select:focus, .grown textarea:focus { outline: none; border-color: var(--purple);
                                                              box-shadow: 0 0 0 3px var(--ring-soft); }
.grown input:disabled, .grown select:disabled, .grown textarea:disabled { background: var(--surface-2); color: var(--muted);
                                                                         border-color: var(--line-2); }
.field .hint { color: var(--muted); font-size: 14px; }
.field .error { display: none; color: var(--err); font-size: 14px; font-weight: 500; }
.field.invalid .error { display: block; }
.field.invalid input, .field.invalid select, .field.invalid textarea, .grown [aria-invalid="true"] {
  border-color: var(--err); box-shadow: 0 0 0 3px rgba(220, 70, 70, .16); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.input-suffix { display: flex; align-items: center; gap: 8px; }
.input-suffix input { max-width: 120px; }
fieldset.fieldset { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
fieldset.fieldset > legend { padding: 0; margin: 0 0 8px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 15px; line-height: 1.45; min-height: 24px; }
.check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--purple-700); cursor: pointer; }
.radio-list { display: grid; gap: 10px; }
.radio-list .check { padding: 6px 0; }

/* Segmented control */
.seg { display: inline-flex; flex-wrap: wrap; padding: 4px; gap: 4px; border-radius: var(--r); background: var(--seg-bg);
       border: 1px solid var(--line); max-width: 100%; }
.seg label, .seg button { position: relative; display: inline-flex; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span, .seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; min-width: 52px;
                         padding: 6px 16px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2);
                         font: 600 15px/1.2 var(--font-ui); touch-action: manipulation;
                         transition: background var(--t), color var(--t), box-shadow var(--t); }
.seg label:hover span, .seg button:hover { color: var(--ink); }
.seg input:checked + span, .seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--purple-dark);
                                                              box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--purple-line); }
html[data-theme="light"] .seg input:checked + span, html[data-theme="light"] .seg button[aria-pressed="true"] { box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { box-shadow: var(--focus); }
.seg input:disabled + span { opacity: .5; cursor: default; }
@media (max-width: 760px), (pointer: coarse) { .seg span, .seg button { min-height: 44px; } }

/* Choice cards (animal / colour pickers) */
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice-face { display: grid; place-items: center; width: 64px; height: 64px; border-radius: var(--r-lg); border: 2px solid var(--line-2);
               background: var(--surface-3); font-size: 34px; transition: border-color var(--t), box-shadow var(--t), transform var(--t); }
html[data-theme="light"] .choice-face { background: #fff; border-color: var(--line); }
.choice:hover .choice-face { border-color: var(--line-3); transform: translateY(-1px); }
.choice input:checked + .choice-face { border-color: var(--purple); background: var(--purple-soft);
                                       box-shadow: 0 0 0 3px var(--ring-soft); }
.choice input:focus-visible + .choice-face { box-shadow: var(--focus); }
.swatch { display: block; width: 36px; height: 36px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
          background: var(--chip-bg-d, var(--chip-bg)); }  /* paintColour(): the chip's colour in this look */
html[data-theme="light"] .swatch { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); background: var(--chip-bg); }

/* Tables: they scroll inside their wrapper on a narrow screen. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; border: 1px solid var(--line);
              border-radius: var(--r-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .02em; background: var(--surface-2);
            padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.is-muted td { color: var(--muted); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px 16px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list-item:first-child { border-top: 0; }
li:first-child > .list-item { border-top: 0; }
.list > li + li > .list-item { border-top: 1px solid var(--line); }
.list-main { flex: 1; min-width: 180px; display: grid; gap: 2px; }
.list-title { font-weight: 600; }
.list-meta { color: var(--muted); font-size: 14px; }
.list-actions { display: flex; flex-wrap: wrap; gap: 6px; }
a.list-item { color: inherit !important; text-decoration: none; transition: background var(--t); }
a.list-item:hover { background: var(--surface-2); }
@media (max-width: 520px) { .list-main { min-width: 0; } .list-item { padding: 14px 16px; } }

/* Tags */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--pill); font-size: 12.5px;
       font-weight: 600; line-height: 1.6; background: var(--tag-bg); color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.tag-ok { background: var(--ok-soft); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-line); }
.tag-warn { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-line); }
.tag-danger { background: var(--err-soft); color: var(--err); box-shadow: inset 0 0 0 1px var(--err-line); }
.tag-accent { background: var(--purple-soft); color: var(--purple-dark); box-shadow: inset 0 0 0 1px var(--purple-line); }
.tag-muted { background: var(--tag-muted-bg); color: var(--muted); }
html[data-theme="light"] .tag { box-shadow: none; }

/* Notices and status */
.notice { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--info-line);
          background: var(--info-soft); color: var(--info); font-size: 15px; }
.notice strong { font-weight: 650; }
.notice p { color: var(--ink-2); }
.notice a { color: inherit; font-weight: 600; }
.notice-ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.notice-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.notice-error { background: var(--err-soft); border-color: var(--err-line); color: var(--err); }
.status { min-height: 1.5em; font-size: 14px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50; max-width: calc(100% - 32px);
         padding: 12px 18px; border-radius: var(--r); background: var(--toast-bg); color: var(--toast-ink);
         border: 1px solid var(--toast-line); font: 500 15px/1.4 var(--font-ui); box-shadow: var(--shadow-lg);
         opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .2s, transform .2s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { background: var(--toast-ok-bg); color: var(--toast-ok-ink); border-color: var(--toast-ok-line); }
.toast-err { background: var(--toast-err-bg); color: var(--toast-err-ink); border-color: var(--toast-err-line); }

/* Modal */
dialog.modal { width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
               overflow: auto; overscroll-behavior: contain; padding: 24px; border: 1px solid var(--line-2); border-radius: var(--r-lg);
               background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); font: 400 16px/1.55 var(--font-ui); }
html[data-theme="light"] dialog.modal { border-color: transparent; }
dialog.modal[open] { animation: fade-up .2s var(--ease); }
dialog.modal::backdrop { background: var(--backdrop); }
dialog.modal h2 { margin: 0 0 8px; font-size: 20px; }
dialog.modal p { margin: 0 0 12px; color: var(--ink-2); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }
@media (max-width: 420px) { dialog.modal { padding: 20px 18px; } .modal-actions .btn { flex: 1 1 auto; } }

/* Empty state */
.empty { display: grid; justify-items: center; gap: 10px; padding: 36px 16px; text-align: center; color: var(--muted); }
.empty .ico, .empty svg { width: 44px; height: 44px; color: var(--empty-ico); }

/* PIN pad */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 8px 0 20px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-3); transition: background var(--t), border-color var(--t); }
.pin-dots span.on { background: var(--purple); border-color: var(--purple); }
.pinpad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; justify-content: center; }
.pinpad button { height: 64px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface-3); font: 600 24px/1 var(--font-ui);
                 color: var(--ink); box-shadow: var(--shadow-sm); touch-action: manipulation; transition: background var(--t), transform .08s; }
html[data-theme="light"] .pinpad button { background: #fff; border-color: var(--line); }
.pinpad button:hover { background: var(--purple-soft); }
html[data-theme="light"] .pinpad button:hover { background: #f8f6fb; }
.pinpad button:active { transform: scale(.96); background: var(--purple-soft); }
.pinpad .pin-wide { grid-column: span 2; font-size: 15px; }

/* Child switcher under the top bar (parent.js): one pill per child, the chosen one marked */
.kids { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -8px 0 24px; }
.kids-label { color: var(--muted); font-size: 14px; font-weight: 500; margin-right: 2px; }
.kid { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; min-height: 44px; padding: 4px 14px 4px 6px;
       border: 1px solid var(--line-2); border-radius: var(--pill); background: var(--surface); color: var(--ink-2) !important;
       font-size: 15px; font-weight: 500; text-decoration: none; transition: background var(--t), border-color var(--t); }
.kid:hover { border-color: var(--line-3); background: var(--surface-3); }
.kid[aria-current="true"] { border-color: var(--purple); background: var(--purple-soft); color: var(--purple-dark) !important;
                            font-weight: 650; box-shadow: inset 0 0 0 1px var(--purple); }
.brand-mia { display: grid; place-items: center; width: 32px; height: 36px; overflow: hidden; }
.brand-mia svg { width: 24px !important; height: 36px !important; }
.btn.nav-toggle { display: none; }
@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; gap: 8px 12px; padding-top: 8px; padding-bottom: 8px; min-height: 60px;
               padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .btn.nav-toggle { display: inline-flex; margin-left: auto; }
  .nav { display: none; order: 3; width: 100%; flex-direction: column; align-items: stretch; gap: 2px; padding: 4px 0 8px;
         border-top: 1px solid var(--line); }
  .topbar.open .nav { display: flex; }
  .nav a { padding: 12px; min-height: 44px; display: flex; align-items: center; }
  .nav-end { order: 4; width: 100%; display: none; flex-wrap: wrap; padding: 0 0 12px; }
  .topbar.open .nav-end { display: flex; }
  .nav-end .btn { flex: 1 1 auto; }
  .nav-who { flex-basis: 100%; padding: 2px 4px 4px; }
  .nav-who::before { content: "Logged in as "; }
}

/* Switch (an on/off checkbox): label.switch > input[type=checkbox] + span.switch-track + span (text) */
.switch { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; flex: none; width: 46px; height: 28px; border-radius: var(--pill); background: var(--switch-off);
                transition: background var(--t); }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
                       background: var(--knob); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform var(--t) var(--ease); }
.switch input:checked + .switch-track { background: var(--purple-700); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }
.switch input:disabled + .switch-track { opacity: .5; }

/* Wrong PIN: a gentle shake (.shake, removed after) */
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.shake { animation: shake .4s ease-in-out; }

/* Profile form (parent.js profileForm, used by setup and Children) */
.grown a.c-btn, .grown a.c-btn:hover { color: var(--on-accent); }  /* a child button on a grown-up page (setup, gate) */
.field { align-content: start; }
.field-row > .field:last-child { margin-bottom: 18px; }
.grown select { height: 44px; }
fieldset.fieldset > .seg { justify-self: start; }
.form-sec + .form-sec { margin-top: 8px; padding-top: 22px; border-top: 1px solid var(--line); }
.form-sec-title { margin: 0 0 16px !important; font-size: 13px !important; font-weight: 650 !important; letter-spacing: .07em;
                  text-transform: uppercase; color: var(--muted) !important; }
.field-row.pair { gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 32px; }
.pick > div { flex: 1 1 300px; min-width: 0; }
.pick-preview { display: grid; justify-items: center; gap: 8px; min-width: 140px; padding: 16px; margin: 0 auto 18px;
                border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line); }
.pick-name { font-weight: 650; max-width: 160px; overflow-wrap: anywhere; text-align: center; }

/* Privacy text (setup and the Privacy page) */
.privacy-sec { display: grid; gap: 8px; }
.privacy-sec + .privacy-sec { margin-top: 22px; }
.privacy-sec h2 { font-size: 17px; }
.privacy-sec ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-2); }
.privacy-sec p { color: var(--ink-2); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
                           transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .c-talk::after { animation: none; }
  .c-talk:active, .c-btn:active, .c-card:active, .c-card:hover, .c-talk:hover, .c-btn:hover { transform: none; }
}
