@import url("flame.css");

:root {
  /* Тёмная тема по умолчанию; --bg/--text/--hint подменяются темой Telegram (см. app.js) */
  --bg: #15111f;
  --text: #f6f2fc;
  --hint: #a59cbd;
  --card: #1f1a30;
  --card2: #2a2342;
  --line: rgba(255, 255, 255, .08);
  --violet: #9b6fd8;
  --violet2: #7b4fc4;

  --accent: #ff7a1a;
  --accent2: #ff3d2e;
  --accent-grad: linear-gradient(135deg, #ff9a1f, #ff4a2a);
  --ok: #35c46a;
  --warn: #f5b82e;
  --bad: #ef4a4a;
  --info: #3b9bff;
  --u1: #ff8a3d;
  --u2: #a78bfa;

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 10px 28px rgba(0, 0, 0, .28);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 62px;
}
@supports (color: color-mix(in srgb, red, blue)) {
  :root {
    --card: color-mix(in srgb, var(--bg) 90%, var(--text) 10%);
    --card2: color-mix(in srgb, var(--bg) 82%, var(--text) 18%);
    --line: color-mix(in srgb, var(--text) 10%, transparent);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  background:
    radial-gradient(700px 360px at 50% -100px, rgba(255, 140, 40, .13), transparent 70%),
    radial-gradient(600px 420px at 100% 100%, rgba(123, 79, 196, .22), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }

#app { max-width: 600px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 28px); min-height: 100vh; }

/* ---------- навигация ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 12px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav[hidden] { display: none; }
.nav a {
  flex: 1; max-width: 190px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 4px; border-radius: 14px; color: var(--hint); font-size: 12px; font-weight: 600;
}
.nav__ico { font-size: 20px; filter: grayscale(1); opacity: .7; }
.nav a.is-active { color: #d6bcff; box-shadow: inset 0 -3px 0 var(--violet); border-radius: 14px 14px 4px 4px; }
.nav a.is-active .nav__ico { filter: none; opacity: 1; }

/* ---------- общие блоки ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 2px 16px; }
.page-head .btn { white-space: nowrap; flex: none; }
.page-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.sub { color: var(--hint); font-size: 14px; }
.vip-hero { display: flex; justify-content: center; padding: 4px 0 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stack { display: grid; gap: 12px; }
.vip-payment-menu { margin-top: 16px; }
.payment-choice { display: grid; gap: 10px; }
.payment-option {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card2);
}
.payment-option__title { display: block; }
.payment-option__desc { margin-top: 4px; color: var(--hint); font-size: 13px; }
.payment-option .btn { padding: 10px 12px; white-space: nowrap; }
@media (max-width: 380px) {
  .payment-option { grid-template-columns: 1fr; }
  .payment-option .btn { width: 100%; }
}
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--hint); margin: 22px 4px 8px; }

.btn {
  appearance: none; border: 0; cursor: pointer; border-radius: var(--radius-sm);
  padding: 14px 18px; font-weight: 700; background: var(--card2); color: var(--text);
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn--primary { background: var(--accent-grad); color: #fff; box-shadow: 0 8px 22px rgba(255, 90, 30, .35); }
.btn--violet { background: linear-gradient(135deg, #a678e6, #7b4fc4); color: #fff; box-shadow: 0 8px 22px rgba(123, 79, 196, .4); }
.btn--danger { background: rgba(239, 74, 74, .16); color: #ff7b7b; }
.btn--block { width: 100%; }
.btn--sm { padding: 9px 14px; font-size: 14px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--card2); color: var(--hint); }
.chip--ok { background: rgba(53, 196, 106, .16); color: var(--ok); }
.chip--wait { background: rgba(245, 184, 46, .16); color: var(--warn); }
.chip--bad { background: rgba(239, 74, 74, .16); color: var(--bad); }
.chip--info { background: rgba(59, 155, 255, .16); color: var(--info); }

.banner { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; border: 1px solid transparent; }
.banner--warn { background: rgba(245, 184, 46, .12); border-color: rgba(245, 184, 46, .35); }
.banner--info { background: rgba(59, 155, 255, .12); border-color: rgba(59, 155, 255, .35); }
.banner--bad { background: rgba(239, 74, 74, .12); border-color: rgba(239, 74, 74, .35); }
.banner b { display: block; margin-bottom: 2px; }

.empty { text-align: center; padding: 36px 12px; display: grid; gap: 10px; justify-items: center; }
.empty h2 { font-size: 20px; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 800; font-size: 13px; color: #fff; background: var(--u1); border: 2px solid var(--card);
}
.avatar.u2 { background: var(--u2); }
.avatar.u3 { background: #34c3b1; } .avatar.u4 { background: #e56aa5; }

/* ---------- карточки серий ---------- */
.streak-card { display: flex; gap: 14px; align-items: center; cursor: pointer; transition: transform .15s ease; position: relative; overflow: hidden; }
.streak-card:active { transform: scale(.985); }
.streak-card h3 { font-size: 18px; font-weight: 800; }
.streak-card .days { font-size: 26px; font-weight: 900; letter-spacing: -.02em; line-height: 1.1; }
.streak-card .days small { font-size: 13px; font-weight: 600; color: var(--hint); letter-spacing: 0; }
.avatars { display: flex; }
.avatars .avatar + .avatar { margin-left: -8px; }
.avatar { position: relative; }
.avatar.done { box-shadow: 0 0 0 2px var(--ok); }

/* ---------- экран серии ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin: 2px 0 6px; }
.topbar h1 { font-size: 20px; font-weight: 800; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--card); color: var(--text); font-size: 18px; cursor: pointer; display: grid; place-items: center; }

.hero {
  text-align: center; padding: 22px 12px 18px; display: grid; justify-items: center; gap: 6px;
  position: relative; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(2px 2px at 12% 18%, #ffd98a 60%, transparent 62%),
    radial-gradient(1.5px 1.5px at 82% 12%, #fff 60%, transparent 62%),
    radial-gradient(2px 2px at 90% 46%, #ffd98a 60%, transparent 62%),
    radial-gradient(1.5px 1.5px at 6% 58%, #fff 60%, transparent 62%),
    radial-gradient(1.5px 1.5px at 70% 30%, #c9b0ff 60%, transparent 62%),
    var(--card);
}
.hero::before, .hero::after { content: ""; position: absolute; bottom: -34px; width: 46%; height: 90px; border-radius: 50%; background: rgba(123, 79, 196, .42); filter: blur(2px); z-index: -1; }
.hero::before { left: -14%; } .hero::after { right: -14%; background: rgba(105, 66, 176, .5); }
.hero .flame { margin-top: 6px; }
.flame-name { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 14px; cursor: pointer; }
.flame-name:active { transform: scale(.96); }
.hero__num { font-size: 64px; font-weight: 900; letter-spacing: -.04em; line-height: 1; margin-top: 4px;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero.is-out .hero__num { background: none; color: var(--hint); }
.hero__label { color: var(--hint); font-weight: 600; }
.hero__state { font-weight: 700; margin-top: 2px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 14px -16px 14px; padding: 2px 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 0; background: var(--card); color: var(--hint); padding: 9px 15px; border-radius: 999px; font-weight: 700; font-size: 14px; cursor: pointer; }
.tab.is-active { background: var(--violet2); color: #fff; }

.progress { height: 10px; border-radius: 999px; background: var(--card2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent-grad); transition: width .7s cubic-bezier(.2, .8, .2, 1); }
.progress.is-done > i { background: linear-gradient(90deg, #35c46a, #7be39b); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 15px; }
.kv dt { color: var(--hint); } .kv dd { margin: 0; font-weight: 700; text-align: right; }
.kv { margin: 0; }

.person { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.person + .person { border-top: 1px solid var(--line); }
.person .avatar { width: 38px; height: 38px; font-size: 15px; border-color: transparent; }
.person__n { font-size: 20px; font-weight: 800; }

/* ---------- статистика ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { padding: 14px; }
.stat__label { color: var(--hint); font-size: 13px; font-weight: 600; }
.stat__value { font-size: 30px; font-weight: 900; letter-spacing: -.03em; margin: 2px 0 8px; }
.split { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--card2); }
.split i { display: block; height: 100%; }
.split .u1 { background: var(--u1); } .split .u2 { background: var(--u2); } .split .u3 { background: #34c3b1; } .split .u4 { background: #e56aa5; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--hint); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* ---------- календарь ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h3 { font-size: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal__dow { text-align: center; font-size: 12px; color: var(--hint); font-weight: 700; padding-bottom: 4px; }
.cal__day {
  aspect-ratio: 1; border-radius: 12px; border: 0; background: var(--card2); color: var(--text);
  font-weight: 700; font-size: 14px; display: grid; place-items: center; cursor: pointer; position: relative;
}
.cal__day:disabled { background: transparent; opacity: .35; cursor: default; }
.cal__day.s-complete { background: rgba(53, 196, 106, .85); color: #06210f; }
.cal__day.s-pending { background: rgba(245, 184, 46, .9); color: #2a1d00; }
.cal__day.s-missed { background: rgba(239, 74, 74, .88); color: #fff; }
.cal__day.s-recovered { background: rgba(59, 155, 255, .9); color: #fff; }
.cal__day.is-today { outline: 2px solid var(--text); outline-offset: 2px; }
.cal__blank { visibility: hidden; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; font-size: 13px; color: var(--hint); }
.cal-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }

/* ---------- история ---------- */
.timeline { display: grid; gap: 0; }
.tl { display: flex; gap: 12px; padding: 12px 0; }
.tl + .tl { border-top: 1px solid var(--line); }
.tl__ico { font-size: 20px; width: 28px; text-align: center; }

/* ---------- формы ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--hint); }
.input {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--card2); outline: none; font-size: 16px;
}
.input:focus { border-color: var(--accent); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch + .switch { border-top: 1px solid var(--line); }
.switch input { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--card2); position: relative; cursor: pointer; flex: none; transition: background .2s; border: 1px solid var(--line); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.switch input:checked { background: var(--ok); border-color: transparent; }
.switch input:checked::after { transform: translateX(20px); }

.pick { display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.pick button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--card2); cursor: pointer; }
.pick button.is-sel { border-color: var(--accent); background: rgba(255, 122, 26, .14); }

/* ---------- шит / тосты ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet { width: 100%; max-width: 600px; max-height: 88vh; overflow: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); border: 1px solid var(--line); animation: slide .24s cubic-bezier(.2, .8, .2, 1); }
.sheet__grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: -6px auto 14px; }
.sheet h2 { font-size: 20px; margin-bottom: 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateY(40px); opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 18px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60; max-width: min(92vw, 460px); padding: 12px 16px; border-radius: 14px; background: var(--card2); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; transition: opacity .2s, transform .2s; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: rgba(239, 74, 74, .6); }

/* скелетон загрузки */
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--card) 25%, var(--card2) 50%, var(--card) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; height: 96px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .skeleton, .sheet, .sheet-bg { animation: none; }
  .progress > i, .btn, .toast { transition: none; }
}
@media (min-width: 640px) { .hero__num { font-size: 76px; } }

/* ---------- настройки огонька ---------- */
.flame-preview { display: grid; place-items: center; padding: 6px 0 2px; }
.char-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.char-btn { border: 2px solid transparent; background: var(--card2); border-radius: 16px; padding: 8px 4px 6px; display: grid; justify-items: center; gap: 4px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--hint); }
.char-btn .flame { width: 52px; pointer-events: none; }
.char-btn .flame * { animation: none !important; }
.char-btn.is-sel { border-color: #d68bd8; color: var(--text); box-shadow: 0 0 0 3px rgba(214, 139, 216, .18); }
.color-row { display: flex; gap: 12px; flex-wrap: wrap; }
.color-dot { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; outline: 2px solid transparent; outline-offset: 2px; }
.color-dot.is-sel { border-color: var(--bg); outline-color: #d68bd8; }
