/* ---------- Themes ----------
   "Auto" (no data-theme) follows the device's light/dark setting.
   Every theme sets the same tokens; the rest of the file only uses tokens. */

:root {
  --bg: #f4f6f3;
  --bg-glow: #dcefe3;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --text: #1c2420;
  --muted: #69746e;
  --line: #e0e6e1;
  --accent: #2f8a5c;
  --accent-2: #5cc08b;
  --accent-text: #ffffff;
  --accent-soft: #e1f3e8;
  --danger: #c8443a;
  --warn-bg: #fff4d6;
  --shadow: 0 1px 2px rgb(20 40 30 / 0.06), 0 6px 18px rgb(20 40 30 / 0.07);
  --tile-l: 94%;
  --tile-s: 60%;
  --radius: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #111613;
    --bg-glow: #17271e;
    --surface: #1a211d;
    --surface-2: #222b26;
    --text: #e6ece8;
    --muted: #8e9a93;
    --line: #2b3530;
    --accent: #4dbb85;
    --accent-2: #7fd8a9;
    --accent-text: #0b130e;
    --accent-soft: #1f3a2b;
    --danger: #ec6c60;
    --warn-bg: #3a3320;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 22px rgb(0 0 0 / 0.25);
    --tile-l: 20%;
    --tile-s: 35%;
    color-scheme: dark;
  }
}

/* Light uses the :root values above. "only light" also stops Android and
   Samsung browsers' forced dark mode from recoloring it. */
[data-theme="light"] { color-scheme: only light; }

[data-theme="dark"] {
  --bg: #111613;
  --bg-glow: #17271e;
  --surface: #1a211d;
  --surface-2: #222b26;
  --text: #e6ece8;
  --muted: #8e9a93;
  --line: #2b3530;
  --accent: #4dbb85;
  --accent-2: #7fd8a9;
  --accent-text: #0b130e;
  --accent-soft: #1f3a2b;
  --danger: #ec6c60;
  --warn-bg: #3a3320;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 22px rgb(0 0 0 / 0.25);
  --tile-l: 20%;
  --tile-s: 35%;
  color-scheme: dark;
}

[data-theme="ocean"] {
  --bg: #0d1724;
  --bg-glow: #12304a;
  --surface: #142233;
  --surface-2: #1b2d42;
  --text: #e3eef8;
  --muted: #8aa1b8;
  --line: #24374d;
  --accent: #38bdf8;
  --accent-2: #67e8f9;
  --accent-text: #06202e;
  --accent-soft: #123a52;
  --danger: #f87171;
  --warn-bg: #2c2f22;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.35), 0 8px 24px rgb(0 10 25 / 0.35);
  --tile-l: 21%;
  --tile-s: 40%;
  color-scheme: dark;
}

[data-theme="sakura"] {
  --bg: #fdf3f5;
  --bg-glow: #fbdbe4;
  --surface: #ffffff;
  --surface-2: #fbe9ee;
  --text: #3a2229;
  --muted: #94707b;
  --line: #f1d9e0;
  --accent: #d6457a;
  --accent-2: #f28ab2;
  --accent-text: #ffffff;
  --accent-soft: #fde1ec;
  --danger: #c0392b;
  --warn-bg: #fff1d9;
  --shadow: 0 1px 2px rgb(120 30 60 / 0.06), 0 6px 18px rgb(120 30 60 / 0.08);
  --tile-l: 95%;
  --tile-s: 70%;
  color-scheme: only light;
}

[data-theme="mango"] {
  --bg: #fff8ec;
  --bg-glow: #ffe4b8;
  --surface: #ffffff;
  --surface-2: #fdefd6;
  --text: #3a2a14;
  --muted: #8f7757;
  --line: #f2e2c7;
  --accent: #e8730c;
  --accent-2: #f9b233;
  --accent-text: #ffffff;
  --accent-soft: #ffe7c7;
  --danger: #c0392b;
  --warn-bg: #fff1c2;
  --shadow: 0 1px 2px rgb(120 70 0 / 0.07), 0 6px 18px rgb(120 70 0 / 0.08);
  --tile-l: 94%;
  --tile-s: 75%;
  color-scheme: only light;
}

[data-theme="midnight"] {
  --bg: #120f1f;
  --bg-glow: #2a1f4d;
  --surface: #1b1730;
  --surface-2: #241f3d;
  --text: #ebe6fa;
  --muted: #9a92b8;
  --line: #2e2850;
  --accent: #a78bfa;
  --accent-2: #f0abfc;
  --accent-text: #170f2e;
  --accent-soft: #2f2560;
  --danger: #fb7185;
  --warn-bg: #33293a;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.35), 0 8px 24px rgb(10 0 30 / 0.4);
  --tile-l: 22%;
  --tile-s: 38%;
  color-scheme: dark;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s, color 0.3s;
}
body {
  background:
    radial-gradient(120% 60% at 50% -10%, var(--bg-glow), transparent 60%) fixed,
    var(--bg);
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }

