/* ============================================================================
   WOVEN — the Coach for Children design language.
   Hand-stitched storybook warmth for parents; meadow-bright practice space
   for kids. No borrowed theme, no icon fonts: every glyph and buddy is drawn
   for this product (see artwork.js).
   ========================================================================== */

:root {
  /* palette: meadow at dusk */
  --paper: #f5efe2;
  --parchment: #faf6ec;
  --card: #fffdf8;
  --ink: #23372e;
  --ink-soft: #48594f;
  --ink-faint: #71806f;
  --pine: #2e5140;
  --pine-deep: #223d30;
  --moss: #4e7a62;
  --sage: #9db8a5;
  --sage-wash: #e3ecdf;
  --clay: #c26e4d;
  --clay-deep: #a85a3c;
  --apricot: #e5a177;
  --apricot-wash: #f6e3d0;
  --dusk: #7c6f94;
  --dusk-wash: #e9e4f0;
  --sun: #d9a441;
  --sun-wash: #f4e7c8;
  --berry: #a34f5b;
  --ok: #47775c;
  --warn: #b07a2a;
  --danger: #a44c36;
  --danger-wash: #f2ded6;

  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-body: "Segoe UI", "Avenir Next", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", Consolas, "SF Mono", monospace;

  --radius-card: 16px 20px 16px 20px;
  --radius-soft: 12px;
  --shadow-card: 0 1px 2px rgba(35, 55, 46, 0.06), 0 6px 18px -8px rgba(35, 55, 46, 0.18);
  --shadow-pop: 0 2px 4px rgba(35, 55, 46, 0.08), 0 16px 40px -12px rgba(35, 55, 46, 0.28);
  --stitch: 2px dashed rgba(46, 81, 64, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(46, 81, 64, 0.022) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(90deg, rgba(46, 81, 64, 0.022) 0 1px, transparent 1px 7px),
    var(--paper);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.005em; color: var(--pine-deep); }
/* every drawn glyph is inline-sized by default; context rules may override */
svg.ico { width: 19px; height: 19px; vertical-align: -3.5px; margin-right: 2px; flex: none; }
h1 { font-size: 1.9rem; margin: 0 0 0.35rem; }
h2 { font-size: 1.35rem; margin: 0 0 0.4rem; }
h3 { font-size: 1.06rem; margin: 0 0 0.3rem; }
p { margin: 0.35rem 0; }
a { color: var(--moss); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; }

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--clay-deep);
}
.muted { color: var(--ink-faint); }
.small { font-size: 0.85rem; }

/* ---- boot splash ---------------------------------------------------------- */
.boot-splash { min-height: 100vh; display: grid; place-content: center; text-align: center; color: var(--ink-faint); }
.boot-mark { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: var(--pine); position: relative; animation: bootBob 1.6s ease-in-out infinite; }
.boot-mark::after { content: ""; position: absolute; left: 50%; top: -12px; width: 22px; height: 20px; background: var(--moss); border-radius: 0 100% 0 100%; transform: rotate(-18deg); }
@keyframes bootBob { 50% { transform: translateY(-6px); } }

