/* Цвета берутся из темы Телеграма; запасные — для открытия в обычном браузере. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f0f1f4);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #1a1c20);
  --hint: var(--tg-theme-hint-color, #868b94);
  --link: var(--tg-theme-link-color, #2f7fd0);
  --btn: var(--tg-theme-button-color, #2f8a63);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #d8483d);
  --header: var(--tg-theme-section-header-text-color, var(--hint));
  --faith: #2f8a63;
  --faith-soft: rgba(47, 138, 99, .14);
  --sport: #e07a2f;
  --sport-soft: rgba(224, 122, 47, .15);
  --line: rgba(128, 128, 128, .18);
  --radius: 16px;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  html:not(.tg) {
    --bg: #111317; --card: #1c1f25; --text: #eceef2; --hint: #8e949e;
    --link: #6fb1f2; --btn: #3a9d72; --danger: #ff6b5f;
    color-scheme: dark;
  }
}
html.tg-dark { color-scheme: dark; --line: rgba(255, 255, 255, .1); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.screen { padding: 14px 16px calc(96px + var(--safe-bottom)); max-width: 560px; margin: 0 auto; }
.screen.no-tabs { padding-bottom: calc(24px + var(--safe-bottom)); }

h1 { font-size: 24px; line-height: 1.2; margin: 6px 0 2px; letter-spacing: -.01em; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
     color: var(--header); margin: 22px 4px 8px; }
.sub { color: var(--hint); margin: 0 0 14px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.right { margin-left: auto; text-align: right; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.card.tight { padding: 4px 0; }
.card-head { display: flex; align-items: center; gap: 10px; }
.sphere-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; flex: none; }
.faith .sphere-icon { background: var(--faith-soft); }
.sport .sphere-icon { background: var(--sport-soft); }
.level { font-size: 28px; font-weight: 700; line-height: 1; }
.level small { font-size: 13px; font-weight: 500; color: var(--hint); margin-left: 2px; }

.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 10px 0 6px; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--btn); transition: width .4s ease; }
.faith .bar > i, .bar.faith > i { background: var(--faith); }
.sport .bar > i, .bar.sport > i { background: var(--sport); }
.bar.thin { height: 5px; margin: 6px 0 2px; }

.meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--hint); }
.weak { margin-top: 8px; font-size: 13px; color: var(--hint); }
.weak b { color: var(--text); font-weight: 600; }

.days { display: flex; gap: 6px; margin-top: 10px; }
.days span { flex: 1; text-align: center; font-size: 11px; color: var(--hint); }
.days span::before { content: ""; display: block; height: 8px; border-radius: 4px; background: var(--line); margin-bottom: 4px; }
.days span.on::before { background: var(--sport); }
.days span.today { color: var(--text); font-weight: 600; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 48px; }
.list-item + .list-item { border-top: 1px solid var(--line); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; }
.list-item .note { color: var(--hint); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lock { font-size: 12px; opacity: .8; }

.person { padding: 12px 16px; }
.person + .person { border-top: 1px solid var(--line); }
.person .name { font-weight: 600; }
.person .total { font-weight: 700; font-size: 17px; }
.split { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--line); margin: 8px 0 6px; }
.split i { display: block; height: 100%; }
.split .f { background: var(--faith); }
.split .s { background: var(--sport); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--text); }
.tag.f { background: var(--faith-soft); }
.tag.s { background: var(--sport-soft); }

.pot { text-align: center; padding: 18px 16px; }
.pot .value { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.delta { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 99px; margin-top: 4px; }
.delta.up { background: var(--faith-soft); color: var(--faith); }
.delta.down { background: rgba(216, 72, 61, .12); color: var(--danger); }

.week-nav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.week-nav .label { text-align: center; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--card); display: grid; place-items: center; font-size: 20px; }
.icon-btn:disabled { opacity: .35; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0;
       border-radius: 12px; padding: 13px 16px; font-weight: 600; background: var(--btn); color: var(--btn-text); }
.btn.secondary { background: var(--card); color: var(--link); }
.btn.ghost { background: transparent; color: var(--link); }
.btn.danger { background: transparent; color: var(--danger); }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }
.link-btn { border: 0; background: none; color: var(--link); padding: 4px 0; font-size: 13px; }
.del-btn { border: 0; background: none; color: var(--danger); font-size: 13px; padding: 6px 0 6px 8px; }

.hero-add { margin: 14px 0 4px; padding: 15px; font-size: 16px; }
.pill-link { display: flex; align-items: center; gap: 10px; background: var(--card); border: 0; width: 100%;
             border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; text-align: left; }
.pill-link .count { margin-left: auto; min-width: 24px; height: 24px; border-radius: 99px; background: var(--danger);
                    color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; padding: 0 7px; }

.check-card .kind { font-size: 12px; color: var(--hint); }
.check-card .quote { margin: 8px 0 2px; padding-left: 10px; border-left: 3px solid var(--faith); white-space: pre-wrap; }

.empty { text-align: center; color: var(--hint); padding: 28px 16px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* ---- нижняя панель ---- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; align-items: flex-end;
          background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-bottom)); }
.tab { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
       font-size: 11px; color: var(--hint); padding: 4px 0; position: relative; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--btn); }
.tab-add .plus { width: 50px; height: 50px; border-radius: 16px; background: var(--btn); color: var(--btn-text);
                 display: grid; place-items: center; margin-top: -18px; box-shadow: 0 6px 16px rgba(0, 0, 0, .18); }
.tab-add .plus svg { width: 26px; height: 26px; stroke-width: 2.4; }
.badge { position: absolute; top: 0; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; border-radius: 9px;
         background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; padding: 0 5px; }

/* ---- запись: полноэкранный лист ---- */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; }
.sheet .screen { padding-bottom: calc(110px + var(--safe-bottom)); }
.steps { display: flex; gap: 4px; margin: 2px 0 14px; }
.steps i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--btn); }
.crumbs { font-size: 13px; color: var(--hint); margin-bottom: 2px; min-height: 18px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { border: 0; background: var(--card); border-radius: var(--radius); padding: 16px 14px; text-align: left; min-height: 74px;
        display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.tile .t { font-weight: 600; }
.tile .d { font-size: 12px; color: var(--hint); }
.tile.big { min-height: 120px; font-size: 17px; }
.tile.big .e { font-size: 30px; }
.tile.faith { box-shadow: inset 0 0 0 1.5px var(--faith-soft); }
.tile.sport { box-shadow: inset 0 0 0 1.5px var(--sport-soft); }
.tile.wide { grid-column: 1 / -1; }

.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-weight: 600; margin: 0 2px 6px; }
.field .hint { font-size: 13px; color: var(--hint); margin: -2px 2px 8px; }
.input, textarea.input { width: 100%; border: 0; border-radius: 12px; background: var(--card); padding: 12px 14px; outline: none; }
.input:focus { box-shadow: inset 0 0 0 1.5px var(--btn); }
textarea.input { min-height: 84px; resize: vertical; }
.input.amount { font-size: 22px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 0; border-radius: 99px; background: var(--card); padding: 8px 14px; font-weight: 500; }
.chip.on { background: var(--btn); color: var(--btn-text); }
.file-box { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 10px 12px; }
.file-box .grow { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.or { text-align: center; font-size: 12px; color: var(--hint); margin: 8px 0; }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--bg);
           padding: 10px 16px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.savebar .inner { max-width: 560px; margin: 0 auto; }
.preview { display: flex; justify-content: space-between; font-size: 13px; color: var(--hint); margin-bottom: 8px; }
.preview b { color: var(--text); }
.error { color: var(--danger); font-size: 13px; margin: 0 2px 8px; }

.done { text-align: center; padding: 28px 12px 8px; }
.done .mark { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 12px; display: grid; place-items: center; font-size: 30px; background: var(--faith-soft); }
.done.wait .mark { background: rgba(128, 128, 128, .15); }
.done .xp { font-size: 30px; font-weight: 700; }
.warn { background: var(--sport-soft); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-top: 10px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + var(--safe-bottom)); z-index: 30; margin: 0 auto; max-width: 520px;
         background: rgba(20, 22, 26, .92); color: #fff; border-radius: 12px; padding: 11px 14px; font-size: 14px; }

.skeleton { background: var(--card); border-radius: var(--radius); height: 110px; margin-bottom: 10px; position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(128, 128, 128, .08), transparent);
                   animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---- рейтинги ---- */
.rank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.rank-grid .card { margin-bottom: 0; padding: 12px; min-width: 0; }
.rank-head { font-weight: 600; margin-bottom: 4px; }
.rank-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; font-size: 14px; }
.rank-row + .rank-row { border-top: 1px solid var(--line); }
.rank-row .place { width: 22px; text-align: center; flex: none; }
.rank-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row.mine .grow { font-weight: 700; }
@media (max-width: 350px) { .rank-grid { grid-template-columns: 1fr; } }

