/* Vero's Garden — soft, sparkly, mobile-first */
:root {
  --cream: #fff7ec;
  --cream-2: #ffeedb;
  --paper: #ffffff;
  --ink: #3b3350;
  --muted: #8a8099;
  --leaf: #4caf7a;
  --leaf-dark: #2e8b57;
  --leaf-soft: #dff5e6;
  --pink: #ff8fb1;
  --pink-soft: #ffe3ec;
  --sun: #ffc94d;
  --sky: #8ccbff;
  --lilac: #b79cff;
  --line: #f1e3d0;
  --shadow: 0 6px 18px rgba(120, 80, 40, .10);
  --shadow-lg: 0 14px 40px rgba(80, 50, 120, .22);
  --r-common: #6cc88f;
  --r-uncommon: #5fb5f2;
  --r-rare: #a47dff;
  --r-legendary: #ffb62e;
  --radius: 22px;
  --display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cream: #251f33; --cream-2: #2e2740; --paper: #332b47; --ink: #f6eefc; --muted: #b3a8c7;
    --line: #463c5f; --leaf-soft: #27493a; --pink-soft: #4a2c3d;
    --shadow: 0 6px 18px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--body); color: var(--ink); background: var(--cream);
  min-height: 100vh; padding-bottom: 110px; -webkit-tap-highlight-color: transparent;
  background-image: radial-gradient(circle at 20px 20px, rgba(255, 160, 190, .13) 2px, transparent 3px),
                    radial-gradient(circle at 60px 60px, rgba(76, 175, 122, .12) 2px, transparent 3px);
  background-size: 80px 80px;
}
h1, h2, h3, h4 { font-family: var(--display); margin: 0; font-weight: 600; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--lilac); outline-offset: 2px; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 20; padding: 12px 16px 0;
  background: linear-gradient(var(--cream) 82%, transparent);
  max-width: 920px; margin: 0 auto;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { font-size: 1.45rem; display: flex; align-items: center; gap: 8px; }