/* ---- app frame ------------------------------------------------------------ */
.frame { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.rail {
  background: linear-gradient(180deg, var(--pine-deep), var(--pine) 60%, #35604b);
  color: #f2ede0;
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.wordmark { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.wordmark svg { width: 38px; height: 38px; flex: none; }
.wordmark .wm-name { font-family: var(--font-display); font-size: 1.02rem; line-height: 1.2; }
.wordmark .wm-sub { font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.65; }

.rail-label { font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.55; padding: 12px 10px 4px; }
.rail a.nav-item {
  display: flex; align-items: center; gap: 10px;
  color: #e9e2cf; text-decoration: none;
  padding: 8px 10px; border-radius: 10px; font-size: 0.92rem;
  border: 1px solid transparent;
}
.rail a.nav-item svg { width: 20px; height: 20px; opacity: 0.85; }
.rail a.nav-item:hover { background: rgba(250, 246, 236, 0.08); }
.rail a.nav-item.active { background: rgba(250, 246, 236, 0.14); border-color: rgba(250, 246, 236, 0.22); color: #fff; }
.rail .rail-foot { margin-top: auto; padding: 10px; font-size: 0.78rem; opacity: 0.75; }
.rail .rail-user { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px dashed rgba(250, 246, 236, 0.25); }

.main { padding: 26px 34px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* ---- cards / panels -------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid rgba(46, 81, 64, 0.14);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
}
.card.stitched { position: relative; }
.card.stitched::before {
  content: ""; position: absolute; inset: 6px; pointer-events: none;
  border: var(--stitch); border-radius: 12px 16px 12px 16px; opacity: 0.55;
}
.card-grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, 1fr); } .frame { grid-template-columns: 200px 1fr; } }
@media (max-width: 720px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } .frame { grid-template-columns: 1fr; } .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .main { padding: 18px; } }

.tile { text-align: left; }
.tile .tile-num { font-family: var(--font-display); font-size: 1.9rem; color: var(--pine-deep); line-height: 1.1; }
.tile .tile-cap { font-size: 0.8rem; color: var(--ink-faint); }

.divider { border: 0; border-top: var(--stitch); margin: 14px 0; }

/* ---- chips / badges --------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 10px; border-radius: 999px;
  border: 1.5px dashed transparent;
}
.chip svg { width: 13px; height: 13px; }
.chip.ok { background: var(--sage-wash); color: var(--ok); border-color: rgba(71, 119, 92, 0.4); }
.chip.warn { background: var(--sun-wash); color: var(--warn); border-color: rgba(176, 122, 42, 0.4); }
.chip.danger { background: var(--danger-wash); color: var(--danger); border-color: rgba(164, 76, 54, 0.4); }
.chip.info { background: var(--dusk-wash); color: var(--dusk); border-color: rgba(124, 111, 148, 0.4); }
.chip.plain { background: rgba(46, 81, 64, 0.07); color: var(--ink-soft); border-color: rgba(46, 81, 64, 0.2); }

/* ---- buttons ----------------------------------------------------------------- */
.btn {
  font-family: var(--font-body); font-size: 0.9rem; font-weight: 600;
  border-radius: 999px; padding: 8px 18px; cursor: pointer;
  border: 1.5px solid var(--pine); background: var(--pine); color: #f7f2e4;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform 0.06s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--pine-deep); box-shadow: 0 4px 14px -6px rgba(34, 61, 48, 0.5); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: transparent; color: var(--pine); border-style: dashed; }
.btn.secondary:hover { background: rgba(46, 81, 64, 0.07); box-shadow: none; }
.btn.clay { background: var(--clay); border-color: var(--clay); }
.btn.clay:hover { background: var(--clay-deep); }
.btn.danger { background: transparent; border: 1.5px dashed var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger-wash); }
.btn.big { font-size: 1.05rem; padding: 12px 26px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---- forms --------------------------------------------------------------------- */
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--parchment);
  border: 1px solid rgba(46, 81, 64, 0.25); border-radius: 10px;
  padding: 9px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(78, 122, 98, 0.18); }
.check { display: flex; gap: 8px; align-items: center; font-size: 0.92rem; margin: 8px 0; }
.check input { width: auto; }

/* ---- tables ---------------------------------------------------------------------- */
table.woven { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.woven th {
  text-align: left; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 700; padding: 8px 10px; border-bottom: 2px solid rgba(46, 81, 64, 0.18);
}
table.woven td { padding: 9px 10px; border-bottom: 1px dashed rgba(46, 81, 64, 0.16); vertical-align: top; }
table.woven tr:hover td { background: rgba(157, 184, 165, 0.1); }
table.woven .num { font-family: var(--font-mono); font-size: 0.84rem; }

/* ---- meters ------------------------------------------------------------------------ */
.meter { margin: 8px 0; }
.meter .meter-line { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 3px; }
.meter .meter-track { height: 8px; border-radius: 6px; background: rgba(46, 81, 64, 0.12); overflow: hidden; }
.meter .meter-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--moss), var(--sage)); }
.meter.hot .meter-fill { background: linear-gradient(90deg, var(--clay), var(--apricot)); }