/* Instant press feedback on everything tappable. */
button:not(:disabled):active,
.btn:not(:disabled):active { transform: scale(0.96); }
button, .btn { transition: transform 0.12s ease, background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s; }

:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* ---------- Header, tab bar ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 12px) max(16px, calc((100% - 760px) / 2 + 16px)) 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.top h1 {
  flex: 1;
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon.back {
  font-size: 1.6rem;
  line-height: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 40px);
}
main.enter { animation: view-in 0.28s ease-out; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Corner menu */
.menu-btn {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: var(--shadow);
}
.menu-btn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.menu-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--muted);
}
.menu-dot.error { background: var(--danger); }

.menu-backdrop { position: fixed; inset: 0; z-index: 14; }
.menu {
  position: fixed;
  z-index: 15;
  top: calc(env(safe-area-inset-top) + 60px);
  right: max(16px, calc((100% - 760px) / 2 + 16px));
  min-width: 220px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.22);
  transform-origin: top right;
  animation: menu-in 0.16s ease-out;
}
@keyframes menu-in {
  from { opacity: 0; transform: scale(0.92) translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.menu-item {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  font-weight: 700;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu-status {
  margin-top: 4px;
  padding: 8px 12px 6px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}
.menu-status::before { content: "● "; }
.menu-status.ok::before { color: var(--accent); }
.menu-status.syncing::before { color: #d9a521; }
.menu-status.error { color: var(--danger); }

/* ---------- Controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2)));
  color: var(--accent-text);
  font-weight: 800;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); box-shadow: none; }
.btn.small { padding: 6px 12px; font-size: 0.9rem; }
.btn.wide { width: 100%; margin-bottom: 14px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.icon {
  border: 0;
  background: none;
  color: var(--muted);
  min-width: 38px;
  min-height: 38px;
  font-size: 1.05rem;
  border-radius: 10px;
}
.icon:hover { background: var(--surface-2); }
.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 8px 0;
  font-weight: 800;
}

input, select {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.add-row { display: flex; gap: 8px; margin: -4px 0 20px; }
.add-row input { flex: 1; font-size: 1.05rem; box-shadow: var(--shadow); }

/* ---------- Home: category tiles ---------- */

.empty { text-align: center; color: var(--muted); padding: 28px 10px 8px; }
.empty strong { color: var(--text); font-size: 1.2rem; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.cat-tile {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, hsl(var(--h) 60% 50%) 25%, var(--line));
  border-radius: 20px;
  background: linear-gradient(150deg, hsl(var(--h) var(--tile-s) var(--tile-l)), var(--surface) 75%);
  box-shadow: var(--shadow);
  text-align: left;
}
.cat-tile::after {
  /* a soft colored blob in the corner */
  content: "";
  position: absolute;
  right: -22px;
  bottom: -22px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: hsl(var(--h) 65% 55% / 0.22);
}
.cat-name { font-size: 1.15rem; font-weight: 800; overflow-wrap: anywhere; }
.cat-count {
  color: hsl(var(--h) 45% 40%);
  background: hsl(var(--h) 70% 50% / 0.14);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}
[data-theme="dark"] .cat-count, [data-theme="ocean"] .cat-count, [data-theme="midnight"] .cat-count { color: hsl(var(--h) 60% 75%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .cat-count { color: hsl(var(--h) 60% 75%); }
}
.cat-tile.add {
  justify-content: center;
  align-items: center;
  border: 2px dashed var(--line);
  background: none;
  box-shadow: none;
  color: var(--accent);
  font-weight: 800;
}
.cat-tile.add::after { display: none; }

/* ---------- Items ---------- */

.rows, .items { list-style: none; margin: 0; padding: 0; }
.rows > li + li, .items > li + li { border-top: 1px solid var(--line); }

.items {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.item { display: flex; align-items: center; gap: 12px; padding: 7px 8px 7px 14px; }
.item.enter { animation: item-in 0.3s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes item-in {
  from { opacity: 0; transform: translateX(-14px); background: var(--accent-soft); }
  to { opacity: 1; transform: none; }
}
.item .text { flex: 1; padding: 9px 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.check {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--accent);
  background: none;
  color: var(--accent-text);
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1;
}
.item.is-done .check { background: var(--accent); }
.item.is-done .text { color: var(--muted); text-decoration: line-through; }
.item.pop .check { animation: check-pop 0.4s cubic-bezier(0.3, 1.8, 0.5, 1); }
@keyframes check-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.hint { color: var(--muted); padding: 16px; text-align: center; }

.done-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0 4px;
}


/* ---------- Cards, forms ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 8px; font-size: 1.1rem; font-weight: 800; }
.card p { margin: 6px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.card .actions { justify-content: flex-start; }
.form .actions { justify-content: flex-end; }

.form label { display: block; font-size: 0.85rem; font-weight: 700; color: var(--muted); margin-bottom: 12px; }
.form label input, .form label select { margin-top: 5px; color: var(--text); font-weight: 400; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--warn-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

/* Theme swatches in Settings */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}
.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 8px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
}
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.swatch-dots { display: flex; }
.swatch-dots span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  margin-left: -6px;
}
.swatch-dots span:first-child { margin-left: 0; }

/* ---------- Reminders ---------- */

.rows:has(.reminder) {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.reminder { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 14px; }
.r-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 9px 0;
  border: 0;
  background: none;
  text-align: left;
  min-width: 0;
}
.r-title { font-weight: 800; overflow-wrap: anywhere; }
.r-meta { color: var(--muted); font-size: 0.85rem; }
.r-meta.overdue { color: var(--danger); }
.reminder.is-past .r-title { color: var(--muted); font-weight: 400; }

/* ---------- Settings: devices ---------- */

.device {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 4px;
}

.sub { font-size: 0.95rem; color: var(--muted); margin: 20px 4px 8px; }
.small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 0.9rem; }
code { font-size: 0.85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
code.sel { user-select: all; word-break: break-all; }
details summary { cursor: pointer; margin-top: 10px; font-weight: 700; }
ol.small { padding-left: 20px; }

/* ---------- Bigger screens ---------- */

@media (min-width: 700px) {
  html, body { font-size: 17px; }
  main { padding-top: 24px; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
  .cat-tile { min-height: 140px; padding: 20px; }
  .cat-name { font-size: 1.3rem; }
  .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; align-items: start; }
}

/* ---------- Mascot: pops up big in the middle of the screen ---------- */

.mascot {
  --m-body: #6fd39b;
  --m-dark: #24563d;
  position: fixed;
  left: 50%;
  top: 48%;
  z-index: 20;
  width: min(44vw, 190px);
  pointer-events: none; /* never blocks taps */
  opacity: 0;
  transform: translate(-50%, -35%) scale(0.45) rotate(-8deg);
  transition: opacity 0.18s ease, transform 0.42s cubic-bezier(0.3, 1.5, 0.5, 1);
  will-change: transform, opacity;
}
.mascot.show { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
.mascot::before {
  /* soft glow behind her so she stands out without being bright */
  content: "";
  position: absolute;
  inset: -18% -18% -6%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 68%);
  z-index: -1;
}
.m-figure { position: relative; transform-origin: 50% 90%; }
.m-figure svg {
  display: block;
  width: 100%;
  overflow: visible;
}

/* Sprout */
.s-body { fill: var(--m-body); stroke: var(--m-dark); stroke-width: 2.5; }
.s-foot { fill: #4fb57e; stroke: var(--m-dark); stroke-width: 2.5; }
.s-stem { fill: none; stroke: var(--m-dark); stroke-width: 3; stroke-linecap: round; }
.s-leaf { fill: #8be3b0; stroke: var(--m-dark); stroke-width: 2.5; stroke-linejoin: round; }
.s-shine { fill: #ffffff; opacity: 0.45; }

/* Mali */
.mascot-mali { --m-dark: #3a2522; }
.g-hair { fill: #121214; stroke: #4a4a55; stroke-width: 2; stroke-linejoin: round; }
.g-shine { fill: none; stroke: #5d5d6b; stroke-width: 2.5; stroke-linecap: round; opacity: 0.8; }
.g-skin { fill: #e8bf9c; stroke: #ad7856; stroke-width: 2; }
.g-top { fill: #3a73b8; stroke: #234f85; stroke-width: 2; stroke-linejoin: round; }
.g-band { fill: #ddb052; }
.g-petal { fill: #c47fcd; stroke: #8d4597; stroke-width: 1.2; }
.g-flower-mid { fill: #f2d877; }

/* Ern */
.mascot-ern { --m-dark: #2a1d16; }
.e-hair { fill: #6b4630; stroke: #3b2618; stroke-width: 2; stroke-linejoin: round; }
.e-shine { fill: none; stroke: #9a6d4f; stroke-width: 2.5; stroke-linecap: round; opacity: 0.8; }
.e-skin { fill: #efcaa8; stroke: #b5815e; stroke-width: 2; }
.e-nose { fill: #e3b590; stroke: #b5815e; stroke-width: 2; stroke-linejoin: round; }
.e-hoodie { fill: #353843; stroke: #1f2128; stroke-width: 2; stroke-linejoin: round; }
.e-hood { fill: none; stroke: #4c5060; stroke-width: 2.5; stroke-linecap: round; }
.e-string { fill: none; stroke: #c9cbd3; stroke-width: 1.6; stroke-linecap: round; }
.e-glasses circle { fill: rgb(255 255 255 / 0.14); stroke: #26262d; stroke-width: 2.2; }
.e-glasses path { fill: none; stroke: #26262d; stroke-width: 2.2; stroke-linecap: round; }

/* Shared parts */
.m-ground { fill: rgb(0 0 0 / 0.18); }
.m-cheek { fill: #f08ea0; opacity: 0.6; }
.m-eyes-open ellipse { fill: var(--m-dark); }
.m-glint { fill: #ffffff; opacity: 0.9; }
.m-eyes-happy path, .m-smile {
  fill: none;
  stroke: var(--m-dark);
  stroke-width: 3.5;
  stroke-linecap: round;
}
.m-grin { fill: var(--m-dark); }
.m-o { fill: var(--m-dark); }

/* Faces: neutral smile by default, swapped by data-mood. */
.m-eyes-happy, .m-grin, .m-o { display: none; }
.mascot[data-mood="happy"] .m-eyes-open,
.mascot[data-mood="happy-open"] .m-eyes-open { display: none; }
.mascot[data-mood="happy"] .m-eyes-happy,
.mascot[data-mood="happy-open"] .m-eyes-happy { display: inline; }
.mascot[data-mood="happy-open"] .m-smile,
.mascot[data-mood="wow"] .m-smile { display: none; }
.mascot[data-mood="happy-open"] .m-grin { display: inline; }
.mascot[data-mood="wow"] .m-o { display: inline; }

.m-eyes-open {
  transform-box: fill-box;
  transform-origin: center;
  animation: m-blink 3.2s infinite;
}
@keyframes m-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}
.s-leaf { transform-origin: 51px 12px; animation: m-sway 2.4s ease-in-out infinite; }
.g-flower { transform-origin: 71px 35px; animation: m-sway 2.8s ease-in-out infinite; }
@keyframes m-sway {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}

.mascot.hop .m-figure { animation: m-hop 0.55s ease-out; }
@keyframes m-hop {
  0% { transform: translateY(0) scale(1, 1); }
  20% { transform: translateY(0) scale(1.1, 0.88); }
  50% { transform: translateY(-12%) scale(0.94, 1.08); }
  80% { transform: translateY(0) scale(1.06, 0.94); }
  100% { transform: translateY(0) scale(1, 1); }
}
.mascot.cheer .m-figure { animation: m-cheer 1s ease-out; }
@keyframes m-cheer {
  0% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-14%) rotate(-12deg); }
  50% { transform: translateY(-18%) rotate(12deg) scale(1.08); }
  75% { transform: translateY(-5%) rotate(-6deg); }
  100% { transform: translateY(0) rotate(0); }
}
.mascot.wobble .m-figure { animation: m-wobble 0.5s ease-in-out; }
@keyframes m-wobble {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(8deg); }
}

.m-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  white-space: nowrap;
  background: var(--surface);
  color: var(--text);
  border: 2.5px solid var(--accent);
  border-radius: 18px;
  padding: 7px 16px;
  font-weight: 900;
  font-size: 1.25rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 8px) scale(0.5);
  transform-origin: 50% 100%;
  transition: opacity 0.18s, transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.m-bubble::after {
  /* little tail pointing down at her */
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-right: 2.5px solid var(--accent);
  border-bottom: 2.5px solid var(--accent);
  transform: translateX(-50%) rotate(45deg);
}
.mascot.talk .m-bubble { opacity: 1; transform: translate(-50%, 0) scale(1); }

.m-sparkle {
  position: absolute;
  left: 50%;
  top: 40%;
  color: hsl(var(--hue) 90% 62%);
  font-size: 22px;
  animation: m-sparkle 0.85s ease-out forwards;
}
@keyframes m-sparkle {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(90deg); opacity: 0; }
}

/* ---------- Toasts ---------- */

#toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 14px;
  max-width: 480px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  animation: view-in 0.25s ease-out;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01s !important; }
  .mascot { transform: translate(-50%, -50%); }
  .m-sparkle { display: none; }
}
