/* ===== Кофейная мини-апка =====
   Палитра: молочная пена + эспрессо, акценты из колеса вкусов specialty-кофе.
   Цвета заведений — из их меню: Атлас чёрный, Сожители зелёные с оранжевым. */

:root {
  --bg: #EFE6DC;
  --surface: #FBF7F2;
  --surface-2: #F5EDE4;
  --ink: #2A1A12;
  --ink-2: #6E5A4E;
  --line: rgba(42, 26, 18, .12);
  --primary: #2A1A12;
  --on-primary: #FBF7F2;
  --crema: #C98A4B;

  --berry: #D2366B;
  --citrus: #EFA500;
  --floral: #8667D4;
  --herbal: #2E9E68;

  --atlas: #000000;
  --atlas-ink: #FFFFFF;
  --soz: #46B26A;
  --soz-2: #F07A2E;
  --soz-ink: #10331C;

  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --shadow: 0 1px 0 rgba(42, 26, 18, .06), 0 12px 32px -18px rgba(42, 26, 18, .45);

  --display: 'Unbounded', system-ui, sans-serif;
  --text: 'Manrope', system-ui, sans-serif;

  --safe-top: var(--tg-content-safe-area-inset-top, 0px);
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --gutter: 18px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #17100D;
  --surface: #241A15;
  --surface-2: #2D211B;
  --ink: #F2E7DE;
  --ink-2: #B09C90;
  --line: rgba(242, 231, 222, .12);
  --primary: #F2E7DE;
  --on-primary: #2A1A12;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 14px 34px -18px rgba(0, 0, 0, .8);
  --soz-ink: #EAF8EE;
  color-scheme: dark;
}