/* ---- login ---------------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 46%) 1fr; }
@media (max-width: 900px) { .login-wrap { grid-template-columns: 1fr; } .login-meadow { display: none; } }
.login-panel { padding: 48px 54px; display: flex; flex-direction: column; justify-content: center; max-width: 560px; }
.login-meadow {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, #2c4c3c 0%, #35604b 42%, #4e7a62 78%, #7fa08c 100%);
  display: grid; place-items: center;
}
.login-meadow .meadow-buddy { width: min(46vh, 380px); filter: drop-shadow(0 24px 40px rgba(20, 36, 28, 0.45)); }
.login-meadow .meadow-quote { position: absolute; bottom: 40px; left: 40px; right: 40px; color: #efe9d8; font-family: var(--font-display); font-size: 1.05rem; opacity: 0.9; }
.login-tabs { display: flex; gap: 8px; margin: 18px 0 6px; }
.login-tabs button {
  font: inherit; font-weight: 600; cursor: pointer; padding: 7px 16px; border-radius: 999px;
  border: 1.5px dashed rgba(46, 81, 64, 0.35); background: transparent; color: var(--ink-soft);
}
.login-tabs button.active { background: var(--pine); border-color: var(--pine); color: #f7f2e4; }
.demo-strip { margin-top: 18px; padding: 12px 14px; border-radius: 12px; background: var(--dusk-wash); border: 1px dashed rgba(124, 111, 148, 0.5); font-size: 0.83rem; }
.demo-strip button { font: inherit; font-size: 0.8rem; border: 0; background: none; color: var(--dusk); font-weight: 700; cursor: pointer; text-decoration: underline dashed; text-underline-offset: 3px; padding: 0 4px; }

/* ---- child cards on the dashboard --------------------------------------------------------- */
.child-card { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; }
.child-card .mini-buddy { width: 96px; height: 104px; }
.child-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ---- buddy stage + avatar states (PRD-required states) -------------------------------------- */
.buddy-stage { position: relative; display: grid; place-items: center; }
.buddy-stage svg.buddy { width: 100%; height: auto; display: block; }
.buddy-stage .state-banner {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 4px 14px; border-radius: 999px; border: 1.5px dashed transparent;
}
.state-ready .state-banner { background: var(--sage-wash); color: var(--ok); border-color: rgba(71,119,92,.4); }
.state-listening .state-banner { background: var(--dusk-wash); color: var(--dusk); border-color: rgba(124,111,148,.4); }
.state-thinking .state-banner { background: var(--sun-wash); color: var(--warn); border-color: rgba(176,122,42,.35); }
.state-speaking .state-banner { background: var(--apricot-wash); color: var(--clay-deep); border-color: rgba(194,110,77,.4); }
.state-calm .state-banner { background: #e3edea; color: var(--pine); border-color: rgba(46,81,64,.35); }
.state-encourage .state-banner { background: var(--apricot-wash); color: var(--clay-deep); border-color: rgba(194,110,77,.4); }
.state-help .state-banner, .state-safety .state-banner { background: var(--danger-wash); color: var(--danger); border-color: rgba(164,76,54,.5); }
.state-ending .state-banner { background: var(--sun-wash); color: var(--warn); border-color: rgba(176,122,42,.45); }
.state-privacy .state-banner { background: rgba(46,81,64,.08); color: var(--ink-soft); border-color: rgba(46,81,64,.3); }

/* buddy motion */
.buddy .g-body { transform-origin: 120px 170px; }
.state-ready .g-body { animation: buddyBob 3.2s ease-in-out infinite; }
.state-speaking .g-body { animation: buddyBob 1.4s ease-in-out infinite; }
.state-calm .g-body { animation: buddyBreathe 4.6s ease-in-out infinite; }
.state-encourage .g-body { animation: buddyHop 0.9s ease-in-out 2; }
@keyframes buddyBob { 50% { transform: translateY(-5px); } }
@keyframes buddyBreathe { 50% { transform: scale(1.045); } }
@keyframes buddyHop { 40% { transform: translateY(-14px) rotate(-2deg); } }

.buddy .g-ripples circle { opacity: 0; }
.state-listening .g-ripples circle { animation: ripple 2s ease-out infinite; }
.state-listening .g-ripples circle:nth-child(2) { animation-delay: 0.6s; }
.state-listening .g-ripples circle:nth-child(3) { animation-delay: 1.2s; }
@keyframes ripple { 0% { opacity: 0.55; transform: scale(0.82); } 100% { opacity: 0; transform: scale(1.18); } }

.buddy .g-orbit { opacity: 0; transform-origin: 120px 96px; }
.state-thinking .g-orbit { opacity: 1; animation: orbitSpin 2.6s linear infinite; }
@keyframes orbitSpin { to { transform: rotate(360deg); } }

.buddy .g-soundwaves path { opacity: 0; }
.state-speaking .g-soundwaves path { animation: waveFade 1.1s ease-in-out infinite; }
.state-speaking .g-soundwaves path:nth-child(2) { animation-delay: 0.22s; }
@keyframes waveFade { 0%, 100% { opacity: 0; } 45% { opacity: 0.85; } }

.buddy .g-lantern { opacity: 0; }
.state-help .g-lantern, .state-safety .g-lantern { opacity: 1; }
.state-safety .g-lantern .lantern-glow { animation: lanternGlow 1.8s ease-in-out infinite; transform-origin: 186px 96px; }
@keyframes lanternGlow { 50% { opacity: 0.35; transform: scale(1.25); } }

.buddy .g-zzz { opacity: 0; }
.state-privacy .g-zzz { opacity: 1; }
.state-privacy .g-eyes { display: none; }
.buddy .g-eyes-closed { display: none; }
.state-privacy .g-eyes-closed, .state-calm .g-eyes-closed { display: block; }
.state-calm .g-eyes { display: none; }

.buddy .g-confetti { opacity: 0; }
.state-encourage .g-confetti { opacity: 1; }
.state-encourage .g-confetti path { animation: leafFall 1.6s ease-in 1 forwards; }
.state-encourage .g-confetti path:nth-child(2) { animation-delay: 0.15s; }
.state-encourage .g-confetti path:nth-child(3) { animation-delay: 0.3s; }
@keyframes leafFall { 0% { transform: translateY(-26px) rotate(-30deg); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(30px) rotate(40deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .buddy .g-body, .g-ripples circle, .g-orbit, .g-soundwaves path, .g-confetti path, .boot-mark, .kid-leaf { animation: none !important; }
}

/* ---- kid mode -------------------------------------------------------------------------------- */
.kid-frame { min-height: 100vh; background: linear-gradient(180deg, #f2ead7 0%, var(--paper) 30%); }
.kid-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 26px; }
.kid-main { max-width: 860px; margin: 0 auto; padding: 4px 22px 80px; }
.kid-title { font-family: var(--font-display); font-size: 2rem; color: var(--pine-deep); text-align: center; margin: 8px 0 2px; }
.transparency-band {
  margin: 10px auto 20px; max-width: 620px; text-align: center;
  font-size: 0.86rem; color: var(--ink-soft);
  background: var(--sun-wash); border: 1.5px dashed rgba(176, 122, 42, 0.45);
  border-radius: 999px; padding: 7px 18px;
}
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 18px; }
.mode-card {
  cursor: pointer; text-align: center; padding: 18px 12px 14px;
  background: var(--card); border: 1.5px solid rgba(46, 81, 64, 0.16); border-radius: 18px 22px 18px 22px;
  box-shadow: var(--shadow-card); transition: transform 0.1s ease, box-shadow 0.15s ease;
  font: inherit;
}
.mode-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
.mode-card .mode-art { width: 64px; height: 64px; margin: 0 auto 8px; }
.mode-card .mode-name { font-family: var(--font-display); font-size: 1.02rem; color: var(--pine-deep); }
.mode-card .mode-sub { font-size: 0.76rem; color: var(--ink-faint); }

.session-stage { display: grid; grid-template-columns: 300px 1fr; gap: 22px; align-items: start; }
@media (max-width: 820px) { .session-stage { grid-template-columns: 1fr; } .session-left { max-width: 300px; margin: 0 auto; } }
.time-ring { position: relative; width: 76px; height: 76px; }
.time-ring svg { transform: rotate(-90deg); }
.time-ring .tr-label { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-mono); font-size: 0.86rem; color: var(--pine-deep); }

.caption-feed { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 4px 2px; }
.bubble { max-width: 84%; padding: 10px 14px; border-radius: 16px; font-size: 0.98rem; box-shadow: var(--shadow-card); }
.bubble.kid { align-self: flex-end; background: var(--sage-wash); border: 1px solid rgba(78, 122, 98, 0.3); border-bottom-right-radius: 4px; }
.bubble.coach { align-self: flex-start; background: var(--card); border: 1px solid rgba(46, 81, 64, 0.16); border-bottom-left-radius: 4px; }
.bubble.coach.flagged { border-style: dashed; border-color: rgba(164, 76, 54, 0.5); }
.bubble .who { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 2px; }

.talk-bar { display: flex; gap: 10px; margin-top: 14px; }
.talk-bar input { flex: 1; font-size: 1.02rem; padding: 12px 16px; border-radius: 999px; }
.kid-leaf { position: fixed; pointer-events: none; opacity: 0.5; animation: leafDrift 14s linear infinite; }
@keyframes leafDrift { 0% { transform: translate(0, -8vh) rotate(0); } 100% { transform: translate(-12vw, 108vh) rotate(300deg); } }

/* ---- avatar studio ------------------------------------------------------------------------------ */
.studio { display: grid; grid-template-columns: 320px 1fr; gap: 22px; }
@media (max-width: 860px) { .studio { grid-template-columns: 1fr; } }
.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.swatch {
  cursor: pointer; border: 2px solid rgba(46, 81, 64, 0.18); background: var(--parchment);
  border-radius: 12px; padding: 7px 12px; font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 7px;
}
.swatch .dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); }
.swatch.selected { border-color: var(--clay); background: var(--apricot-wash); color: var(--clay-deep); }
.swatch.premium::after { content: "premium"; font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dusk); border: 1px dashed var(--dusk); padding: 1px 6px; border-radius: 999px; }