/* ---- переключатель и номинации ---- */
.segment { display: flex; background: var(--card); border-radius: 12px; padding: 3px; margin: 2px 0 12px; }
.segment button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 6px; font-weight: 600; color: var(--hint); font-size: 14px; }
.segment button.on { background: var(--btn); color: var(--btn-text); }
.award .award-icon { font-size: 22px; width: 36px; height: 36px; border-radius: 11px; background: var(--quest-soft); display: grid; place-items: center; flex: none; }
.award-win { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 10px; }
.award.empty .award-icon { filter: grayscale(1); opacity: .6; }
.award.mine { box-shadow: inset 0 0 0 1.5px var(--quest); }
.award-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.award-row:first-of-type { margin-top: 8px; }
.award-row .right { display: flex; flex-direction: column; align-items: flex-end; }
.award-row.mine > span:first-child { font-weight: 600; }
.prize { margin-top: 10px; background: var(--quest-soft); border-radius: 10px; padding: 8px 10px; font-size: 13px; }

/* ---- ивент пятницы ---- */
:root { --quest: #c28a12; --quest-soft: rgba(194, 138, 18, .15); }
.tag.q { background: var(--quest-soft); }
.quest-card { display: block; width: 100%; border: 0; text-align: left; box-shadow: inset 0 0 0 1.5px var(--quest-soft); }
.quest-card .sphere-icon, .quest-hero .sphere-icon { background: var(--quest-soft); }
.quest-card .bar > i, .quest-hero .bar > i { background: var(--quest); }
.quest-card.idle { box-shadow: none; }
.q-dots { display: flex; gap: 6px; margin-top: 10px; }
.q-dots span { flex: 1; height: 30px; border-radius: 9px; background: var(--line); display: grid; place-items: center; font-size: 15px; }
.q-dots span.done { background: var(--quest-soft); }
.q-dots span.pending { background: rgba(128, 128, 128, .12); }
.q-dots span.failed, .q-dots span.rejected { background: rgba(216, 72, 61, .12); }
.quest-hero { text-align: center; padding: 18px 16px; }
.quest-hero .big { font-size: 40px; line-height: 1; }
.quest-hero h1 { margin-top: 8px; }
.quest-task .q-desc { margin: 8px 0 0; color: var(--text); white-space: pre-wrap; }
.quest-task .q-icon { font-size: 22px; width: 36px; height: 36px; border-radius: 11px; background: var(--quest-soft); display: grid; place-items: center; flex: none; }
.quest-task.done .q-icon { background: var(--faith-soft); }
.quest-task .btn { margin-top: 12px; }
.state { font-size: 13px; font-weight: 600; white-space: nowrap; }
.state.done { color: var(--faith); }
.state.failed, .state.rejected { color: var(--danger); }
.state.pending, .state.todo { color: var(--hint); }
.celebrate { background: var(--quest-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; text-align: center; font-weight: 600; }

.q-question { font-size: 21px; margin: 6px 0 16px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option { border: 0; border-radius: 12px; background: var(--card); padding: 14px 16px; text-align: left; font-size: 16px; }
.option.on { box-shadow: inset 0 0 0 2px var(--btn); }
.review { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.review span { font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.review span.correct { background: var(--faith-soft); font-weight: 600; }
.review span.wrong { background: rgba(216, 72, 61, .12); text-decoration: line-through; }
/* ---- база знаний ---- */
.lib-card { display: block; width: 100%; border: 0; text-align: left; }
.lib-card .sphere-icon { background: var(--faith-soft); }
.lib-counts { margin-top: 10px; font-size: 13px; color: var(--hint); }
.lib-last { margin-top: 6px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-cap { margin: 8px 4px 2px; }
.lib-search { margin-bottom: 10px; }
.lib-item .q-icon { font-size: 22px; width: 36px; height: 36px; border-radius: 11px; background: var(--faith-soft); display: grid; place-items: center; flex: none; }
.lib-item .q-desc { margin: 8px 0 0; color: var(--text); white-space: pre-wrap; }
.lib-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.lib-row .btn { flex: 1; margin: 0; }
.lib-by { margin-top: 8px; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--btn); }
.check.off { opacity: .55; }
.check + .input { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } .bar > i { transition: none; } }
