/* ---------- fonts ---------- */
@font-face { font-family: 'Fredoka'; src: url('/fonts/fredoka.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('/fonts/nunito.woff2') format('woff2'); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: 'Bricolage Grotesque'; src: url('/fonts/bricolage.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }

/* ---------- themes ---------- */
:root, [data-theme="night"] {
  --bg: linear-gradient(180deg, #0F0C2E 0%, #221A55 55%, #3A2468 100%);
  --bg-solid: #1B1648;
  --ink: #F5F3FF;
  --muted: #C9C4EC;
  --accent: #FFD166;
  --accent-2: #FF9F7A;
  --on-accent: #2B1F5C;
  --card-bg: rgba(255, 255, 255, 0.07);
  --card-border: 1px solid rgba(255, 255, 255, 0.14);
  --card-shadow: none;
  --task-done-bg: rgba(255, 209, 102, 0.14);
  --task-done-border: rgba(255, 209, 102, 0.55);
  --check-border: 2px dashed rgba(255, 255, 255, 0.5);
  --check-done-bg: var(--accent);
  --check-done-ink: var(--on-accent);
  --glow: 0 0 18px rgba(255, 209, 102, 0.7);
  --field-bg: rgba(255, 255, 255, 0.08);
  --field-border: rgba(255, 255, 255, 0.22);
  --tab-bg: rgba(15, 12, 46, 0.82);
  --danger: #FF8A8A;
  --ok: #8FF0C4;
  --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --radius: 20px;
  --sky: 1;
  --aurora: 0;
  color-scheme: dark;
}

[data-theme="aurora"] {
  --bg: linear-gradient(180deg, #050F1A 0%, #0B2A3A 60%, #12404A 100%);
  --bg-solid: #0B1E2D;
  --muted: #BFDCE0;
  --accent: #7CF5C8;
  --accent-2: #B693FF;
  --on-accent: #06231C;
  --task-done-bg: rgba(124, 245, 200, 0.13);
  --task-done-border: rgba(124, 245, 200, 0.55);
  --glow: 0 0 18px rgba(124, 245, 200, 0.7);
  --tab-bg: rgba(5, 15, 26, 0.82);
  --aurora: 1;
}

[data-theme="pet"] {
  --bg: #FFF4EC;
  --bg-solid: #FFF4EC;
  --ink: #3B2546;
  --muted: #6E5878;
  --accent: #FF6F91;
  --accent-2: #FFD66B;
  --on-accent: #3B2546;
  --card-bg: #FFFFFF;
  --card-border: 0;
  --card-shadow: 0 3px 0 #F2D9CC;
  --task-done-bg: #FFE3EA;
  --task-done-border: transparent;
  --check-border: 3px solid #D9BFCB;
  --check-done-bg: #FF6F91;
  --check-done-ink: #FFFFFF;
  --glow: none;
  --field-bg: #FFFFFF;
  --field-border: #E5CFD8;
  --tab-bg: rgba(255, 244, 236, 0.9);
  --danger: #C62845;
  --ok: #1E7F5C;
  --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --radius: 22px;
  --sky: 0;
  color-scheme: light;
}

[data-theme="sticker"] {
  --bg: #D9CCFF;
  --bg-solid: #D9CCFF;
  --ink: #1A1A1A;
  --muted: #3D3557;
  --accent: #FF5FA2;
  --accent-2: #C6F432;
  --on-accent: #1A1A1A;
  --card-bg: #FFFFFF;
  --card-border: 3px solid #1A1A1A;
  --card-shadow: 4px 4px 0 #1A1A1A;
  --task-done-bg: #C6F432;
  --task-done-border: #1A1A1A;
  --check-border: 3px solid #1A1A1A;
  --check-done-bg: #FFFFFF;
  --check-done-ink: #1A1A1A;
  --glow: none;
  --field-bg: #FFFFFF;
  --field-border: #1A1A1A;
  --tab-bg: rgba(217, 204, 255, 0.92);
  --danger: #B00040;
  --ok: #1E6B2E;
  --font-display: 'Bricolage Grotesque', 'Nunito', system-ui, sans-serif;
  --radius: 16px;
  --sky: 0;
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg-solid); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { -webkit-appearance: none; appearance: none; }
[hidden] { display: none !important; }
a { color: var(--accent); }
svg { flex: none; }
hr { border: 0; border-top: 1px solid var(--field-border); margin: 14px 0; opacity: 0.6; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.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; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.accent { color: var(--accent); }
.center { text-align: center; justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* sky + aurora backgrounds */
#sky, #aurora { position: fixed; inset: 0; pointer-events: none; z-index: 0; transition: opacity 0.6s; }
#sky { opacity: var(--sky); }
#sky i {
  position: absolute; width: var(--s); height: var(--s); border-radius: 50%; background: #fff;
  opacity: var(--o); animation: twinkle var(--tw) ease-in-out var(--d) infinite alternate;
}
@keyframes twinkle { to { opacity: calc(var(--o) * 0.25); } }
#aurora { opacity: var(--aurora); overflow: hidden; }
#aurora span {
  position: absolute; width: 140vw; height: 38vh; left: -20vw; top: -6vh; border-radius: 50%;
  filter: blur(48px); opacity: 0.45; animation: aurora 14s ease-in-out infinite alternate;
  background: radial-gradient(closest-side, #46F2B2, transparent);
}
#aurora span:nth-child(2) { top: 4vh; background: radial-gradient(closest-side, #8A6CFF, transparent); animation-duration: 18s; animation-delay: -6s; }
#aurora span:nth-child(3) { top: 14vh; background: radial-gradient(closest-side, #2FD3E8, transparent); animation-duration: 22s; animation-delay: -3s; opacity: 0.3; }
@keyframes aurora { from { transform: translateX(-12vw) rotate(-6deg) scaleY(0.8); } to { transform: translateX(12vw) rotate(5deg) scaleY(1.15); } }

#app { position: relative; z-index: 1; }

.screen {
  max-width: 480px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 22px) 18px calc(env(safe-area-inset-bottom, 0px) + 104px);
  display: flex; flex-direction: column; gap: 16px;
}
.screen.setup { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 32px); gap: 18px; }
.screen.center { min-height: 80vh; align-items: center; justify-content: center; }

/* ---------- type ---------- */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 32px; line-height: 1.1; letter-spacing: -0.01em; }
[data-theme="sticker"] .title { font-weight: 800; letter-spacing: -0.02em; }
.title--xl { font-size: 40px; }
.lead { margin: 0; font-size: 17px; color: var(--muted); }
.lead b { color: var(--ink); }
.label { display: block; margin: 0; font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.section-title { margin: 8px 0 0; font-family: var(--font-display); font-size: 21px; font-weight: 600; }
.error { margin: 0; color: var(--danger); font-weight: 700; }
.ok { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ok); font-weight: 800; }
.ok svg { width: 20px; height: 20px; }
.note {
  margin: 0; padding: 12px 14px; border-radius: 14px; font-size: 14.5px;
  background: var(--card-bg); border: var(--card-border); color: var(--muted);
}
.note b { color: var(--ink); }
.note svg { width: 16px; height: 16px; vertical-align: -2px; color: var(--accent); }
.code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: 0.06em; color: var(--ink); white-space: nowrap; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 800;
  background: var(--task-done-bg); color: var(--ink); vertical-align: 1px;
}