/* ---- health rows ---------------------------------------------------------------------------------- */
.health-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: baseline; padding: 10px 4px; border-bottom: 1px dashed rgba(46, 81, 64, 0.16); }
.health-dot { width: 11px; height: 11px; border-radius: 50%; position: relative; top: 1px; }
.health-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(71, 119, 92, 0.18); }
.health-dot.down { background: var(--danger); box-shadow: 0 0 0 4px rgba(164, 76, 54, 0.18); }
.health-dot.not_adopted { background: var(--dusk); box-shadow: 0 0 0 4px rgba(124, 111, 148, 0.2); }
.health-dot.forbidden { background: repeating-linear-gradient(45deg, var(--danger) 0 2px, var(--paper) 2px 4px); border: 1px solid var(--danger); }

/* ---- toasts / modal --------------------------------------------------------------------------------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--pine-deep); color: #f2ede0; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-pop); font-size: 0.88rem; max-width: 340px; }
.toast.error { background: var(--danger); }
.modal-scrim { position: fixed; inset: 0; background: rgba(35, 55, 46, 0.45); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); padding: 22px 26px; width: min(480px, 92vw); }

.ai-footer { margin-top: 40px; font-size: 0.78rem; color: var(--ink-faint); border-top: var(--stitch); padding-top: 12px; }

.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 8px 2px; border-bottom: 1px dashed rgba(46, 81, 64, 0.14); }
.right { text-align: right; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.notif-dot { display: inline-block; min-width: 19px; text-align: center; background: var(--clay); color: #fff; font-size: 0.7rem; font-weight: 700; border-radius: 999px; padding: 1px 5px; }

/* ============================================================================
   PWA — safe-area insets, standalone mode, install UX, offline/update banners.
   Additive: the installed home-screen app extends under the notch/home bar.
   ========================================================================== */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* keep primary regions clear of the notch, rounded corners, and home bar */
