/* ============================================================
   FAMILY APP — design tokens + base
   Warm dark mode · energetic orange · cozy & friendly
   ============================================================ */

/* ---- fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Young+Serif&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,500&display=swap');

/* ============================================================
   TOKENS
   ============================================================ */
:root {
  /* type */
  --font-display: 'Young Serif', Georgia, serif;
  --font-ui: 'Plus Jakarta Sans', system-ui, sans-serif;

  /* accent hue — overridden by accent presets */
  --accent-h: 24;
  --accent-s: 95%;

  /* functional accents (energetic, anchored on orange) */
  --orange: hsl(var(--accent-h) var(--accent-s) 56%);
  --orange-soft: hsl(var(--accent-h) var(--accent-s) 62%);
  --orange-deep: hsl(calc(var(--accent-h) - 8) var(--accent-s) 48%);
  --amber: hsl(40 96% 56%);
  --amber-deep: hsl(36 96% 50%);
  --coral: hsl(350 90% 66%);
  --mint: hsl(152 62% 50%);
  --lagoon: hsl(192 80% 54%);
  --grape: hsl(276 62% 66%);

  /* radii */
  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 20px;
  --r-lg: 28px;
  --r-xl: 34px;

  /* glass intensity (tweakable) */
  --glass-blur: 18px;
  --glass-alpha: 0.055;
  --glass-border: 0.10;

  /* density (tweakable) */
  --gap: 16px;
  --pad: 18px;
  --card-pad: 18px;

  /* easing */
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.22, .61, .36, 1);

  /* z layers */
  --z-nav: 60;
  --z-fab: 65;
  --z-sheet: 80;
  --z-overlay: 90;
  --z-confetti: 120;
}

/* ---- DARK (default) ---- */
:root, [data-theme="dark"] {
  --bg-0: hsl(24 22% 7%);
  --bg-1: hsl(24 18% 9%);
  --bg-grad-a: hsl(24 60% 16%);
  --bg-grad-b: hsl(350 45% 13%);
  --ink: hsl(36 30% 96%);
  --ink-2: hsl(32 12% 72%);
  --ink-3: hsl(30 8% 52%);
  --surface: hsl(28 16% 12%);
  --surface-2: hsl(28 15% 15%);
  --hairline: hsl(30 14% 100% / .09);
  --glass-tint: hsl(30 40% 96% / var(--glass-alpha));
  --glass-stroke: hsl(40 60% 96% / var(--glass-border));
  --shadow: 0 18px 40px -16px hsl(20 60% 3% / .8);
  --scrim: hsl(22 30% 3% / .6);
}

/* ---- LIGHT (tweak) ---- */
[data-theme="light"] {
  --bg-0: hsl(34 60% 96%);
  --bg-1: hsl(34 54% 94%);
  --bg-grad-a: hsl(28 96% 86%);
  --bg-grad-b: hsl(350 90% 90%);
  --ink: hsl(24 30% 14%);
  --ink-2: hsl(26 14% 36%);
  --ink-3: hsl(28 10% 52%);
  --surface: hsl(36 60% 99%);
  --surface-2: hsl(34 50% 97%);
  --hairline: hsl(28 30% 20% / .10);
  --glass-tint: hsl(28 80% 100% / .5);
  --glass-stroke: hsl(28 40% 100% / .7);
  --shadow: 0 18px 38px -18px hsl(24 50% 40% / .35);
  --scrim: hsl(24 30% 30% / .35);
}

/* density variants */
[data-density="compact"] { --gap: 11px; --pad: 14px; --card-pad: 14px; }
[data-density="comfy"]   { --gap: 20px; --pad: 22px; --card-pad: 22px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg-0);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

/* desktop ambient stage */
.stage {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 18% 0%, var(--bg-grad-a) 0%, transparent 46%),
    radial-gradient(120% 90% at 90% 100%, var(--bg-grad-b) 0%, transparent 50%),
    var(--bg-0);
  padding: 0;
}
@media (min-width: 560px) {
  .stage { padding: 28px; }
}

