/* ============================================================
   Seed & Slumber. Shared app styles (setup, account, child, library).
   Twilight-lamplit theme. Openable via file://, no build step.
   ============================================================ */

/* Brand tokens are the single source of truth in ../tokens.css. This @import
   pulls the ONE canonical :root palette + type. Must be the first rule (CSS
   requires @import before other rules). Every app page also <link>s tokens.css
   directly (so tokens exist even if this @import is slow), and this @import keeps
   app.css self-sufficient when opened alone. */
@import url("../tokens.css");

/* ---- APP-SCOPED token overrides (deliberate, NOT drift; see docs/BRAND.md) ----
   The reading/app view intentionally differs from the marketing palette in a few
   tokens, and adds surface tokens the marketing pages don't need:
     - --dusk-1/--dusk-2: a DEEPER reading night than the marketing hero, so the
       calm dark reading background sits right. (marketing 2a2440/3d3357)
     - --sage-soft: reused here as a PALE CARD FILL (#eef4e9), not the marketing
       on-dark accent green (#d5e6cf). Coda/derived chips depend on this pale value.
     - --page/--paper: warm card surface. --line: card/border hairline. App-only.
     - --maxw: the app shell is a touch narrower (1040) than marketing (1080).
   Keep these HERE, scoped and documented, so no brand hex is silently duplicated. */
:root{
  --dusk-1:#201b30; --dusk-2:#2c2542;
  --sage-soft:#eef4e9;
  --page:#fffdf7; --paper:#fffdf7;
  --line:#e7d9bd;
  --maxw:1040px;
}
*{box-sizing:border-box}
/* The [hidden] attribute must always win. Several components set display (flex,
   grid, inline-flex) which would otherwise override the attribute's default
   display:none and leave a "hidden" element visible (e.g. an empty derived-note
   pill showing as a lone indicator). This reset keeps hidden truly hidden. */