.rail { padding-top: calc(20px + var(--safe-top)); padding-left: calc(14px + var(--safe-left)); padding-bottom: calc(10px + var(--safe-bottom)); }
.main { padding-top: calc(26px + var(--safe-top)); padding-right: calc(34px + var(--safe-right)); padding-bottom: calc(60px + var(--safe-bottom)); }
.login-panel { padding-top: calc(48px + var(--safe-top)); padding-left: calc(54px + var(--safe-left)); padding-bottom: calc(48px + var(--safe-bottom)); }
.kid-top { padding-top: calc(16px + var(--safe-top)); padding-left: calc(26px + var(--safe-left)); padding-right: calc(26px + var(--safe-right)); }
.kid-main { padding-bottom: calc(80px + var(--safe-bottom)); }

@media (max-width: 720px) {
  .main { padding-left: calc(18px + var(--safe-left)); padding-right: calc(18px + var(--safe-right)); }
  .rail { position: sticky; top: 0; }
}

/* installed standalone: hide any browser-only affordances, firm up the shell */
html[data-display="standalone"] .cfc-install-chip { display: none !important; }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .cfc-install-chip { display: none !important; }
}

/* install chip (Android beforeinstallprompt / iOS instructions) */
.cfc-install-chip {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + var(--safe-bottom)); z-index: 70;
  display: flex; align-items: center; gap: 10px;
  max-width: min(94vw, 520px);
  background: var(--card); color: var(--ink);
  border: 1.5px solid rgba(46, 81, 64, 0.2); border-radius: 999px;
  box-shadow: var(--shadow-pop); padding: 8px 10px 8px 16px;
}
.cfc-install-chip .cfc-ic { color: var(--pine); display: flex; }
.cfc-install-text { font-size: 0.86rem; }
.cfc-install-go {
  font: inherit; font-weight: 600; font-size: 0.84rem; cursor: pointer;
  border: 0; border-radius: 999px; padding: 7px 16px; background: var(--pine); color: #f7f2e4;
}
.cfc-install-x { font-size: 1.2rem; line-height: 1; border: 0; background: none; color: var(--ink-faint); cursor: pointer; padding: 0 6px; }