/* ---------- streak pill ---------- */
.streak-pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--accent); font-family: var(--font-display); font-size: 20px; font-weight: 700;
}
.streak-pill svg { width: 20px; height: 20px; }
[data-theme="pet"] .streak-pill { background: #fff; border: 0; box-shadow: var(--card-shadow); color: var(--ink); }
[data-theme="pet"] .streak-pill svg { color: var(--accent); }
[data-theme="sticker"] .streak-pill {
  background: var(--accent); color: #1A1A1A; border: 3px solid #1A1A1A; box-shadow: 3px 3px 0 #1A1A1A; transform: rotate(3deg);
  font-weight: 800;
}

/* ---------- cards ---------- */
.card {
  background: var(--card-bg); border: var(--card-border); box-shadow: var(--card-shadow);
  border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.card-title { margin: 0; display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.card-title svg { width: 20px; height: 20px; color: var(--accent); }
[data-theme="sticker"] .card-title svg { color: #1A1A1A; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card.empty { align-items: center; text-align: center; padding: 28px 20px; }
.card p { margin: 0; }
.stats { flex-direction: row; justify-content: space-around; text-align: center; }
.stats div { display: flex; flex-direction: column; gap: 2px; }
.stat { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--accent); line-height: 1; }
[data-theme="sticker"] .stat, [data-theme="pet"] .stat { color: var(--ink); }
.stats span { font-size: 13px; font-weight: 700; color: var(--muted); }

/* ---------- hero ---------- */
.hero { display: flex; flex-direction: column; gap: 10px; }
.hero-row { display: flex; justify-content: space-between; font-size: 14px; font-weight: 800; color: var(--muted); }
.hero-row b { color: var(--ink); }
.hero-title { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.hero-text { margin: 0; color: var(--muted); }
.hero--off { align-items: center; text-align: center; padding: 12px 8px; }

.bar { height: 12px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 13%, transparent); overflow: hidden; }
.bar--thin { height: 8px; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.5s cubic-bezier(.2, .9, .3, 1.2); }
[data-theme="pet"] .bar { background: #F6DCD0; }
[data-theme="pet"] .bar-fill { background: var(--accent); }
[data-theme="sticker"] .bar { background: #fff; border: 2px solid #1A1A1A; height: 14px; }
[data-theme="sticker"] .bar-fill { background: var(--accent); border-radius: 0; }

.constellation { width: 100%; height: auto; overflow: visible; }
.constellation--big { max-width: 300px; }
.c-line { stroke: color-mix(in srgb, var(--ink) 30%, transparent); stroke-width: 2; stroke-dasharray: 4 6; transition: stroke 0.4s; }
.c-line.is-lit { stroke: var(--accent); stroke-dasharray: none; opacity: 0.7; }
.c-star polygon { fill: color-mix(in srgb, var(--ink) 22%, transparent); transition: fill 0.3s; }
.c-glow { fill: var(--accent); opacity: 0; transition: opacity 0.4s; }
.c-star.is-lit polygon { fill: var(--accent); }
.c-star.is-lit .c-glow { opacity: 0.22; }
.c-star.pop polygon { animation: star-pop 0.6s cubic-bezier(.2, 1.6, .4, 1); transform-box: fill-box; transform-origin: center; }
.c-star.pop .c-glow { animation: glow-burst 0.7s ease-out; }
@keyframes star-pop { 0% { scale: 0.4; } 60% { scale: 1.5; } 100% { scale: 1; } }
@keyframes glow-burst { 0% { opacity: 0.8; r: 6; } 100% { opacity: 0.22; r: 20; } }

.moon-big { color: var(--accent); filter: drop-shadow(0 0 24px color-mix(in srgb, var(--accent) 50%, transparent)); }
.moon-big svg { width: 72px; height: 72px; }
.moon-big--hero svg { width: 96px; height: 96px; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; transform: scale(0.94); } }

/* pet */
.pet-scene {
  position: relative; height: 210px; border-radius: 28px; overflow: hidden; background: #BDF0E0;
  display: flex; align-items: flex-end; justify-content: center;
}
.pet-scene::before { content: ''; position: absolute; left: -20px; right: -20px; bottom: -44px; height: 92px; border-radius: 50%; background: #8FDCC4; }
.pet-scene::after { content: ''; position: absolute; top: 18px; right: 22px; width: 40px; height: 40px; border-radius: 50%; background: #FFE9A8; }
.pet-scene .pip { position: relative; margin-bottom: 16px; z-index: 1; }
.bubble { position: absolute; left: 14px; top: 14px; z-index: 2; padding: 6px 12px; border-radius: 999px; background: #fff; font-weight: 800; font-size: 14px; }
.pip-body { transform-box: fill-box; transform-origin: 50% 100%; animation: pip-breathe 3s ease-in-out infinite; }
.pip--overjoyed .pip-body { animation: pip-bounce 0.7s ease-in-out infinite; }
.pip--sleepy .pip-body { animation-duration: 5s; }
.pip-heart { animation: float-up 1.4s ease-in-out infinite; }
@keyframes pip-breathe { 50% { transform: scale(1.02, 0.97); } }
@keyframes pip-bounce { 50% { transform: translateY(-10px) scale(0.98, 1.03); } }
@keyframes float-up { 50% { transform: translateY(-6px); } }

/* sticker */
.hero--sticker { flex-direction: row; align-items: center; gap: 16px; }
.sticker-copy { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sticker-slot {
  flex: none; width: 104px; height: 104px; display: flex; align-items: center; justify-content: center;
  border-radius: 22px; border: 3px dashed #1A1A1A; background: #F1ECFF; transform: rotate(-4deg);
}
.sticker-slot.is-won { border-style: solid; background: #FFF8E6; box-shadow: 4px 4px 0 #1A1A1A; animation: sticker-slap 0.5s cubic-bezier(.2, 1.6, .4, 1); }
.sticker-slot--big { width: 150px; height: 150px; margin: 0 auto; }
.mystery { font-family: var(--font-display); font-size: 48px; font-weight: 800; }
@keyframes sticker-slap { from { transform: rotate(-20deg) scale(1.6); opacity: 0; } }

/* ---------- tasks ---------- */
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task {
  width: 100%; min-height: 66px; display: flex; align-items: center; gap: 14px; padding: 12px 16px; text-align: left; cursor: pointer;
  background: var(--card-bg); border: var(--card-border); box-shadow: var(--card-shadow); border-radius: var(--radius);
  transition: background 0.25s, border-color 0.25s, transform 0.12s, box-shadow 0.12s;
  touch-action: manipulation;
}
.task:active { transform: scale(0.98); }
.task.is-done { background: var(--task-done-bg); border-color: var(--task-done-border); }
.task-check {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: var(--check-border);
  display: flex; align-items: center; justify-content: center; transition: background 0.2s;
}
.task.is-done .task-check { border: 0; background: var(--check-done-bg); color: var(--check-done-ink); box-shadow: var(--glow); }
.task-check svg { width: 21px; height: 21px; }
.task.pop .task-check { animation: check-pop 0.5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes check-pop { 0% { transform: scale(0.3); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
.task-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.task-title { font-weight: 800; font-size: 17px; }
.task-hint { font-size: 14px; color: var(--muted); }
.task-mine { color: var(--accent); }
.task-mine svg { width: 18px; height: 18px; }

[data-theme="pet"] .task-check { border-radius: 12px; }
[data-theme="sticker"] .task-check { border-radius: 9px; width: 32px; height: 32px; }
[data-theme="sticker"] .task.is-done { transform: translate(4px, 4px); box-shadow: 0 0 0 #1A1A1A; }
[data-theme="sticker"] .task.is-done .task-check { border: 3px solid #1A1A1A; }
[data-theme="sticker"] .task-title { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
[data-theme="sticker"] .task-mine { color: #1A1A1A; }

.done-banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); font-family: var(--font-display); font-size: 18px; font-weight: 600;
  animation: rise 0.5s cubic-bezier(.2, 1.4, .4, 1);
}
.done-banner svg { width: 26px; height: 26px; }
[data-theme="sticker"] .done-banner { border: 3px solid #1A1A1A; box-shadow: 4px 4px 0 #1A1A1A; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

/* ---------- week strip ---------- */
.week-row { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.night { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.night-dot {
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 2px solid color-mix(in srgb, var(--ink) 22%, transparent); color: var(--accent);
}
.night-dot svg { width: 18px; height: 18px; }
.night-day { font-size: 13px; font-weight: 800; color: var(--muted); }
.night--done .night-dot { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.night--off .night-dot { border-style: dotted; color: var(--muted); }
.night--off .night-dot svg { width: 14px; height: 14px; }
.night--pending .night-dot { border: 2px dashed var(--accent); }
.night--before .night-dot { opacity: 0.3; }
.night--missed .night-dot { opacity: 0.55; }
[data-theme="sticker"] .night-dot { border-radius: 12px; border: 2px solid #1A1A1A; background: #FFF8E6; }
[data-theme="sticker"] .night--done .night-dot { background: #FFF8E6; border-color: #1A1A1A; }
[data-theme="sticker"] .night-dot svg { width: 28px; height: 28px; }
[data-theme="sticker"] .night--off .night-dot svg { width: 14px; height: 14px; color: #1A1A1A; }
[data-theme="pet"] .night--done .night-dot { background: #FFE3EA; border-color: #FF9DB5; }

/* ---------- rewards ---------- */
.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badge {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; text-align: center;
  background: var(--card-bg); border: var(--card-border); box-shadow: var(--card-shadow); border-radius: var(--radius);
}
.badge b { font-size: 14px; line-height: 1.2; }
.badge span { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.badge:not(.is-earned) { opacity: 0.6; }
.badge-art polyline { stroke: color-mix(in srgb, var(--ink) 35%, transparent); stroke-width: 1.5; }
.badge-art circle { fill: color-mix(in srgb, var(--ink) 35%, transparent); }
.badge-art.is-earned polyline { stroke: var(--accent); }
.badge-art.is-earned circle { fill: var(--accent); }
[data-theme="sticker"] .badge-art.is-earned circle, [data-theme="sticker"] .badge-art.is-earned polyline { fill: #1A1A1A; stroke: #1A1A1A; }

.themes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.theme-card {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px; text-align: left; cursor: pointer;
  background: var(--card-bg); border: var(--card-border); box-shadow: var(--card-shadow); border-radius: var(--radius);
}
.theme-card:disabled { cursor: default; opacity: 0.6; color: var(--ink); background: var(--card-bg); }
.theme-card.is-current { outline: 3px solid var(--accent); outline-offset: -3px; }
.theme-text { flex: 1; display: flex; flex-direction: column; }
.theme-text span { font-size: 14px; color: var(--muted); }
.theme-state { font-weight: 800; font-size: 14px; color: var(--accent); }
.theme-state svg { width: 20px; height: 20px; color: var(--muted); }
[data-theme="sticker"] .theme-state { color: #1A1A1A; }
.swatch { width: 52px; height: 52px; border-radius: 14px; flex: none; border: 2px solid rgba(255, 255, 255, 0.25); }
.swatch--night { background: radial-gradient(circle at 70% 30%, #FFD166 0 5px, transparent 6px), linear-gradient(160deg, #0F0C2E, #3A2468); }
.swatch--sticker { background: radial-gradient(circle at 35% 40%, #FF5FA2 0 9px, transparent 10px), radial-gradient(circle at 68% 64%, #C6F432 0 8px, transparent 9px), #D9CCFF; border-color: #1A1A1A; }
.swatch--pet { background: radial-gradient(ellipse 15px 13px at 50% 60%, #FFB3C6 98%, transparent), linear-gradient(#BDF0E0 65%, #8FDCC4 65%); }
.swatch--aurora { background: radial-gradient(ellipse at 30% 30%, rgba(70, 242, 178, 0.9), transparent 60%), radial-gradient(ellipse at 75% 45%, rgba(138, 108, 255, 0.9), transparent 55%), #071624; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 12px 20px;
  border-radius: 16px; border: 0; cursor: pointer; text-decoration: none; font-weight: 800; font-size: 16.5px;
  touch-action: manipulation; transition: transform 0.1s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn svg { width: 20px; height: 20px; }
.btn--primary { background: var(--accent); color: var(--on-accent); font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.btn--ghost { background: var(--card-bg); color: var(--ink); border: var(--card-border); box-shadow: var(--card-shadow); }
.btn--quiet { background: transparent; color: var(--muted); min-height: 44px; padding: 10px 12px; text-decoration: underline; text-underline-offset: 3px; }
.btn--danger { background: transparent; color: var(--danger); border: 2px solid currentColor; }
.btn--small { min-height: 40px; padding: 8px 12px; font-size: 14.5px; }
.btn--block { width: 100%; }
.btn.is-armed { background: var(--danger); color: #fff; border-color: var(--danger); text-decoration: none; }
[data-theme="sticker"] .btn--primary { border: 3px solid #1A1A1A; box-shadow: 4px 4px 0 #1A1A1A; font-weight: 800; }
[data-theme="pet"] .btn--primary { box-shadow: 0 4px 0 #D94C70; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-row.center { justify-content: center; }

.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: none;
  border-radius: 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: 0.25; cursor: default; }
.icon-btn--danger { color: var(--danger); }
.icon-btn--big svg { width: 26px; height: 26px; }
a.icon-btn { color: var(--ink); }

.back-link {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 0 6px -6px; min-height: 44px; padding: 0 6px;
  color: var(--muted); text-decoration: none; font-weight: 800;
}
.back-link svg { width: 20px; height: 20px; }

.field {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px;
  background: var(--field-bg); border: 2px solid var(--field-border); color: var(--ink); font-size: 17px;
}
.field::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.field:focus { outline: none; border-color: var(--accent); }
.field--hint { min-height: 42px; padding: 8px 12px; font-size: 15px; }
.field--code { text-align: center; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 24px; letter-spacing: 0.12em; text-transform: uppercase; }
.field--time { width: auto; min-width: 140px; }
.input-row { display: flex; gap: 8px; }
.inline-form { display: flex; flex-direction: column; gap: 8px; }

.switch-row, .time-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-weight: 700; }
.switch-row span { display: inline-flex; align-items: center; gap: 8px; }
.switch-row svg { width: 20px; height: 20px; color: var(--accent); }
.time-row.is-disabled { opacity: 0.5; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; width: 54px; height: 32px; border-radius: 999px; margin: 0; cursor: pointer;
  background: color-mix(in srgb, var(--ink) 25%, transparent); position: relative; transition: background 0.2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(22px); }

/* ---------- task editor ---------- */
.editor { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.edit-task { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 16px; background: color-mix(in srgb, var(--ink) 5%, transparent); border: 1px solid var(--field-border); }
.edit-row { display: flex; gap: 4px; align-items: center; }
.edit-tools { display: flex; }
.edit-tools .icon-btn { width: 36px; }
.editor-empty { color: var(--muted); padding: 8px 0; }
.chips { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.chip {
  min-height: 40px; border-radius: 12px; border: 2px solid var(--field-border); background: transparent;
  font-weight: 800; color: var(--muted); cursor: pointer; touch-action: manipulation;
}
.chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
[data-theme="sticker"] .chip.is-on { border-color: #1A1A1A; }
.owner-note { margin: 0; font-size: 13px; font-weight: 800; color: var(--accent); }

.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plain-list li { display: flex; flex-direction: column; gap: 1px; padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
.plain-list li:last-child { border-bottom: 0; }

.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.steps svg { width: 18px; height: 18px; vertical-align: -3px; color: var(--accent); }

/* ---------- set-up & landing ---------- */
.setup .moon-big, .landing .moon-big { align-self: center; margin-top: 12px; }
.landing { min-height: 100vh; min-height: 100dvh; justify-content: center; text-align: center; }
.landing .stack { margin-top: 12px; }
.dots { display: flex; gap: 8px; justify-content: center; }
.dots span { width: 9px; height: 9px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 25%, transparent); transition: width 0.3s; }
.dots span.is-on { width: 26px; border-radius: 999px; background: var(--accent); }
.setup-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.feature-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.feature-list li { display: flex; gap: 12px; align-items: flex-start; font-size: 16.5px; }
.feature-list svg { width: 24px; height: 24px; color: var(--accent); margin-top: 1px; }
.push-area { display: flex; flex-direction: column; gap: 10px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 5; width: 100%; max-width: 480px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 10px calc(env(safe-area-inset-bottom, 0px) + 6px);
  background: var(--tab-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 54px; justify-content: center;
  color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 800; border-radius: 14px;
}
.tab svg { width: 24px; height: 24px; }
.tab.is-active { color: var(--accent); }
[data-theme="sticker"] .tab.is-active { color: #1A1A1A; background: #fff; border: 2px solid #1A1A1A; }
[data-theme="sticker"] .tabbar { border-top: 3px solid #1A1A1A; }

/* ---------- parent ---------- */
.child-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.child-card {
  display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: var(--card-bg); border: var(--card-border);
}
.child-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); font-family: var(--font-display); font-size: 22px; font-weight: 700;
}
.child-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.child-name b { font-size: 19px; }
.bar-fill.is-full { background: var(--ok); }
.mini-week { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; }
.mini { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--ink) 30%, transparent); vertical-align: -2px; }
.mini--done { background: var(--accent); border-color: var(--accent); }
.mini--missed { border-color: var(--danger); }
.mini--off { border-style: dotted; opacity: 0.6; }
.mini--pending { border-style: dashed; border-color: var(--accent); }
.mini--before { opacity: 0.2; }
.legend { margin: 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.legend .mini { margin-left: 6px; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; font-size: 12px; font-weight: 800; color: var(--muted); }
.cal-day { aspect-ratio: 1; border-radius: 9px; border: 2px solid color-mix(in srgb, var(--ink) 18%, transparent); }
.cal--done { background: var(--accent); border-color: var(--accent); }
.cal--missed { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, transparent); }
.cal--off { border-style: dotted; }
.cal--pending { border-style: dashed; border-color: var(--accent); }
.cal--before { opacity: 0.25; }

.tonight-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tonight-list li { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.tonight-list li:not(.is-done) { color: var(--muted); }
.tick { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px dashed color-mix(in srgb, var(--ink) 35%, transparent); display: flex; align-items: center; justify-content: center; }
.is-done .tick { border: 0; background: var(--accent); color: var(--on-accent); }
.tick svg { width: 15px; height: 15px; }

.share-box { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px; background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); }
.share-link { margin: 0; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 14px; word-break: break-all; user-select: all; -webkit-user-select: all; }

/* ---------- celebration ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: color-mix(in srgb, var(--bg-solid) 88%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  overflow: hidden; animation: fade 0.3s ease-out;
}
.celebrate-card {
  position: relative; z-index: 2; width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; padding: 24px 20px 20px; border-radius: 28px;
  background: var(--card-bg); border: var(--card-border); box-shadow: var(--card-shadow);
  animation: card-in 0.6s cubic-bezier(.2, 1.4, .4, 1);
}
[data-theme="night"] .celebrate-card, [data-theme="aurora"] .celebrate-card { background: color-mix(in srgb, var(--bg-solid) 93%, #fff); }
.celebrate-art { display: flex; justify-content: center; width: 100%; }
.celebrate .eyebrow { font-size: 15px; }
.big-num { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 96px; line-height: 0.95; animation: num-in 0.8s cubic-bezier(.2, 1.6, .4, 1) 0.2s both; }
.big-label { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.pill-best { margin: 4px 0 0; padding: 6px 14px; border-radius: 999px; background: var(--accent-2); color: #2B1F5C; font-weight: 800; }
.unlock { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--accent); }
.unlock svg { width: 18px; height: 18px; }
[data-theme="sticker"] .unlock, [data-theme="pet"] .unlock { color: var(--ink); }
.celebrate .btn { margin-top: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes card-in { from { transform: scale(0.8) translateY(30px); opacity: 0; } }
@keyframes num-in { from { transform: scale(0.2); opacity: 0; } }

.confetti {
  position: absolute; top: -30px; left: var(--x); width: var(--size); height: var(--size); z-index: 3; border-radius: 2px; pointer-events: none;
  background: var(--c); animation: confetti-fall var(--dur) cubic-bezier(.25, .4, .5, 1) var(--delay) forwards; opacity: 0;
}
.confetti--star { background: none; }
.confetti--star svg { width: 100%; height: 100%; fill: var(--c); display: block; }
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift), 105vh) rotate(var(--spin)); }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 86px); z-index: 30; max-width: min(440px, calc(100vw - 32px));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
  padding: 12px 18px; border-radius: 16px; background: #fff; color: #221A55; font-weight: 800; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25); text-align: center;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: #FFE3E3; color: #7A0F22; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