[hidden]{display:none !important}
html{scroll-behavior:smooth}
body{
  margin:0; font-family:var(--body); font-size:19px; line-height:1.7; color:var(--ink);
  background:radial-gradient(1200px 760px at 50% -12%, #33294d 0%, var(--dusk-2) 42%, var(--dusk-1) 100%) fixed;
  min-height:100vh; -webkit-font-smoothing:antialiased;
}
a{color:inherit}
em{font-style:italic}
h1,h2,h3,h4{font-family:var(--display); font-weight:400; line-height:1.14; letter-spacing:-.01em; margin:0}

/* ---- ambient dusk sky (fixed background: moon + stars) ---- */
.skybg{position:fixed; inset:0; z-index:0; pointer-events:none; overflow:hidden}
.moon2{filter:drop-shadow(0 0 26px rgba(255,223,158,.5))}
.twk{fill:#fff; opacity:.14; animation:twk 4.5s ease-in-out infinite}
@keyframes twk{0%,100%{opacity:.10}50%{opacity:.8}}
.glow2{animation:glow2 6s ease-in-out infinite}
@keyframes glow2{0%,100%{opacity:.45}50%{opacity:1}}
.forest{position:fixed; left:0; right:0; bottom:0; width:100%; height:auto; z-index:0; pointer-events:none; display:block}
@media(prefers-reduced-motion:reduce){.twk,.glow2{animation:none}}

/* ---- shared app top bar ---- */
.appbar{position:sticky; top:0; z-index:30; background:rgba(32,27,48,.82);
  backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px);
  border-bottom:1px solid rgba(255,255,255,.09)}
.appbar .inner{max-width:var(--maxw); margin:0 auto; padding:.85rem 1.5rem;
  display:flex; align-items:center; justify-content:space-between; gap:1rem}
.appbar .brand{font-family:var(--display); font-size:1.2rem; color:var(--cream); text-decoration:none; white-space:nowrap}
.appbar .brand .amp{color:var(--gold)}
.appbar nav{display:flex; gap:.3rem; align-items:center; flex-wrap:wrap}
.appbar nav a{font-family:var(--body); font-size:.98rem; text-decoration:none; color:rgba(251,245,234,.78);
  padding:.42rem .85rem; border-radius:999px; transition:background .2s, color .2s}
.appbar nav a:hover{color:var(--cream); background:rgba(255,255,255,.08)}
.appbar nav a.active{color:#2c2213; background:var(--glow)}
@media(max-width:560px){
  .appbar .inner{flex-direction:column; align-items:flex-start; gap:.5rem}
  .appbar nav{width:100%}
}

/* ---- page shell ---- */
.shell{position:relative; z-index:2; max-width:var(--maxw); margin:0 auto; padding:2.6rem 1.5rem 5rem}
.shell.narrow{max-width:760px}
.pagehead{text-align:center; margin:0 auto 2.4rem; max-width:60ch}
.pagehead .eyebrow{font-family:var(--body); font-style:italic; color:var(--glow); font-size:1.02rem; margin:0 0 .6rem}
.pagehead h1{font-size:clamp(2rem,5vw,2.9rem); color:var(--cream)}
.pagehead p{color:rgba(251,245,234,.82); font-size:1.14rem; max-width:52ch; margin:1rem auto 0}

/* ---- card surface (warm paper) ---- */
.card{background:var(--page); border:1px solid var(--line); border-radius:18px; padding:2rem 1.9rem;
  box-shadow:0 40px 90px -50px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.5) inset}
.card + .card{margin-top:1.5rem}
.card h2{font-size:1.5rem; margin:0 0 .2rem}
.card h3{font-size:1.25rem}
.card .sub{color:var(--ink-soft); font-size:1.02rem; margin:.3rem 0 0}
.section-label{font-family:var(--body); font-variant:small-caps; letter-spacing:.06em; color:var(--sage);
  font-weight:600; font-size:.95rem; margin:0 0 1rem}
.hr{height:1px; background:var(--line); border:0; margin:1.6rem 0}

/* ---- buttons (gold + ghost) ---- */
.btn{display:inline-flex; align-items:center; justify-content:center; gap:.5rem; cursor:pointer;
  font-family:var(--body); font-size:1.04rem; font-weight:500; background:var(--gold); color:#2c2213;
  text-decoration:none; padding:.82rem 1.6rem; border-radius:999px; border:1px solid rgba(0,0,0,.08);
  box-shadow:0 8px 24px -12px rgba(199,154,78,.8), inset 0 1px 0 rgba(255,255,255,.35);
  transition:transform .18s, box-shadow .18s, background .2s}
.btn:hover{transform:translateY(-2px); box-shadow:0 14px 30px -14px rgba(199,154,78,.95), inset 0 1px 0 rgba(255,255,255,.4)}
.btn:disabled,.btn.is-disabled{opacity:.45; cursor:not-allowed; transform:none; box-shadow:none}
.btn-lg{font-size:1.16rem; padding:1rem 2.2rem}
.btn-block{width:100%}
.btn-soft{background:#fbf3e2; color:var(--gold-deep); border-color:#e7d5b0; box-shadow:none}
.btn-soft:hover{background:#f6ead0; box-shadow:none}
.btn-ghost{background:transparent; color:rgba(251,245,234,.92); border:1px solid rgba(255,255,255,.24); box-shadow:none}
.btn-ghost:hover{background:rgba(255,255,255,.08); transform:none}
.btn-danger{background:transparent; color:var(--rose); border:1px solid rgba(184,105,94,.4); box-shadow:none}
.btn-danger:hover{background:rgba(184,105,94,.08); transform:none}
.linklike{background:none; border:0; color:var(--gold-deep); font-family:var(--body); font-size:1rem;
  cursor:pointer; text-decoration:underline; text-underline-offset:3px; padding:0}
.backlink{display:inline-block; color:rgba(251,245,234,.8); text-decoration:none; font-size:1rem; margin-bottom:1.4rem}
.backlink:hover{color:var(--cream)}

/* ---- forms ---- */
.field{margin:0 0 1.15rem}
.field:last-child{margin-bottom:0}
label.lbl{display:block; font-family:var(--body); font-weight:500; color:var(--ink); margin:0 0 .35rem; font-size:1rem}
label.lbl .hint{font-weight:400; font-style:italic; color:var(--ink-soft); font-size:.9rem}
.input, select.input, textarea.input{
  width:100%; font-family:var(--body); font-size:1.04rem; color:var(--ink); background:var(--page);
  border:1px solid var(--line); border-radius:11px; padding:.7rem .9rem; transition:border-color .2s, box-shadow .2s}
.input:focus, select.input:focus, textarea.input:focus{outline:none; border-color:var(--gold);
  box-shadow:0 0 0 3px rgba(199,154,78,.18)}
.input::placeholder{color:#b7a892}
select.input{appearance:none; -webkit-appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239a7b53' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right .8rem center; padding-right:2.2rem}
.row2{display:grid; grid-template-columns:1fr 1fr; gap:1rem}
@media(max-width:520px){.row2{grid-template-columns:1fr}}
.derived{display:inline-flex; align-items:center; gap:.45rem; margin-top:.5rem; font-size:.95rem;
  color:var(--sage-deep); background:var(--sage-soft); border:1px solid #d7e6cf; border-radius:999px; padding:.32rem .85rem}
/* A small check, not a bare status pip: the pill states a value we derived from
   what the parent entered, so the mark reads as "confirmed" alongside its text. */
.derived .dot{width:14px; height:14px; flex:none; border-radius:50%; background:var(--sage);
  position:relative}
.derived .dot::after{content:""; position:absolute; left:4.5px; top:2px; width:3px; height:6.5px;
  border:solid #fff; border-width:0 2px 2px 0; transform:rotate(40deg)}

/* radio / choice pills (gender) */
.pills{display:flex; flex-wrap:wrap; gap:.5rem}
.pill{position:relative}
.pill input{position:absolute; opacity:0; inset:0; cursor:pointer}
.pill span{display:inline-block; font-family:var(--body); font-size:.98rem; color:var(--gold-deep);
  background:var(--page); border:1px solid var(--line); border-radius:999px; padding:.42rem 1rem; transition:.15s}
.pill input:checked + span{background:var(--sage); color:#fff; border-color:var(--sage)}
.pill input:focus-visible + span{box-shadow:0 0 0 3px rgba(199,154,78,.3)}

/* ---- tile pickers (worlds / series) ---- */
.tiles{display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:.9rem}
.tile{position:relative; text-align:left}
.tile input{position:absolute; opacity:0; inset:0; cursor:pointer}
.tile .body{display:block; height:100%; background:var(--page); border:1.5px solid var(--line); border-radius:14px;
  padding:1rem 1.05rem; transition:border-color .15s, box-shadow .15s, transform .15s}
.tile .ico{font-size:1.5rem; line-height:1; display:block; margin-bottom:.5rem}
.tile .name{font-family:var(--display); font-size:1.12rem; display:block}
.tile .desc{color:var(--ink-soft); font-size:.9rem; margin-top:.25rem; display:block}
.tile input:checked + .body{border-color:var(--gold); box-shadow:0 0 0 3px rgba(199,154,78,.18)}
.tile input:focus-visible + .body{box-shadow:0 0 0 3px rgba(199,154,78,.32)}
.tile.disabled .body{opacity:.55; cursor:not-allowed; background:repeating-linear-gradient(135deg,var(--cream),var(--cream) 8px,#f4ecdd 8px,#f4ecdd 16px)}
.tile .flag{position:absolute; top:.55rem; right:.6rem; font-family:var(--body); font-size:.7rem; letter-spacing:.04em;
  text-transform:uppercase; color:var(--gold-deep); background:#fbf3e2; border:1px solid #e7d5b0; border-radius:999px; padding:.12rem .5rem}
.tile .flag.soon{color:var(--ink-soft); background:#efe7d6; border-color:#e0d3ba}

/* ---- child card grid (account) ---- */
.kidgrid{display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:1.1rem}
.kidcard{display:block; text-decoration:none; color:inherit; background:var(--page); border:1px solid var(--line);
  border-radius:16px; padding:1.3rem 1.35rem; box-shadow:0 30px 60px -50px rgba(0,0,0,.5);
  transition:transform .18s, box-shadow .18s, border-color .18s}
.kidcard:hover{transform:translateY(-3px); border-color:var(--gold);
  box-shadow:0 34px 60px -44px rgba(199,154,78,.6)}
.kidcard .avatar{width:46px; height:46px; border-radius:50%; display:grid; place-items:center;
  font-family:var(--display); font-size:1.3rem; color:#2c2213; background:radial-gradient(circle at 32% 28%,#ffe7b0,var(--gold));
  box-shadow:0 0 18px -4px rgba(255,223,158,.7); margin-bottom:.7rem}
.kidcard .kname{font-family:var(--display); font-size:1.3rem; line-height:1.1}
.kidcard .knick{font-style:italic; color:var(--gold-deep); font-size:.98rem}
.kidcard .meta{margin:.7rem 0 0; font-size:.92rem; color:var(--ink-soft); line-height:1.5}
.kidcard .meta b{color:var(--ink); font-weight:500}
.kidcard .prog{margin-top:.85rem}
.kidcard.add{display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center;
  border-style:dashed; background:rgba(255,253,247,.55); color:var(--gold-deep); min-height:160px}
.kidcard.add .plus{font-family:var(--display); font-size:2.4rem; line-height:1; color:var(--gold)}
.kidcard.add.is-disabled{opacity:.5; pointer-events:none}

/* progress bar */
.bar-track{height:8px; border-radius:999px; background:#efe7d6; overflow:hidden}
.bar-fill{height:100%; border-radius:999px; background:linear-gradient(90deg,var(--sage),#7ba06d)}
.bar-cap{font-size:.85rem; color:var(--ink-soft); margin-top:.4rem}

/* progress dots (nights) */
.dots{display:inline-flex; gap:5px; vertical-align:middle}
.dots i{width:8px; height:8px; border-radius:50%; background:#e2d6bf; display:block}
.dots i.on{background:var(--sage)}

/* ---- plan / billing block ---- */
.plan-strip{display:flex; flex-wrap:wrap; align-items:center; gap:1rem 1.4rem; justify-content:space-between}
.plan-name{font-family:var(--display); font-size:1.55rem; display:flex; align-items:baseline; gap:.6rem}
.plan-name .badge{font-family:var(--body); font-size:.74rem; letter-spacing:.05em; text-transform:uppercase;
  color:#2c2213; background:var(--glow); border-radius:999px; padding:.2rem .7rem}
.plan-price{color:var(--ink-soft); font-size:1rem}

/* ---- pill row / chips ---- */
.chip{display:inline-block; font-family:var(--body); font-size:.92rem; color:var(--gold-deep);
  background:#fbf3e2; border:1px solid #e7d5b0; border-radius:999px; padding:.3rem .8rem}
.chip.sage{color:#fff; background:var(--sage); border-color:var(--sage)}

/* ---- toast / saved note ---- */
.toast{position:fixed; left:50%; bottom:1.6rem; transform:translateX(-50%) translateY(140%);
  background:var(--sage); color:#fff; font-family:var(--body); padding:.75rem 1.4rem; border-radius:999px;
  box-shadow:0 20px 40px -18px rgba(0,0,0,.5); z-index:60; transition:transform .35s cubic-bezier(.2,.9,.3,1); font-size:1rem}
.toast.show{transform:translateX(-50%) translateY(0)}

/* ---- misc ---- */
.center{text-align:center}
.muted{color:var(--ink-soft)}
.stack{display:flex; flex-wrap:wrap; gap:.8rem; align-items:center}
.spread{display:flex; flex-wrap:wrap; gap:1rem; align-items:center; justify-content:space-between}
.footnote{color:rgba(251,245,234,.55); font-size:.9rem; text-align:center; margin-top:2.4rem; font-style:italic}

/* ---- family hub (parent profiles) ---- */
.hub-actions{display:flex; flex-wrap:wrap; gap:.55rem; margin-top:1rem}
.hub-actions .linklike{font-size:.95rem}
.hubcard{background:var(--page); border:1px solid var(--line); border-radius:16px; padding:1.4rem 1.4rem;
  box-shadow:0 24px 46px -40px rgba(0,0,0,.5); display:flex; flex-direction:column; gap:.2rem}
.hubcard .hub-head{display:flex; align-items:center; gap:.8rem}
.hubcard .avatar{width:46px; height:46px; border-radius:50%; display:grid; place-items:center;
  font-family:var(--display); font-size:1.35rem; color:#2c2213;
  background:radial-gradient(circle at 32% 28%,#ffe7b0,var(--gold)); flex:none}
/* Lantern avatar: replaces the flat gold initial orb. `.lit` neutralizes the old
   circular orb styling on whatever `.avatar` slot holds a lantern; the SVG fits the
   slot height and carries its own warm glow. */
/* `.lit` neutralizes ANY orb slot (the big card `.avatar`, or the small child-
   button `.av` / sibling `.dot` chips) so the lantern SVG shows instead. */
.lit{background:none !important; box-shadow:none !important; border-radius:0 !important; overflow:visible}
/* Cute rounded lantern: a soft dome body on a warm glow, no hard square frame.
   The whole SVG carries its own halo so it sits on light, not in a box. */
.lantern{display:block; width:100%; height:100%;
  filter:drop-shadow(0 2px 4px rgba(58,46,38,.22)) drop-shadow(0 0 10px rgba(255,205,120,.85))}
.lantern .ln-cap,.lantern .ln-base,.lantern .ln-foot{fill:var(--gold-deep)}
.lantern .ln-body{fill:var(--gold)}
.lantern .ln-glow{fill:var(--glow)}
.lantern .ln-hang{fill:none; stroke:var(--gold-deep); stroke-width:1.6; stroke-linecap:round}
.lantern .ln-letter{font-family:var(--display); font-size:17px; font-weight:600; fill:var(--gold-deep)}
/* Compact chip lantern: letter-dominant so it stays legible at ~26-34px. A soft
   halo only (no hard box); a faint warm outline keeps the rounded lantern shape
   readable even when the chip sits on a light amber selected background. */
.lantern-mini{filter:drop-shadow(0 1px 2px rgba(58,46,38,.25)) drop-shadow(0 0 4px rgba(255,205,120,.7))}
.lantern-mini .ln-body{stroke:var(--gold-deep); stroke-width:.9}
.lantern-mini .ln-glow{opacity:.85}
.lantern-mini .ln-letter{font-size:15px; font-weight:700}
.hubcard .kname{font-family:var(--display); font-size:1.28rem; line-height:1.1}
.hubcard .knick{font-style:italic; color:var(--gold-deep); font-size:.95rem}
.hubcard .meta{margin:.5rem 0 0; font-size:.92rem; color:var(--ink-soft); line-height:1.5}
.badge-stale{display:inline-block; font-family:var(--body); font-size:.72rem; letter-spacing:.03em;
  text-transform:uppercase; border-radius:999px; padding:.16rem .55rem; color:#7a5a12; background:#fbeccb;
  border:1px solid #e7d5b0; margin-left:.4rem}
.hubcard.add{align-items:center; justify-content:center; text-align:center; border-style:dashed; min-height:150px; cursor:pointer}
.hubcard.add .plus{font-family:var(--display); font-size:2.4rem; line-height:1; color:var(--gold)}
.hubcard.add.is-disabled{opacity:.5; pointer-events:none}
/* inline edit/add form */
.hub-form{margin-top:1rem; border-top:1px dashed var(--line); padding-top:1rem}
.hub-form .save-row{display:flex; gap:.7rem; flex-wrap:wrap; align-items:center; margin-top:1rem}
.hub-empty{color:var(--ink-soft); font-style:italic}
.hub-note{color:rgba(251,245,234,.7); font-size:.92rem; text-align:center; margin-top:.8rem; font-style:italic}

/* parent hub tiles (family.html dashboard) */
.hub-links{display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:1rem; margin:0 0 1.6rem}
.hub-tile{display:flex; flex-direction:column; gap:.25rem; text-decoration:none; color:inherit;
  background:linear-gradient(160deg,#fffdf7,#f7efdd); border:1px solid var(--line); border-radius:16px;
  padding:1.2rem 1.25rem; box-shadow:0 24px 46px -40px rgba(0,0,0,.5);
  transition:transform .16s, box-shadow .16s, border-color .16s}
.hub-tile:hover{transform:translateY(-3px); border-color:var(--gold); box-shadow:0 28px 50px -38px rgba(199,154,78,.6)}
.hub-tile .hub-ico{font-size:1.5rem; line-height:1; color:var(--gold-deep)}
.hub-tile .hub-ico svg{width:26px; height:26px; display:block; fill:none;
  stroke:var(--gold-deep); stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round}
.hub-tile .hub-name{font-family:var(--display); font-size:1.2rem; line-height:1.15}
.hub-tile .hub-desc{color:var(--ink-soft); font-size:.9rem}
