:root {
  --bg: #f2f5f9; --card: #ffffff; --card2: #eaf0f7; --text: #0f172a; --muted: #64748b;
  --line: rgba(15, 23, 42, .08); --water1: #38bdf8; --water2: #2563eb;
  --xp1: #fbbf24; --xp2: #f97316; --good: #10b981; --bad: #ef4444;
  --shadow: 0 6px 24px rgba(15, 23, 42, .07);
  --tab-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="dark"] {
  --bg: #0d1117; --card: #171c25; --card2: #212836; --text: #eef2f7; --muted: #8b96a8;
  --line: rgba(255, 255, 255, .07); --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
#view { padding: 14px 14px calc(var(--tab-h) + var(--safe-b) + 24px); max-width: 560px; margin: 0 auto; }
h2 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; }
.card { background: var(--card); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.fade { animation: fade .25s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* hero */
.hero { display: flex; gap: 14px; align-items: center; background: linear-gradient(135deg, var(--card), var(--card2)); }
.avatar { width: 84px; height: 84px; border-radius: 26px; background: var(--card2); display: grid; place-items: center; position: relative; flex: none; }
.avatar .face { font-size: 46px; line-height: 1; animation: bob 3.2s ease-in-out infinite; }
.avatar .gear { position: absolute; bottom: -6px; right: -8px; font-size: 22px; background: var(--card); border-radius: 12px; padding: 1px 4px; box-shadow: var(--shadow); }
.avatar .mood { position: absolute; top: -6px; left: -6px; font-size: 20px; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.hero h1 { font-size: 20px; margin: 0 0 2px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; background: var(--card2); font-size: 13px; font-weight: 600; }
.pill.fire { background: linear-gradient(90deg, #fb923c33, #f9731633); color: #ea580c; }
.bar { height: 10px; border-radius: 99px; background: var(--card2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--xp1), var(--xp2)); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.bar.water > i { background: linear-gradient(90deg, var(--water1), var(--water2)); }
.bar.good > i { background: var(--good); }

/* water orb */
.orb-wrap { display: grid; place-items: center; padding: 6px 0 14px; }
.orb { width: 196px; height: 196px; border-radius: 50%; position: relative; overflow: hidden; background: var(--card2);
  box-shadow: inset 0 0 0 4px var(--card), 0 0 0 3px rgba(56, 189, 248, .45), var(--shadow); }
.orb-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(#38bdf8, #2563eb); transition: height 1s cubic-bezier(.2, .8, .2, 1); }
.wave { position: absolute; left: 0; top: -13px; width: 200%; height: 14px; background-repeat: repeat-x; background-size: 50% 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 14' preserveAspectRatio='none'%3E%3Cpath d='M0 7 Q25 0 50 7 T100 7 V14 H0Z' fill='%2338bdf8'/%3E%3C/svg%3E");
  animation: wave 3.2s linear infinite; }
.wave.w2 { top: -10px; opacity: .45; animation-duration: 5.4s; animation-direction: reverse; }
@keyframes wave { to { transform: translateX(-50%); } }
.orb-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.orb-text > div { background: color-mix(in srgb, var(--card) 80%, transparent); backdrop-filter: blur(6px); border-radius: 18px; padding: 6px 14px; }
.orb-text b { font-size: 34px; display: block; line-height: 1.1; }
.orb-text span { font-size: 13px; color: var(--muted); }

/* кнопки */
.btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; transition: transform .12s, opacity .2s; }
button:active { transform: scale(.95); }
button:disabled { opacity: .5; }
.btn { background: var(--card2); border-radius: 16px; padding: 13px 4px; font-weight: 700; }
.btn.water { background: linear-gradient(135deg, #38bdf822, #2563eb22); color: #0284c7; }
:root[data-theme="dark"] .btn.water { color: #7dd3fc; }
.btn.primary { background: linear-gradient(135deg, var(--water1), var(--water2)); color: #fff; width: 100%; padding: 15px; font-size: 17px; border-radius: 18px; box-shadow: 0 8px 20px rgba(37, 99, 235, .3); }
.btn.go { background: linear-gradient(135deg, #34d399, #059669); box-shadow: 0 8px 20px rgba(5, 150, 105, .3); }
.btn.ghost { background: transparent; color: var(--muted); font-size: 14px; padding: 10px; }
.btns2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

/* списки */
.prog { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--card); border-radius: 20px; padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.prog .ic { font-size: 30px; width: 52px; height: 52px; border-radius: 16px; background: var(--card2); display: grid; place-items: center; flex: none; }
.prog b { display: block; }
.chev { color: var(--muted); font-size: 22px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--card2); border-radius: 99px; padding: 9px 14px; font-weight: 600; font-size: 14px; }
.chip.on { background: linear-gradient(135deg, var(--water1), var(--water2)); color: #fff; }
.detail { line-height: 1.6; }
.detail b { font-size: 18px; }
.sticky { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 10px); margin-top: 14px; }
.back { background: none; color: var(--water2); font-weight: 600; padding: 6px 2px; margin-bottom: 6px; }

/* квесты, достижения, облики */
.quest { margin-bottom: 14px; }
.quest:last-child { margin-bottom: 0; }
.quest .top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.forms { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.form { flex: none; width: 92px; text-align: center; background: var(--card2); border-radius: 18px; padding: 10px 6px; }
.form .g { font-size: 26px; }
.form.cur { outline: 2px solid var(--xp2); background: linear-gradient(135deg, #fbbf2433, #f9731622); }
.form.lock { opacity: .45; filter: grayscale(1); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ach { background: var(--card2); border-radius: 18px; padding: 12px 6px; text-align: center; }
.ach .e { font-size: 30px; }
.ach b { display: block; font-size: 12px; margin-top: 2px; }
.ach small { display: block; color: var(--muted); font-size: 11px; line-height: 1.2; margin-top: 2px; }
.ach.lock { opacity: .45; filter: grayscale(1); }
.animals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.animal { background: var(--card2); border-radius: 18px; padding: 10px 4px; font-weight: 600; font-size: 13px; }
.animal span { display: block; font-size: 30px; }
.animal.on { outline: 2px solid var(--water2); background: linear-gradient(135deg, #38bdf822, #2563eb22); }

/* статистика */
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; padding-top: 6px; }
.col { text-align: center; font-size: 12px; }
.track { height: 130px; background: var(--card2); border-radius: 12px; position: relative; overflow: hidden; margin: 4px 0; }
.track i { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(var(--water1), var(--water2)); border-radius: 12px; transition: height .8s cubic-bezier(.2, .8, .2, 1); }
.track i.full { background: linear-gradient(#34d399, #059669); }
.col .d { color: var(--muted); }
.col .d.now { color: var(--text); font-weight: 700; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card2); border-radius: 18px; padding: 14px; }
.tile b { font-size: 24px; display: block; }

/* настройки */
.set { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 38px; height: 38px; border-radius: 12px; background: var(--card2); font-size: 20px; font-weight: 700; }
.stepper b { min-width: 78px; text-align: center; font-size: 18px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--card2); border-radius: 99px; transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 26px; height: 26px; top: 3px; left: 3px; background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: .2s; }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { transform: translateX(20px); }
select, input[type=time], input[type=text], input[type=number] { font: inherit; color: var(--text); background: var(--card2); border: 0; border-radius: 12px; padding: 9px 10px; max-width: 100%; }
input[type=text], input[type=number] { width: 100%; font-size: 20px; text-align: center; }

/* tabbar */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; padding: 6px 6px calc(6px + var(--safe-b)); height: calc(var(--tab-h) + var(--safe-b));
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(16px); border-top: 1px solid var(--line); z-index: 10; }
#tabs button { flex: 1; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); font-size: 10.5px; font-weight: 600; border-radius: 14px; }
#tabs button span { font-size: 22px; filter: grayscale(1); opacity: .65; transition: .2s; }
#tabs button.on { color: var(--water2); }
#tabs button.on span { filter: none; opacity: 1; transform: translateY(-1px) scale(1.1); }

/* тосты и праздник */
#toasts { position: fixed; top: 12px; left: 0; right: 0; display: grid; gap: 8px; justify-items: center; pointer-events: none; z-index: 30; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 16px; font-weight: 600; font-size: 14px; max-width: 90%; box-shadow: var(--shadow); animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both, out .3s 2.6s ease forwards; }
.toast.xp { background: linear-gradient(90deg, var(--xp1), var(--xp2)); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(-14px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes out { to { opacity: 0; transform: translateY(-10px); } }
#overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); animation: fade .25s both; }
#overlay[hidden] { display: none; }
.sheet { background: var(--card); border-radius: 26px; padding: 26px 22px; width: min(86vw, 340px); text-align: center; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.sheet .big { font-size: 72px; line-height: 1; animation: bob 2s ease-in-out infinite; }
.sheet h3 { margin: 10px 0 4px; font-size: 22px; }
.sheet .btns2 { margin-top: 16px; }
.confetti { position: fixed; top: -30px; font-size: 22px; animation: fall linear forwards; pointer-events: none; z-index: 41; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .8; } }
.empty { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty .big { font-size: 60px; }
