/* Метаморфоза · приложение курса. Одна колонка под телефон, нижняя панель вкладок, фирменная слива. */
:root {
  --bg: #2E1230;
  --bg2: #24102A;
  --card: rgba(255, 246, 247, .06);
  --card2: rgba(255, 246, 247, .1);
  --line: rgba(255, 246, 247, .12);
  --ink: #FFF6F7;
  --muted: rgba(255, 246, 247, .62);
  --faint: rgba(255, 246, 247, .38);
  --rose: #F07FA3;
  --green: #6BBF7E;
  --apricot: #F5A86B;
  --lilac: #B79BF2;
  --red: #FF7A7A;
  --display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --body: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-t: var(--tg-content-safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--body); }
body { min-height: 100vh; background: radial-gradient(120% 60% at 100% 0%, #4A1D45 0%, var(--bg) 55%) fixed, var(--bg); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
a { color: var(--rose); text-decoration: none; }
#app { padding: 14px 16px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; display: grid; gap: 18px; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 19px; line-height: 1.2; }
h3 { font-size: 16px; line-height: 1.25; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 16px; display: grid; gap: 12px; }
.card.linkcard { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; }
.eyebrow { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--card2); color: var(--ink); white-space: nowrap; }
.pill.ok { background: rgba(107, 191, 126, .18); color: var(--green); }
.pill.star { background: rgba(245, 168, 107, .18); color: var(--apricot); }
.pill.lock { color: var(--faint); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; padding: 12px 18px;
  border-radius: 16px; background: var(--rose); color: #2E1230; font-weight: 600; font-size: 16px; text-align: center; }
.btn.green { background: var(--green); }
.btn.ghost { background: var(--card2); color: var(--ink); }
.btn:disabled { opacity: .45; }
.btn:active, .tap:active { transform: scale(.98); }
.boot { min-height: 70vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--rose); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.msg { text-align: center; display: grid; gap: 14px; padding: 40px 10px; }

/* шапка курса */
.hero { display: grid; grid-template-columns: 104px 1fr; gap: 16px; align-items: center; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.ring-in b { display: flex; align-items: baseline; font-family: var(--display); font-weight: 700; font-size: 32px; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ring-in b span { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
.ring-in small { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* главы */
.block-h { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chapters { display: grid; gap: 10px; }
.ch { display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: center; padding: 8px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); text-align: left; width: 100%; }
.ch img { width: 92px; height: 69px; object-fit: cover; border-radius: 12px; display: block; }
.ch .t { font-weight: 600; line-height: 1.25; }
.ch .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ch.read { border-color: rgba(107, 191, 126, .35); }

/* глава */
.cover { width: 100%; border-radius: 20px; display: block; aspect-ratio: 4 / 3; object-fit: cover; }
.short { background: rgba(240, 127, 163, .1); border: 1px solid rgba(240, 127, 163, .35); border-radius: 20px; padding: 14px 16px; display: grid; gap: 8px; }
.short p { line-height: 1.45; }
.text { display: grid; gap: 18px; }
.text section { display: grid; gap: 10px; }
.text h3 { color: var(--ink); }
.text p, .text li { line-height: 1.55; }
.text ul, .text ol { margin: 0; padding-left: 20px; display: grid; gap: 7px; }
.text ul { list-style: none; padding-left: 0; }
.text ul li { padding-left: 18px; position: relative; }
.text ul li::before { content: ""; position: absolute; left: 2px; top: .65em; width: 7px; height: 7px; border-radius: 50%; background: var(--rose); }
.text ul li.ok::before { content: "✓"; background: none; color: var(--green); top: 0; left: 0; width: auto; height: auto; font-weight: 700; }
.text ul li.no::before { content: "✕"; background: none; color: var(--red); top: 0; left: 0; width: auto; height: auto; font-weight: 700; }
.text ul li.tip::before { content: "💡"; background: none; top: 0; left: -2px; width: auto; height: auto; font-size: 13px; }
.text blockquote { margin: 0; padding: 10px 14px; border-left: 3px solid var(--lilac); background: var(--card); border-radius: 0 14px 14px 0; }
.text a, .short a { color: var(--rose); border-bottom: 1px solid rgba(240, 127, 163, .4); }
.done-box { display: grid; gap: 10px; }

/* тесты */
.test-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); width: 100%; text-align: left; }
.test-row.final { border-color: rgba(245, 168, 107, .45); background: rgba(245, 168, 107, .08); }
.test-row.locked { opacity: .55; }
.bar { height: 6px; border-radius: 3px; background: var(--card2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--rose); border-radius: 3px; transition: width .3s; }
.q { font-family: var(--display); font-size: 20px; line-height: 1.3; font-weight: 600; }
.opts { display: grid; gap: 10px; }
.opt { padding: 15px 16px; border-radius: 16px; background: var(--card); border: 1.5px solid var(--line); text-align: left; line-height: 1.35; width: 100%; }
.opt.right { border-color: var(--green); background: rgba(107, 191, 126, .16); }
.opt.wrong { border-color: var(--red); background: rgba(255, 122, 122, .12); }
.opt:disabled { cursor: default; }
.explain { padding: 12px 14px; border-radius: 16px; background: var(--card2); line-height: 1.45; }
.score { font-family: var(--display); font-size: 56px; font-weight: 800; line-height: 1; }

/* трекер */
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.day-nav button { width: 44px; height: 44px; border-radius: 14px; background: var(--card2); font-size: 20px; }
.day-nav button:disabled { opacity: .3; }
.habit { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); width: 100%; text-align: left; }
.habit .box { width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--faint); flex: none; display: grid; place-items: center; font-weight: 800; color: #2E1230; }
.habit.on { border-color: rgba(107, 191, 126, .45); background: rgba(107, 191, 126, .1); }
.habit.on .box { background: var(--green); border-color: var(--green); }
.habit .h { font-weight: 600; line-height: 1.25; }
.grid21 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cell { aspect-ratio: 1; border-radius: 9px; background: var(--card); display: grid; place-items: center; font-size: 12px; color: var(--muted); border: 1.5px solid transparent; }
.cell.today { border-color: var(--rose); color: var(--ink); }
.cell.sel { outline: 2px solid var(--ink); outline-offset: 1px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* прогресс */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px; display: grid; gap: 4px; }
.stat b { font-family: var(--display); font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); line-height: 1.25; }
.chart svg { width: 100%; height: auto; display: block; }
.mtable { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.mtable td, .mtable th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.mtable td:first-child, .mtable th:first-child { text-align: left; }
.mtable th { font-size: 12px; color: var(--muted); font-weight: 600; }
.minus { color: var(--green); font-weight: 600; }
.plus { color: var(--apricot); font-weight: 600; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form input { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--ink); font: 500 17px var(--body); }
.form input:focus { outline: 2px solid var(--rose); border-color: transparent; }
.err { color: var(--red); font-size: 14px; }

/* ведущей */
.person { display: grid; gap: 10px; text-align: left; width: 100%; }
.person .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mlines { display: grid; gap: 5px; }
.mline { display: grid; grid-template-columns: 1fr auto 58px; gap: 10px; align-items: baseline; font-size: 14px; font-variant-numeric: tabular-nums; }
.mline > span:first-child { color: var(--muted); }
.mline > span:last-child { text-align: right; font-weight: 600; }
.mline.total { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.mline.total > span:first-child { color: var(--ink); font-weight: 600; }
.hists { display: grid; gap: 8px; }
.hist { display: grid; grid-template-columns: 50px 1fr; gap: 10px; font-size: 14px; line-height: 1.4; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.hist:last-child { border-bottom: 0; padding-bottom: 0; }
.hist b { font-variant-numeric: tabular-nums; }

/* шапка «Метаморфоза»: в полноэкранном режиме на телефоне — вместо заголовка Telegram с именем бота */
#brandbar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px 0;
  font: 600 12px var(--display); letter-spacing: .18em; color: var(--ink); }
#brandbar svg { width: 22px; height: 22px; flex: none; }
body.fs #brandbar { position: fixed; left: 0; right: 0; z-index: 9; padding: 0; top: var(--tg-safe-area-inset-top, 0px);
  height: var(--tg-content-safe-area-inset-top, 46px); background: rgba(46, 18, 48, .96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
body.fs #app { padding-top: calc(14px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 46px)); }

/* вкладки */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: rgba(36, 16, 42, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); }
#tabs .in { display: flex; width: 100%; max-width: 640px; }
#tabs button { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--muted); font-weight: 500; }
#tabs button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on { color: var(--rose); }
.toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #2E1230;
  padding: 10px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; z-index: 20; max-width: 90vw; text-align: center; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