/* the phone column */
.phone {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  background: var(--bg-1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}
@media (min-width: 560px) {
  .phone {
    height: min(920px, calc(100dvh - 56px));
    border-radius: 44px;
    box-shadow: var(--shadow), 0 0 0 1px var(--hairline), 0 60px 120px -40px hsl(20 60% 3% / .7);
  }
}
/* phone interior warm glow */
.phone::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(90% 50% at 50% -6%, hsl(var(--accent-h) 80% 30% / .42) 0%, transparent 60%),
    radial-gradient(70% 40% at 100% 102%, hsl(350 60% 26% / .3) 0%, transparent 60%);
  pointer-events: none; z-index: 0;
}
[data-theme="light"] .phone::before {
  background:
    radial-gradient(90% 50% at 50% -6%, hsl(var(--accent-h) 96% 70% / .5) 0%, transparent 60%),
    radial-gradient(70% 40% at 100% 102%, hsl(350 90% 82% / .45) 0%, transparent 60%);
}

/* scroll body */
.screen {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--pad) 120px;
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }

/* ============================================================
   STATUS BAR + HEADER
   ============================================================ */
.statusbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 26px 2px;
  font-size: 13px; font-weight: 700; letter-spacing: .2px;
  color: var(--ink);
}
.statusbar .sb-icons { display: flex; gap: 6px; align-items: center; }
.statusbar svg { width: 16px; height: 16px; }

.appbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: 8px var(--pad) 12px;
}
.appbar-title { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.appbar-title .eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap;
}
.appbar-title h1 {
  font-family: var(--font-display);
  font-weight: 400; font-size: 25px; margin: 4px 0 0; color: var(--ink); white-space: nowrap;
}
.appbar .spacer { flex: 1; }

/* ============================================================
   GLASS / CARD primitives
   ============================================================ */
.glass {
  background: var(--glass-tint);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border: 1px solid var(--glass-stroke);
}
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--card-pad);
  position: relative;
}
.card-glass {
  background: var(--glass-tint);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--r-lg);
  padding: var(--card-pad);
  position: relative;
}
.section-label {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 2px 12px;
}
.section-label h2 {
  font-size: 15px; font-weight: 800; letter-spacing: -.01em; margin: 0; color: var(--ink); white-space: nowrap;
}
.section-label .more { font-size: 13px; font-weight: 700; color: var(--orange); white-space: nowrap; flex: none; cursor: pointer; }

/* pills + chips */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1;
  border: 1px solid var(--hairline);
  background: var(--surface-2); color: var(--ink-2);
}
.pill svg { width: 13px; height: 13px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px; border-radius: 8px;
  font-size: 11px; font-weight: 700; line-height: 1;
}

/* buttons */
.btn {
  font-family: var(--font-ui);
  border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; font-size: 15px;
  padding: 14px 20px; border-radius: var(--r-md);
  transition: transform .12s var(--spring), filter .2s;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--orange-soft), var(--orange-deep));
  color: hsl(24 60% 12%);
  box-shadow: 0 10px 24px -8px hsl(var(--accent-h) 90% 40% / .6);
}
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--hairline); }
.btn-block { width: 100%; }

/* progress */
.bar {
  height: 9px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; border: 1px solid var(--hairline);
}
.bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--orange-soft), var(--amber));
  transition: width .6s var(--ease);
}

/* icon button */
.iconbtn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--glass-tint); border: 1px solid var(--glass-stroke);
  -webkit-backdrop-filter: blur(var(--glass-blur)); backdrop-filter: blur(var(--glass-blur));
  color: var(--ink); transition: transform .12s var(--spring);
}
.iconbtn:active { transform: scale(.9); }
.iconbtn svg { width: 20px; height: 20px; }

/* avatar */
.avatar {
  border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; color: #fff; flex: none;
  font-size: 15px; position: relative;
  background: linear-gradient(135deg, var(--orange-soft), var(--coral));
}
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }
.avatar.md { width: 40px; height: 40px; font-size: 15px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.ring { box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 4px var(--orange); }

/* coin glyph */
.coin {
  display: inline-grid; place-items: center; flex: none;
  width: 1em; height: 1em; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, hsl(46 100% 72%), var(--amber-deep));
  box-shadow: inset 0 -1px 2px hsl(36 80% 30% / .6), inset 0 1px 1px hsl(48 100% 90% / .8);
  color: hsl(36 80% 28%); font-weight: 900;
  font-size: 1em; position: relative;
}
.coin::after { content: "₵"; font-size: .62em; line-height: 1; }

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: var(--z-nav);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  display: flex; align-items: stretch; justify-content: space-around;
  background: var(--glass-tint);
  -webkit-backdrop-filter: blur(26px) saturate(1.5);
  backdrop-filter: blur(26px) saturate(1.5);
  border-top: 1px solid var(--glass-stroke);
}
.nav::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-stroke), transparent);
}
.navitem {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 2px; color: var(--ink-3);
  font-family: var(--font-ui); font-size: 10px; font-weight: 700;
}
.navitem svg { width: 23px; height: 23px; transition: transform .25s var(--spring); }
.navitem.active { color: var(--orange); }
.navitem.active svg { transform: translateY(-2px) scale(1.06); }
.navitem .dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--orange);
  opacity: 0; transform: scale(0); transition: all .25s var(--spring);
}
.navitem.active .dot { opacity: 1; transform: scale(1); }