/* iOS "Add to Home Screen" instruction sheet */
.cfc-sheet-scrim { position: fixed; inset: 0; z-index: 80; background: rgba(35, 55, 46, 0.45); display: grid; place-items: end center; }
.cfc-sheet {
  background: var(--card); width: min(560px, 96vw);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow-pop);
  padding: 22px 24px calc(24px + var(--safe-bottom));
  animation: sheetUp 0.24s ease;
}
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0; } }
.cfc-sheet h3 { font-family: var(--font-display); color: var(--pine-deep); margin: 0 0 10px; }
.cfc-sheet ol { margin: 0 0 10px; padding-left: 1.2rem; }
.cfc-sheet li { margin: 8px 0; }
.cfc-sheet-note { font-size: 0.82rem; color: var(--ink-faint); }
.cfc-sheet-close { margin-top: 12px; font: inherit; font-weight: 600; cursor: pointer; border: 1.5px solid var(--pine); background: var(--pine); color: #f7f2e4; border-radius: 999px; padding: 9px 20px; width: 100%; }

/* offline + update banners (attached to body, above the SPA) */
.cfc-offline-banner {
  position: fixed; left: 0; right: 0; top: 0; z-index: 75;
  padding: calc(7px + var(--safe-top)) 14px 7px; text-align: center;
  background: var(--sun-wash); color: var(--warn);
  font-size: 0.84rem; font-weight: 600; border-bottom: 1.5px dashed rgba(176, 122, 42, 0.5);
}
.cfc-update-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + var(--safe-bottom)); z-index: 76;
  display: flex; align-items: center; gap: 10px; max-width: min(94vw, 520px);
  background: var(--pine-deep); color: #f2ede0;
  border-radius: 14px; box-shadow: var(--shadow-pop); padding: 10px 12px 10px 16px; font-size: 0.86rem;
}
.cfc-update-banner button { font: inherit; font-weight: 600; font-size: 0.82rem; cursor: pointer; border: 0; border-radius: 999px; padding: 6px 14px; background: var(--sun); color: #3a2c08; }
.cfc-update-banner .cfc-update-x { background: none; color: #cfc7b3; padding: 0 4px; font-size: 1.1rem; }

@media (prefers-reduced-motion: reduce) {
  .cfc-sheet { animation: none; }
}