/* Ночь (00–06) — своя палитра, независимо от темы */
body[data-period="night"] {
  --bg: #0E0F1E;
  --surface: #191A31;
  --surface-2: #22233D;
  --ink: #ECE9FF;
  --ink-2: #A3A0C8;
  --line: rgba(236, 233, 255, .12);
  --primary: #ECE9FF;
  --on-primary: #191A31;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 500 16px/1.5 var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  transition: background-color .6s ease;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--citrus); outline-offset: 3px; border-radius: 12px; }
h1, h2, h3, p { margin: 0; }

/* ===== живой фон по времени суток ===== */
#sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
#sky .blob {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  filter: blur(60px); opacity: .55; will-change: transform;
  animation: drift 48s ease-in-out infinite alternate;
}
#sky .b1 { left: -30vmax; top: -35vmax; }
#sky .b2 { right: -35vmax; top: 10vh; animation-duration: 62s; animation-delay: -20s; }
#sky .b3 { left: -10vmax; bottom: -45vmax; animation-duration: 54s; animation-delay: -35s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(8vmax, 6vmax) scale(1.12); }
}
body[data-period="morning"] .b1 { background: #FFC98E; }
body[data-period="morning"] .b2 { background: #FFE7A3; }
body[data-period="morning"] .b3 { background: #F7B7A3; }
body[data-period="day"] .b1 { background: #BFE3FF; }
body[data-period="day"] .b2 { background: #CDEFD3; }
body[data-period="day"] .b3 { background: #FFE7B8; }
body[data-period="evening"] .b1 { background: #F59C85; }
body[data-period="evening"] .b2 { background: #C9A5F2; }
body[data-period="evening"] .b3 { background: #FFB86B; }
body[data-period="night"] .b1 { background: #2A2F7A; opacity: .6; }
body[data-period="night"] .b2 { background: #4B2A6E; opacity: .45; }
body[data-period="night"] .b3 { background: #12345E; opacity: .5; }
:root[data-theme="dark"] body:not([data-period="night"]) .blob { opacity: .16; }

#sky .stars { position: absolute; inset: 0; display: none; }
body[data-period="night"] #sky .stars { display: block; }
.stars i {
  position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff;
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle { 50% { opacity: .15; } }

/* ===== каркас ===== */
#app { position: relative; z-index: 1; min-height: 100%; }
.screen {
  padding: calc(var(--safe-top) + 20px) var(--gutter) calc(var(--safe-bottom) + 104px);
  max-width: 520px; margin: 0 auto;
}
.screen.home { padding-bottom: calc(var(--safe-bottom) + 172px); }

/* ===== сплэш ===== */
#splash {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: var(--bg); transition: opacity .5s ease, visibility .5s;
}
#splash.gone { opacity: 0; visibility: hidden; }
#splash svg { width: 132px; height: 132px; }
.drip { animation: drip 1s cubic-bezier(.55, 0, 1, .45) infinite; }
.drip.d2 { animation-delay: .5s; }
@keyframes drip {
  0% { transform: translateY(-6px); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(52px); opacity: 0; }
}
.fill { animation: fill 2.4s ease-in-out infinite; transform-origin: bottom; transform-box: fill-box; }
@keyframes fill { from { transform: scaleY(.15); } to { transform: scaleY(1); } }

/* ===== главная ===== */
.hello { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.greet {
  font: 800 27px/1.12 var(--display); letter-spacing: -.02em; text-wrap: balance;
  animation: rise .7s cubic-bezier(.2, .8, .2, 1) both;
}
.today { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; padding-top: 4px; }
.today-cups { display: flex; gap: 4px; }
.mini-cup { width: 22px; height: 22px; }
.mini-cup .liquid { fill: var(--crema); transform: scaleY(0); transform-origin: bottom; transform-box: fill-box; transition: transform .8s cubic-bezier(.2, .8, .2, 1); }
.mini-cup.on .liquid { transform: scaleY(1); }
.mini-cup .body { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.today-label { font-size: 12px; color: var(--ink-2); }
.today.over .mini-cup .liquid { fill: var(--berry); }

.note {
  margin-top: 18px; padding: 18px 20px 20px; border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow);
  animation: rise .7s .12s cubic-bezier(.2, .8, .2, 1) both;
}
.note-head { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.note-text { font: 700 19px/1.4 var(--text); text-wrap: pretty; }
.note.night { background: var(--surface); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.hero {
  display: block; margin: 10px auto 0; width: min(64vw, 260px); aspect-ratio: 1;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.hero svg { width: 100%; height: 100%; overflow: visible; }
.hero.small { width: min(46vw, 190px); }
.steam path { stroke: var(--ink-2); stroke-width: 6; fill: none; stroke-linecap: round; opacity: 0; animation: steam 3.6s ease-in-out infinite; }
.steam path:nth-child(2) { animation-delay: 1.2s; }
.steam path:nth-child(3) { animation-delay: 2.4s; }
@keyframes steam {
  0% { opacity: 0; transform: translateY(14px); }
  35% { opacity: .55; }
  100% { opacity: 0; transform: translateY(-26px); }
}
.hero.charging svg { animation: shake .12s linear infinite; }
@keyframes shake { 25% { transform: translate(-2px, 1px) rotate(-1.5deg); } 75% { transform: translate(2px, -1px) rotate(1.5deg); } }
.hero.launch svg { animation: launch 1.6s cubic-bezier(.3, -0.3, .3, 1.3); }
@keyframes launch {
  30% { transform: translateY(-46px) rotate(-12deg); }
  60% { transform: translateY(-60px) rotate(372deg); }
  100% { transform: translateY(0) rotate(360deg); }
}

.cta {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 5;
  bottom: calc(var(--safe-bottom) + 84px);
  width: min(calc(100% - 2 * var(--gutter)), 484px); height: 64px; border-radius: 22px;
  background: var(--primary); color: var(--on-primary);
  font: 800 18px/1 var(--display); letter-spacing: -.01em;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 16px 30px -14px rgba(42, 26, 18, .7);
  transition: transform .15s ease;
}
.cta:active { transform: translateX(-50%) scale(.97); }

.card {
  margin-top: 14px; padding: 16px 18px; border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow);
  animation: rise .6s cubic-bezier(.2, .8, .2, 1) both;
}
.card p + p { margin-top: 4px; }
.card .muted { color: var(--ink-2); font-size: 14px; }
.card-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pill {
  height: 42px; padding: 0 16px; border-radius: 999px; background: var(--surface-2);
  font-weight: 700; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .12s ease, background .2s;
}
.pill:active { transform: scale(.95); }
.pill.solid { background: var(--primary); color: var(--on-primary); }
.wrapped-banner {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: linear-gradient(120deg, var(--floral), var(--berry)); color: #fff;
}
.wrapped-banner b { font: 800 16px/1.2 var(--display); display: block; }
.wrapped-banner span { font-size: 14px; opacity: .9; }
.wrapped-banner .big { font-size: 34px; }

/* ===== нижние вкладки ===== */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 8px var(--gutter) calc(var(--safe-bottom) + 10px);
  display: flex; justify-content: center; gap: 8px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
.tab {
  height: 52px; flex: 1; max-width: 240px; border-radius: 18px;
  font-weight: 800; color: var(--ink-2); display: flex; align-items: center; justify-content: center; gap: 8px;
}
.tab[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ===== дневник ===== */
.diary-title { font: 800 27px/1.12 var(--display); letter-spacing: -.02em; }
.section { margin-top: 28px; }
.section h2 { font: 600 17px/1.3 var(--display); display: flex; justify-content: space-between; align-items: baseline; }
.section h2 small { font: 700 14px var(--text); color: var(--ink-2); }

.receipt {
  margin-top: 16px; padding: 18px 20px 26px; background: var(--surface); box-shadow: var(--shadow);
  border-radius: var(--r-sm) var(--r-sm) 0 0; position: relative;
  -webkit-mask: radial-gradient(circle 7px at 50% 100%, transparent 98%, #000) 0 0 / 18px 100%;
  mask: radial-gradient(circle 7px at 50% 100%, transparent 98%, #000) 0 0 / 18px 100%;
}
.receipt-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.receipt-row:last-child { border-bottom: 0; }
.receipt-row span { color: var(--ink-2); }
.receipt-row b { text-align: right; }
.empty { color: var(--ink-2); margin-top: 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 12px; }
.venue-label { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.tile {
  aspect-ratio: 1 / .9; border-radius: var(--r-sm); padding: 10px; position: relative;
  display: flex; flex-direction: column; justify-content: space-between; text-align: left;
  border: 1.5px dashed var(--line); color: var(--ink-2); font: 700 13px/1.2 var(--text);
}
.tile .glyph { font-size: 20px; filter: grayscale(1); opacity: .35; }
.tile.got { border: 0; color: var(--atlas-ink); background: var(--atlas); }
.tile.got.soz { background: var(--soz); color: #fff; }
.tile.got .glyph { filter: none; opacity: 1; }
.tile .n { position: absolute; top: 8px; right: 10px; font: 800 12px var(--display); }
.tile.fresh { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.badge {
  display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: var(--r-sm);
  background: var(--surface); box-shadow: var(--shadow); text-align: left;
}
.badge .e { font-size: 26px; width: 34px; text-align: center; flex-shrink: 0; }
.badge b { display: block; font-size: 14px; line-height: 1.25; }
.badge small { display: block; font-size: 12px; color: var(--ink-2); line-height: 1.3; }
.badge.locked { background: transparent; box-shadow: none; border: 1.5px dashed var(--line); }
.badge.locked .e { filter: grayscale(1); opacity: .3; }

.history { margin-top: 12px; }
.h-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.h-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--atlas); flex-shrink: 0; }
.h-dot.soz { background: var(--soz); }
:root[data-theme="dark"] .h-dot:not(.soz), body[data-period="night"] .h-dot:not(.soz) { background: var(--ink); }
.h-main { flex: 1; min-width: 0; }
.h-main b { display: block; }
.h-main small { color: var(--ink-2); font-size: 13px; }
.h-rate { font-size: 18px; }

.wide-btn {
  width: 100%; height: 54px; margin-top: 10px; border-radius: 18px; background: var(--surface);
  box-shadow: var(--shadow); font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 8px;
}

/* ===== лист выбора ===== */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow: hidden;
  animation: sheet-in .45s cubic-bezier(.2, .8, .2, 1) both;
}
.sheet.out { animation: sheet-out .35s ease both; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
.sheet .sky-copy { position: absolute; inset: 0; pointer-events: none; }
.step {
  position: absolute; inset: 0; overflow-y: auto;
  padding: calc(var(--safe-top) + 22px) var(--gutter) calc(var(--safe-bottom) + 28px);
  display: flex; flex-direction: column;
}
.step-inner { max-width: 520px; width: 100%; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.step.enter { animation: step-in .42s cubic-bezier(.2, .8, .2, 1) both; }
.step.leave { animation: step-out .3s ease both; pointer-events: none; }
.step.enter.back { animation-name: step-in-back; }
.step.leave.back { animation-name: step-out-back; }
@keyframes step-in { from { transform: translateX(36%); opacity: 0; } }
@keyframes step-out { to { transform: translateX(-24%); opacity: 0; } }
@keyframes step-in-back { from { transform: translateX(-36%); opacity: 0; } }
@keyframes step-out-back { to { transform: translateX(24%); opacity: 0; } }

.progress { display: flex; gap: 6px; margin-bottom: 26px; padding-right: 52px; min-height: 40px; align-items: center; }
.progress i { height: 5px; flex: 1; border-radius: 3px; background: var(--line); transition: background .3s; }
.progress i.on { background: var(--ink); }
.close-x {
  position: absolute; right: var(--gutter); top: calc(var(--safe-top) + 12px);
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface); font-size: 18px; z-index: 2;
}
.q { font: 800 25px/1.15 var(--display); letter-spacing: -.02em; text-wrap: balance; padding-right: 44px; }
.q-sub { color: var(--ink-2); margin-top: 8px; }

.options { display: grid; gap: 10px; margin-top: 24px; }
.options.two { grid-template-columns: 1fr 1fr; }
.opt {
  min-height: 64px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface);
  box-shadow: var(--shadow); font-weight: 800; font-size: 16px; text-align: left;
  display: flex; align-items: center; gap: 10px;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
  transition: transform .12s ease;
}
.opt:active { transform: scale(.97); }
.opt.big { min-height: 132px; flex-direction: column; align-items: flex-start; justify-content: space-between; font-size: 18px; }
.opt.big .e { font-size: 34px; }
.opt.big small { font-weight: 600; font-size: 13px; color: var(--ink-2); display: block; }
.opt.full { grid-column: 1 / -1; }
.opt.picked { outline: 3px solid var(--ink); }
.opt.venue-atlas { background: var(--atlas); color: var(--atlas-ink); }
.opt.venue-soz { background: var(--soz); color: #fff; }
.opt.venue-atlas small, .opt.venue-soz small { color: inherit; opacity: .75; }
.opt.v { min-height: 168px; font: 800 22px/1.1 var(--display); justify-content: flex-end; }
.opt.v small { font-family: var(--text); margin-top: 6px; }

/* ===== слот-машина ===== */
.slot {
  margin: 40px auto 0; width: 100%; height: 216px; border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow); position: relative;
}
.slot::before, .slot::after {
  content: ""; position: absolute; left: 0; right: 0; height: 72px; z-index: 2; pointer-events: none;
}
.slot::before { top: 0; background: linear-gradient(var(--surface), transparent); }
.slot::after { bottom: 0; background: linear-gradient(transparent, var(--surface)); }
.slot-window {
  position: absolute; left: 12px; right: 12px; top: 72px; height: 72px; border-radius: 16px;
  border: 2.5px solid var(--ink); z-index: 3; pointer-events: none;
}
.reel { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.reel div {
  height: 72px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font: 800 21px/1 var(--display); letter-spacing: -.01em; white-space: nowrap;
}
.reel div small { font: 700 13px var(--text); color: var(--ink-2); }
.slot-caption { text-align: center; color: var(--ink-2); margin-top: 16px; min-height: 24px; }

/* ===== чек-результат ===== */
.ticket-wrap { perspective: 1200px; margin-top: 22px; }
.ticket {
  border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); overflow: hidden; transform-origin: 50% 0;
  -webkit-mask: radial-gradient(circle 9px at 50% 100%, transparent 98%, #000) 0 0 / 22px 100%;
  mask: radial-gradient(circle 9px at 50% 100%, transparent 98%, #000) 0 0 / 22px 100%;
  padding-bottom: 14px;
}
.ticket.flip { animation: flip .9s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes flip {
  0% { transform: rotateX(-95deg) translateY(-10px); opacity: 0; }
  60% { transform: rotateX(8deg); opacity: 1; }
  100% { transform: rotateX(0); }
}
.t-head {
  padding: 16px 20px 14px; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  background: var(--atlas); color: var(--atlas-ink);
}
.ticket.soz .t-head { background: var(--soz); color: #fff; box-shadow: inset 0 -6px 0 var(--soz-2); }
.t-venue { font: 800 24px/1 var(--display); letter-spacing: -.02em; }
.t-addr { font-size: 13px; opacity: .8; margin-top: 6px; }
.t-time { font: 600 13px var(--display); opacity: .85; }
.t-body { padding: 18px 20px 10px; }
.t-kicker { color: var(--ink-2); font-size: 14px; }
.t-drink { font: 800 30px/1.08 var(--display); letter-spacing: -.025em; margin-top: 4px; text-wrap: balance; }
.t-meta { margin-top: 6px; color: var(--ink-2); }
.t-note { margin-top: 2px; font-style: italic; }
.t-lines { margin-top: 16px; border-top: 2px dashed var(--line); padding-top: 10px; }
.t-line { display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; }
.t-line span:first-child { color: var(--ink-2); }
.t-line b { white-space: nowrap; }
.t-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; padding-top: 10px; border-top: 2px dashed var(--line); }
.t-total span { font-weight: 800; }
.t-total b { font: 800 26px var(--display); }
.t-comment { margin-top: 14px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); }

.actions { display: grid; gap: 8px; margin-top: auto; padding-top: 22px; }
.actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  height: 56px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow);
  font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px;
  transition: transform .12s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: var(--on-primary); height: 62px; font: 800 17px var(--display); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn[disabled] { opacity: .5; }

/* ===== гадание ===== */
.fortune-cup { width: min(70vw, 270px); margin: 30px auto 0; display: block; }
.fortune-cup .coffee { transform-box: fill-box; transform-origin: center; transition: transform 2.2s cubic-bezier(.6, 0, .4, 1), opacity 2.2s; }
.fortune-cup.drained .coffee { transform: scale(0); opacity: 0; }
.fortune-cup .grounds { opacity: 0; transition: opacity 1.2s 1.4s; }
.fortune-cup.drained .grounds { opacity: 1; }
.fortune-text {
  margin-top: 22px; text-align: center; font: 700 20px/1.4 var(--text); text-wrap: balance;
  min-height: 84px; opacity: 0; transform: translateY(10px); transition: opacity .8s, transform .8s;
}
.fortune-text.show { opacity: 1; transform: none; }

/* ===== предупреждение ===== */
.ecg { width: 100%; height: 120px; margin-top: 28px; }
.ecg path { fill: none; stroke: var(--berry); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ecg .base { opacity: .2; }
.ecg .pulse { stroke-dasharray: 22 78; animation: ecg 1.8s linear infinite; }
.ecg.fast .pulse { animation-duration: .65s; }
@keyframes ecg { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
.warn-n { font: 800 64px/1 var(--display); color: var(--berry); margin-top: 8px; }

/* ===== ночь ===== */
.moon { width: 60px; height: 60px; border-radius: 50%; box-shadow: inset -14px -6px 0 0 #F6E7B0; transform: rotate(-20deg); margin-bottom: 18px; }

/* ===== всплывашки ===== */
#toasts {
  position: fixed; z-index: 60; left: var(--gutter); right: var(--gutter); top: calc(var(--safe-top) + 12px);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  pointer-events: auto; max-width: 440px; width: 100%; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--primary); color: var(--on-primary); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .6);
  display: flex; gap: 12px; align-items: center;
  animation: toast-in .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.toast.out { animation: toast-out .35s ease both; }
.toast .e { font-size: 30px; animation: wobble 1.2s .3s ease-in-out; }
.toast b { display: block; font: 800 15px/1.2 var(--display); }
.toast small { font-size: 13px; opacity: .8; }
@keyframes toast-in { from { transform: translateY(-120%) scale(.9); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-120%); opacity: 0; } }
@keyframes wobble { 25% { transform: rotate(-14deg) scale(1.2); } 50% { transform: rotate(10deg); } 75% { transform: rotate(-6deg); } }

#confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; width: 100%; height: 100%; }

/* ===== итог месяца ===== */
.stories { position: fixed; inset: 0; z-index: 40; color: #fff; overflow: hidden; touch-action: manipulation; }
.stories .bars { position: absolute; z-index: 3; left: 12px; right: 12px; top: calc(var(--safe-top) + 10px); display: flex; gap: 4px; }
.stories .bars i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .35); overflow: hidden; }
.stories .bars i b { display: block; height: 100%; width: 0; background: #fff; }
.stories .bars i.done b { width: 100%; }
.stories .bars i.run b { animation: bar 6s linear forwards; }
@keyframes bar { to { width: 100%; } }
.story {
  position: absolute; inset: 0; padding: calc(var(--safe-top) + 64px) 26px calc(var(--safe-bottom) + 40px);
  display: flex; flex-direction: column; justify-content: center;
  animation: story-in .5s ease both;
}
@keyframes story-in { from { opacity: 0; transform: scale(1.04); } }
.story .k { font: 700 18px/1.3 var(--text); opacity: .9; }
.story .huge { font: 800 clamp(64px, 24vw, 120px)/.95 var(--display); letter-spacing: -.04em; margin: 10px 0; }
.story .big { font: 800 clamp(30px, 9vw, 44px)/1.08 var(--display); letter-spacing: -.03em; margin: 10px 0; text-wrap: balance; }
.story .s { font-size: 17px; opacity: .9; margin-top: 8px; }
.split { display: flex; height: 54px; border-radius: 16px; overflow: hidden; margin-top: 22px; font-weight: 800; }
.split div { display: flex; align-items: center; justify-content: center; min-width: 54px; }
.stories .x { position: absolute; z-index: 4; right: 12px; top: calc(var(--safe-top) + 22px); width: 40px; height: 40px; color: #fff; font-size: 20px; }

/* ===== вне Телеграма ===== */
.outside { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 30px; }
.outside h1 { font: 800 24px/1.2 var(--display); margin-top: 16px; }
.outside p { color: var(--ink-2); margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #sky .blob { animation: none; }
}