/* FAB */
.fab {
  position: absolute; right: 18px; z-index: var(--z-fab);
  bottom: calc(86px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 20px; border: none; cursor: pointer;
  display: grid; place-items: center; color: hsl(24 60% 12%);
  background: linear-gradient(135deg, var(--orange-soft), var(--orange-deep));
  box-shadow: 0 14px 30px -8px hsl(var(--accent-h) 90% 40% / .7);
  transition: transform .15s var(--spring);
}
.fab:active { transform: scale(.9) rotate(8deg); }
.fab svg { width: 26px; height: 26px; }

/* ============================================================
   SHEET / OVERLAY
   ============================================================ */
.scrim {
  position: absolute; inset: 0; z-index: var(--z-overlay);
  background: var(--scrim);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
}
.scrim.center { align-items: center; padding: 22px; }
.sheet {
  width: 100%; background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--glass-stroke);
  padding: 10px var(--pad) calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 50px -20px hsl(20 60% 3% / .7);
  animation: sheetup .34s var(--spring);
  max-height: 86%; overflow-y: auto; scrollbar-width: none;
}
.sheet::-webkit-scrollbar { display: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--ink-3); opacity: .5; margin: 4px auto 12px; }
.modal {
  width: 100%; max-width: 360px; background: var(--surface);
  border-radius: var(--r-xl); border: 1px solid var(--glass-stroke);
  padding: 24px; box-shadow: var(--shadow);
  animation: pop .34s var(--spring);
}

@keyframes sheetup { from { transform: translateY(64px); } }
@keyframes pop { from { transform: scale(.94); } }
@keyframes shake {
  10%,90% { transform: translateX(-1px); }
  20%,80% { transform: translateX(2px); }
  30%,50%,70% { transform: translateX(-4px); }
  40%,60% { transform: translateX(4px); }
}
.shake { animation: shake .5s var(--ease) infinite; }

/* confetti canvas */
#fx-canvas {
  position: absolute; inset: 0; z-index: var(--z-confetti);
  pointer-events: none;
}

/* coin clink drops */
.coinfx {
  position: absolute; z-index: var(--z-confetti); pointer-events: none;
  font-size: 22px; will-change: transform, opacity;
}

/* haptic ripple */
.ripple {
  position: absolute; z-index: var(--z-confetti); pointer-events: none;
  border-radius: 50%; border: 2px solid var(--orange);
  transform: translate(-50%,-50%); animation: ripple .6s var(--ease) forwards;
}
@keyframes ripple { from { width: 8px; height: 8px; opacity: .8; } to { width: 120px; height: 120px; opacity: 0; } }

/* misc utility */
.row { display: flex; align-items: center; gap: var(--gap); }
.col { display: flex; flex-direction: column; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.serif { font-family: var(--font-display); font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.hscroll {
  display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(var(--pad) * -1); padding: 2px var(--pad) 4px;
}
.hscroll::-webkit-scrollbar { display: none; }
.enter { animation: enter .5s var(--ease) both; }
@keyframes enter { from { transform: translateY(9px); } 60% { } }
@keyframes petbob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-7px) rotate(1deg); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001s !important; } }

/* ── form pages (replaces bottom-sheet modals) ── */
.form-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--hairline);
  background: var(--bg-1); position: relative; z-index: 2;
}
.form-header h2 {
  font-family: var(--font-display); font-weight: 400; font-size: 20px;
  margin: 0; color: var(--ink); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.form-body {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 20px var(--pad) 60px; scrollbar-width: none;
}
.form-body::-webkit-scrollbar { display: none; }

/* inline timed logger */
.timed-logger {
  display: flex; align-items: center; gap: 8;
}
.count-stepper {
  display: flex; align-items: center; gap: 10;
}
