/* ===== Ранок — Telegram Mini App ===== */
:root {
  --bg: #020617;
  --surface: #0f172a;
  --surface-2: #111c33;
  --border: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-2: #3b82f6;
  --accent-soft: rgba(37, 99, 235, 0.14);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --warm: #f59e0b;
  --shadow: 0 12px 40px rgba(2, 6, 23, 0.55);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --ok-soft: rgba(16, 185, 129, 0.12);
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent-2); }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }
.screen { display: none; padding: 0 16px; animation: fadeIn .28s ease; }
.screen.is-active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- HERO ---------- */
.hero { padding: 18px 0 8px; }
.hero__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand__logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, .35);
}
.brand__name { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand__sub { color: var(--muted); font-size: 13px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 6px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--ok);
}
.status.is-closed { background: rgba(148, 163, 184, .14); color: var(--muted); }
.status__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.hero__title { font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.025em; margin: 0 0 6px; }
.hero__meta { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.hero__meta b { color: var(--text); font-weight: 700; }
.sep { margin: 0 6px; opacity: .6; }

/* ---------- LOYALTY ---------- */
.loyalty {
  border-radius: var(--radius); padding: 14px 16px; color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(59, 130, 246, .55), transparent 55%),
    linear-gradient(135deg, #1d4ed8, #0b1f5c);
  box-shadow: 0 10px 30px rgba(29, 78, 216, .35);
}
.loyalty__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.loyalty__title { font-weight: 800; font-size: 15px; }
.loyalty__sub { font-size: 13px; color: rgba(255, 255, 255, .78); margin-top: 2px; }
.loyalty__count { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.stamps { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.stamp {
  aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px dashed rgba(255, 255, 255, .45); color: rgba(255, 255, 255, .5);
}
.stamp.is-on { background: #fff; color: #1d4ed8; border: none; animation: pop .35s ease; }
.stamp.is-gift { border-style: solid; border-color: #fcd34d; color: #fcd34d; }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } 100% { transform: none; } }

/* ---------- TABS ---------- */
.tabs {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; overflow-x: auto;
  padding: 12px 16px; margin: 6px -16px 4px; background: var(--bg);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-weight: 700; font-size: 14px; transition: .2s;
}
.tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- CATALOG ---------- */
.cat-title { font-size: 18px; font-weight: 800; letter-spacing: -.015em; margin: 18px 2px 10px; scroll-margin-top: 70px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card {
  position: relative; display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: transform .15s;
}
.card:active { transform: scale(.98); }
.card__art { height: 118px; display: grid; place-items: center; }
.card__art svg { width: 92px; height: 92px; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .25)); }
.card__tag {
  position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
  background: rgba(2, 6, 23, .7); color: #fff; backdrop-filter: blur(6px);
}
.card__tag.is-new { background: var(--warm); color: #1f1300; }
.card__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card__name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.card__foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; }
.card__price { font-weight: 800; font-size: 15px; }
.card__price small { font-weight: 600; color: var(--muted); font-size: 12px; }
.card__add {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-2); font-size: 20px; font-weight: 700; line-height: 1;
}
.card__badge {
  position: absolute; top: 8px; right: 8px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center;
  animation: pop .3s ease;
}

/* art backgrounds */
.bg-coffee { background: linear-gradient(160deg, #3b2a20, #1f1611); }
.bg-latte  { background: linear-gradient(160deg, #6b4a32, #2d1e14); }
.bg-pastry { background: linear-gradient(160deg, #f6c46b, #d9822b); }
.bg-cherry { background: linear-gradient(160deg, #f4a3a8, #b4233c); }
.bg-break  { background: linear-gradient(160deg, #bfe3b4, #4d9b5b); }
.bg-cream  { background: linear-gradient(160deg, #fde7c4, #e2a65c); }
.bg-berry  { background: linear-gradient(160deg, #c7d2fe, #6366f1); }

.credit { text-align: center; color: var(--muted); font-size: 12px; padding: 26px 0 120px; }

/* ---------- TOPBAR / CART ---------- */
.topbar { display: flex; align-items: center; gap: 8px; padding: 12px 0; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar__title { flex: 1; font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
}
.linkbtn { background: none; border: none; color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px; }
.tg .topbar .iconbtn#cartBack { display: none; }

.cart-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.line {
  display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.line__art { width: 58px; height: 58px; border-radius: 14px; flex-shrink: 0; display: grid; place-items: center; }
.line__art svg { width: 46px; height: 46px; }
.line__info { flex: 1; min-width: 0; }
.line__name { font-weight: 700; font-size: 14px; }
.line__opts { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line__price { font-weight: 800; font-size: 14px; margin-top: 2px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.stepper button { width: 32px; height: 32px; border-radius: 9px; border: none; background: var(--surface); font-size: 18px; font-weight: 700; }
.stepper span { min-width: 22px; text-align: center; font-weight: 800; }

.block { margin-top: 20px; }
.block__label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; font-size: 14px; transition: .15s;
}
.chip small { color: var(--muted); font-weight: 600; margin-left: 4px; }
.chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.textarea {
  width: 100%; resize: none; border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; padding: 12px 14px; outline: none;
}
.textarea:focus { border-color: var(--accent); }

.summary { margin-top: 20px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.summary__row { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; padding: 3px 0; }
.summary__total { color: var(--text); font-size: 18px; font-weight: 800; padding-top: 10px; margin-top: 6px; border-top: 1px dashed var(--border); }
.accent { color: var(--accent-2); }
.spacer { height: 120px; }

.empty { text-align: center; padding: 50px 10px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* ---------- SHEET ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .6); z-index: 20; animation: fadeIn .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 560px; margin: 0 auto;
  max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow); animation: slideUp .28s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: calc(110px + var(--safe-bottom));
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet__grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .5); position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 2; }
.sheet__close { position: absolute; top: 14px; right: 14px; z-index: 2; background: rgba(2, 6, 23, .45); border: none; color: #fff; }
.sheet__art { height: 200px; display: grid; place-items: center; border-radius: 24px 24px 0 0; }
.sheet__art svg { width: 150px; height: 150px; filter: drop-shadow(0 14px 22px rgba(0, 0, 0, .3)); animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.sheet__body { padding: 16px 18px 0; }
.sheet__title { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.sheet__desc { color: var(--muted); margin: 6px 0 4px; font-size: 14px; }
.qty-row { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.qty-row .block__label { margin: 0; }

/* ---------- DONE ---------- */
.done { padding: 36px 4px 0; text-align: center; }
.done__badge {
  width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok); color: #fff; box-shadow: 0 0 0 10px var(--ok-soft); animation: pop .45s ease;
}
.done__title { font-size: 26px; font-weight: 800; letter-spacing: -.025em; margin: 0; }
.done__num { margin: 6px 0 0; color: var(--muted); }
.done__num b { color: var(--text); font-size: 18px; letter-spacing: .04em; }
.done__text { color: var(--muted); font-size: 14px; margin: 10px auto 0; max-width: 330px; }
.timeline { list-style: none; padding: 0; margin: 24px 0 0; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 16px; }
.timeline li { display: flex; gap: 12px; align-items: center; padding: 10px 0; position: relative; color: var(--muted); }
.timeline li + li { border-top: 1px solid var(--border); }
.timeline b { display: block; font-size: 14px; }
.timeline small { font-size: 12px; }
.timeline .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; }
.timeline li.is-done { color: var(--text); }
.timeline li.is-done .dot { background: var(--ok); border-color: var(--ok); }
.timeline li.is-active { color: var(--text); }
.timeline li.is-active .dot { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); animation: pulse 1.4s infinite; }
.done__card { margin-top: 12px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; font-size: 14px; }
.done__card .row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; color: var(--muted); }
.done__card .row b { color: var(--text); }

/* ---------- BUTTONS / TOAST ---------- */
.fallback-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.mainbtn {
  display: block; width: 100%; max-width: 528px; margin: 0 auto; height: 52px; border: none; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 16px; box-shadow: 0 10px 24px rgba(37, 99, 235, .35);
}
.mainbtn:disabled { opacity: .6; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0; z-index: 40;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px; padding: 10px 16px; border-radius: 12px;
  transition: .25s; pointer-events: none; white-space: nowrap;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.tg .toast { bottom: 24px; }

/* Currency switch */
.cur { display: flex; gap: 6px; margin: -6px 0 16px; }
.cur button {
  flex: 1; border: 1px solid var(--border); background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 700; padding: 8px 6px; border-radius: 12px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.cur button.is-active { background: var(--accent, #2563eb); border-color: transparent; color: #fff; }