.brand-fairy { display: inline-block; animation: float 3.2s ease-in-out infinite; }
.chips { display: flex; gap: 6px; }
.chip {
  background: var(--paper); border: 2px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font-weight: 800; font-size: .9rem; box-shadow: var(--shadow); white-space: nowrap;
}
.chip-btn { padding: 5px 9px; }
.level { margin: 10px 0 8px; }
.level-text { display: flex; justify-content: space-between; font-weight: 800; font-size: .88rem; margin-bottom: 4px; }
.level-text .muted { font-weight: 700; }
.bar { height: 12px; background: var(--cream-2); border-radius: 99px; overflow: hidden; border: 2px solid var(--line); }
.bar-fill {
  height: 100%; width: 0; border-radius: 99px; transition: width .9s cubic-bezier(.2,.9,.3,1.2);
  background: linear-gradient(90deg, var(--pink), var(--sun), var(--leaf));
}
.tabs { display: flex; gap: 8px; padding: 6px 0 10px; }
.tabs button {
  flex: 1; border: 2px solid var(--line); background: var(--paper); border-radius: 16px;
  padding: 9px 8px; font-weight: 800; font-family: var(--display); font-size: 1rem; box-shadow: var(--shadow);
  transition: transform .15s, background .2s;
}
.tabs button.on { background: var(--leaf); border-color: var(--leaf-dark); color: #fff; transform: translateY(-1px); }

/* ---------- Layout ---------- */
main { max-width: 920px; margin: 0 auto; padding: 6px 16px 20px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 10px 2px 12px; }
.section-title h2 { font-size: 1.25rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }

/* ---------- Plant cards ---------- */
.plant-card {
  position: relative; background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); text-align: left; display: flex; flex-direction: column; gap: 10px;
  transition: transform .18s, box-shadow .18s; overflow: hidden;
}
.plant-card:hover { transform: translateY(-3px) rotate(-.4deg); box-shadow: var(--shadow-lg); }
.plant-card::after {
  content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: var(--leaf-soft); opacity: .8; z-index: 0;
}
.plant-top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.plant-emoji {
  width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center; font-size: 2.1rem;
  background: var(--pink-soft); flex: none; overflow: hidden;
}
.plant-emoji img { width: 100%; height: 100%; object-fit: cover; }
.plant-name { font-size: 1.2rem; line-height: 1.1; }
.plant-species { color: var(--muted); font-size: .85rem; font-weight: 700; }
.stage {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  background: var(--leaf-soft); color: var(--leaf-dark); font-weight: 800; font-size: .8rem;
  padding: 3px 10px; border-radius: 99px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stage { color: #9be6b9; } }
.plant-meta { position: relative; z-index: 1; font-size: .85rem; color: var(--muted); font-weight: 700; line-height: 1.5; }
.plant-meta b { color: var(--ink); }
.delta-up { color: var(--leaf-dark); } .delta-down { color: #d4586e; }
.plant-actions { position: relative; z-index: 1; display: flex; gap: 8px; margin-top: 2px; }

.add-plant {
  border: 3px dashed var(--line); background: transparent; border-radius: var(--radius);
  min-height: 150px; display: grid; place-items: center; color: var(--muted); font-weight: 800;
  font-family: var(--display); font-size: 1.05rem; transition: border-color .2s, color .2s, transform .2s;
}
.add-plant:hover { border-color: var(--leaf); color: var(--leaf-dark); transform: scale(1.01); }
.add-plant span { display: block; font-size: 2rem; text-align: center; }

/* ---------- Buttons / form ---------- */
.btn {
  border: 2px solid var(--line); background: var(--paper); border-radius: 14px; padding: 9px 14px;
  font-weight: 800; transition: transform .12s, box-shadow .12s; box-shadow: 0 3px 0 var(--line);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn-primary { background: var(--leaf); color: #fff; border-color: var(--leaf-dark); box-shadow: 0 3px 0 var(--leaf-dark); }
.btn-primary:active { box-shadow: 0 1px 0 var(--leaf-dark); }
.btn-pink { background: var(--pink); color: #fff; border-color: #e7658f; box-shadow: 0 3px 0 #e7658f; }
.btn-danger { color: #c9435e; }
.btn-small { padding: 6px 11px; font-size: .85rem; border-radius: 12px; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.fab {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 25;
  background: linear-gradient(135deg, var(--pink), #ff7aa0); color: #fff; border: 3px solid #fff;
  border-radius: 999px; padding: 13px 24px; font-family: var(--display); font-size: 1.1rem; font-weight: 600;
  box-shadow: 0 10px 28px rgba(255, 110, 150, .5); animation: pulse 2.6s ease-in-out infinite; white-space: nowrap;
}
.fab span { font-size: 1.3rem; margin-right: 4px; vertical-align: -2px; }

label.field { display: block; font-weight: 800; font-size: .85rem; margin: 12px 0 5px; }
.field-hint { font-weight: 600; color: var(--muted); }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; border: 2px solid var(--line); background: var(--cream); color: var(--ink); border-radius: 14px;
  padding: 10px 12px; font: inherit; font-size: 1rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--leaf); background: var(--paper); }
textarea { resize: vertical; min-height: 70px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hearts { display: flex; gap: 6px; }
.hearts button {
  flex: 1; border: 2px solid var(--line); background: var(--cream); border-radius: 14px; padding: 8px 0; font-size: 1.35rem;
  filter: grayscale(1); opacity: .55; transition: all .15s;
}
.hearts button.on { filter: none; opacity: 1; background: var(--pink-soft); border-color: var(--pink); transform: translateY(-2px); }
.health-help { font-size: .8rem; text-align: center; margin-top: 4px; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-pick button { width: 42px; height: 42px; font-size: 1.4rem; border: 2px solid var(--line); background: var(--cream); border-radius: 12px; }
.emoji-pick button.on { border-color: var(--leaf); background: var(--leaf-soft); }
.photo-pick { display: flex; align-items: center; gap: 10px; }
.photo-pick img { width: 64px; height: 64px; object-fit: cover; border-radius: 14px; border: 2px solid var(--line); }
.error { color: #c9435e; font-weight: 800; font-size: .9rem; }

/* ---------- Sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(45, 30, 70, .45); animation: fade .2s; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: var(--paper);
  border-radius: 28px 28px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg);
  animation: rise .28s cubic-bezier(.2,.9,.3,1.1);
}
.sheet::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: -8px auto 12px; }
.sheet h3 { font-size: 1.35rem; margin-bottom: 4px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; padding: 12px; }
@media (min-width: 640px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 28px; } }

/* ---------- Plant detail ---------- */
.back { margin: 4px 0 10px; }
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.detail-head .plant-emoji { width: 78px; height: 78px; font-size: 2.6rem; }
.detail-head h2 { font-size: 1.6rem; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--paper); border: 2px solid var(--line); border-radius: 18px; padding: 10px 12px; box-shadow: var(--shadow); }
.stat small { display: block; color: var(--muted); font-weight: 800; font-size: .75rem; }
.stat b { font-family: var(--display); font-size: 1.35rem; }
.card { background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h3 { font-size: 1.05rem; margin-bottom: 8px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--body); font-size: 10px; fill: var(--muted); font-weight: 700; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.rec { display: flex; gap: 12px; padding: 12px; border-radius: 18px; background: var(--cream); border: 2px solid var(--line); }
.rec-photo { width: 72px; height: 72px; border-radius: 14px; object-fit: cover; flex: none; cursor: zoom-in; }
.rec-body { flex: 1; min-width: 0; }
.rec-date { font-weight: 800; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.rec-vals { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .88rem; font-weight: 700; margin: 3px 0; }
.rec-note { font-size: .9rem; color: var(--muted); font-weight: 600; word-wrap: break-word; }
.rec-fairy { font-size: .78rem; font-weight: 800; margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; }
.empty { text-align: center; padding: 28px 14px; color: var(--muted); font-weight: 700; }
.empty .big { font-size: 3rem; display: block; animation: float 3s ease-in-out infinite; }

/* ---------- Fairies ---------- */
.fairy {
  --h: 330; position: relative; width: 84px; height: 84px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, hsl(var(--h) 100% 96%), hsl(var(--h) 85% 82%));
  border: 4px solid var(--rc, var(--r-common)); box-shadow: 0 0 0 3px #fff, 0 6px 14px hsl(var(--h) 60% 50% / .35);
}
.fairy .f-main { font-size: 2.6rem; line-height: 1; filter: drop-shadow(0 3px 2px rgba(0,0,0,.15)); }
.fairy .f-badge {
  position: absolute; right: -6px; bottom: -4px; width: 32px; height: 32px; border-radius: 50%; background: #fff;
  display: grid; place-items: center; font-size: 1.1rem; box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.fairy.lg { width: 150px; height: 150px; border-width: 6px; }
.fairy.lg .f-main { font-size: 5rem; }
.fairy.lg .f-badge { width: 54px; height: 54px; font-size: 1.9rem; right: -2px; bottom: 0; }
.fairy.sm { width: 28px; height: 28px; border-width: 2px; box-shadow: none; }
.fairy.sm .f-main { font-size: .95rem; } .fairy.sm .f-badge { display: none; }
.r-common { --rc: var(--r-common); } .r-uncommon { --rc: var(--r-uncommon); }
.r-rare { --rc: var(--r-rare); } .r-legendary { --rc: var(--r-legendary); }
.r-legendary.fairy { animation: shimmer 2.4s linear infinite; }
.rarity-tag {
  display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .72rem; font-weight: 800; color: #fff;
  background: var(--rc); text-transform: uppercase; letter-spacing: .05em;
}

.book-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.book-progress .bar { flex: 1; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; }
.filters button { border: 2px solid var(--line); background: var(--paper); border-radius: 99px; padding: 5px 14px; font-weight: 800; font-size: .85rem; white-space: nowrap; }
.filters button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.fairy-card {
  background: var(--paper); border: 2px solid var(--line); border-radius: 20px; padding: 14px 8px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; position: relative; box-shadow: var(--shadow);
  transition: transform .15s;
}
.fairy-card:hover { transform: translateY(-3px) rotate(1deg); }
.fairy-card .name { font-family: var(--display); font-weight: 600; font-size: .98rem; line-height: 1.15; }
.fairy-card .count {
  position: absolute; top: 8px; right: 8px; background: var(--sun); color: #5a3c00; font-weight: 800; font-size: .72rem; border-radius: 99px; padding: 1px 8px;
}
.fairy-card.locked { background: transparent; border-style: dashed; box-shadow: none; }
.fairy-card.locked .fairy { filter: grayscale(1) brightness(.75) contrast(.6); opacity: .5; background: var(--cream-2); }
.fairy-card.locked .f-main { filter: brightness(0) opacity(.35); }
.fairy-card.locked .f-badge { display: none; }
.fairy-card.locked .name { color: var(--muted); }
.hint { font-size: .75rem; color: var(--muted); font-weight: 700; }

/* ---------- Reveal ---------- */
.reveal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 50% 40%, rgba(88, 48, 150, .96), rgba(25, 15, 50, .98));
  animation: fade .25s;
}
.reveal-card { text-align: center; color: #fff; max-width: 360px; width: 100%; position: relative; }
.orb { font-size: 5.5rem; animation: shake .7s ease-in-out infinite; filter: drop-shadow(0 0 22px #ffe9a8); }
.orb-text { font-family: var(--display); font-size: 1.2rem; margin-top: 10px; opacity: .9; }
.reveal-fairy { display: flex; flex-direction: column; align-items: center; gap: 12px; animation: pop .7s cubic-bezier(.2,1.5,.4,1) both; position: relative; z-index: 2; }
.reveal-fairy .banner { font-family: var(--display); font-size: 1rem; opacity: .85; }
.reveal-fairy h2 { font-size: 2rem; text-shadow: 0 3px 12px rgba(0,0,0,.4); }
.reveal-fairy .blurb { font-weight: 700; opacity: .9; font-size: .98rem; }
.new-tag { background: var(--pink); padding: 3px 14px; border-radius: 99px; font-family: var(--display); font-weight: 700; animation: pulse 1s infinite; }
.dup-tag { background: rgba(255,255,255,.2); padding: 3px 14px; border-radius: 99px; font-weight: 800; }
.glow {
  position: absolute; left: 50%; top: 38%; width: 380px; height: 380px; transform: translate(-50%, -50%); z-index: 1; border-radius: 50%;
  background: radial-gradient(circle, var(--rc) 0%, transparent 62%); opacity: .55; animation: spin-glow 6s linear infinite;
  pointer-events: none;
}
.rays { position: absolute; left: 50%; top: 38%; width: 520px; height: 520px; margin: -260px 0 0 -260px; z-index: 1; pointer-events: none; opacity: .16;
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.9) 0 6deg, transparent 6deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 65%); mask: radial-gradient(circle, #000 0, transparent 65%);
  animation: spin-glow 14s linear infinite; }
.reward-box { margin-top: 18px; background: rgba(255,255,255,.12); border-radius: 18px; padding: 10px 14px; font-weight: 800; font-size: .92rem; position: relative; z-index: 2; }
.reveal .btn { margin-top: 18px; position: relative; z-index: 2; min-width: 170px; padding: 12px 18px; font-size: 1.05rem; }
.spark { position: fixed; z-index: 61; pointer-events: none; font-size: 1.2rem; animation: burst 1.1s ease-out forwards; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 70; background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 99px; font-weight: 800; box-shadow: var(--shadow-lg); animation: rise .25s; max-width: 90vw; text-align: center;
}

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: var(--cream); }
.login-card { background: var(--paper); border: 2px solid var(--line); border-radius: 28px; padding: 28px 24px; width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; }
.login-fairy { font-size: 4rem; animation: float 3s ease-in-out infinite; }
.login-card .btn { padding: 12px; }

.bg-sparkles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-sparkles i { position: absolute; font-style: normal; opacity: .5; animation: drift linear infinite; }
main, .top, .fab { position: relative; z-index: 1; }
.top { position: sticky; } .fab { position: fixed; }

/* ---------- Animations ---------- */
@keyframes float { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
@keyframes pulse { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.05); } }
.new-tag { animation-name: pulse-plain; } @keyframes pulse-plain { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake { 0%,100% { transform: rotate(-10deg) scale(1); } 25% { transform: rotate(10deg) scale(1.08); } 50% { transform: rotate(-8deg) scale(1); } 75% { transform: rotate(8deg) scale(1.1); } }
@keyframes pop { 0% { transform: scale(.2) rotate(-25deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes spin-glow { to { transform: translate(-50%, -50%) rotate(360deg); } }
.rays { animation-name: spin-rays; } @keyframes spin-rays { to { transform: rotate(360deg); } }
@keyframes burst { 0% { transform: translate(0,0) scale(.3); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(240deg); opacity: 0; } }
@keyframes shimmer { 0%,100% { box-shadow: 0 0 0 3px #fff, 0 0 18px 4px rgba(255,182,46,.6); } 50% { box-shadow: 0 0 0 3px #fff, 0 0 30px 10px rgba(255,182,46,.95); } }
@keyframes drift { from { transform: translateY(105vh) rotate(0); } to { transform: translateY(-10vh) rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-width: 420px) {
  .brand { font-size: 1.2rem; } .chip { padding: 4px 8px; font-size: .8rem; }
  .grid { grid-template-columns: 1fr; }
  .book-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Accounts ---------- */
.auth-tabs { display: flex; gap: 6px; background: var(--cream); border-radius: 14px; padding: 4px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; border-radius: 11px; padding: 8px 4px; font-weight: 800; color: var(--muted); }
.auth-tabs button.on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.small { font-size: .8rem; margin: 0; font-weight: 700; }
#btnAccount b { max-width: 84px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
@media (max-width: 420px) { #btnAccount b { display: none; } }
.account-id { font-family: var(--display); font-size: 1.15rem; }
.ok { color: var(--leaf-dark); font-weight: 800; font-size: .9rem; }
