/* Дисциплина Life — стили. Цвета берутся из темы Telegram, фирменный акцент — «уголь и огонь». */
:root {
  --f-bg: #14110f; --f-text: #f6efe8; --f-hint: #a0948a; --f-card: #1f1a17;
  --accent: #ff6a1f; --accent-2: #ffb020; --accent-ink: #fff;
  --bg: var(--tg-theme-bg-color, var(--f-bg));
  --text: var(--tg-theme-text-color, var(--f-text));
  --hint: var(--tg-theme-hint-color, var(--f-hint));
  --card: var(--tg-theme-secondary-bg-color, var(--f-card));
  --line: color-mix(in srgb, var(--text) 13%, transparent);
  --soft: color-mix(in srgb, var(--text) 7%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --danger: #e5484d;
  --radius: 18px;
  --nav-h: 62px;
}
@media (prefers-color-scheme: light) {
  :root { --f-bg: #fbf7f2; --f-text: #1d1814; --f-hint: #82776d; --f-card: #f1e9e0; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#view {
  max-width: 560px; margin: 0 auto;
  padding: 14px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
}
.screen { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; animation: rise .28s ease-out both; }
.screen > * { min-width: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

h2 { margin: 6px 0 0; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--hint); font-weight: 600; }
.muted { color: var(--hint); }
.small { font-size: 13px; }

/* ---------- Герой: серия ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: 20px 20px 18px;
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 26%, var(--card)), var(--card) 62%);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center;
}
.hero .flame { width: 76px; height: 76px; color: var(--hint); opacity: .55; transition: .3s; }
.hero .flame svg { width: 100%; height: 100%; display: block; }
.hero.lit .flame { color: var(--accent); opacity: 1; filter: drop-shadow(0 6px 18px color-mix(in srgb, var(--accent) 55%, transparent)); }
.hero.done .flame { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.hero-num { font-size: 52px; line-height: 1; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero-label { color: var(--hint); font-size: 15px; margin-top: 2px; }
.hero-status { grid-column: 1 / -1; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; }
.hero-status b { color: var(--accent-2); font-weight: 650; }

/* ---------- Неделя ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; background: var(--card); border-radius: var(--radius); padding: 12px 8px; }
.wd { display: grid; justify-items: center; gap: 6px; font-size: 12px; color: var(--hint); }
.wd .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); }
.wd .dot svg { width: 16px; height: 16px; }
.wd.complete .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wd.partial .dot { border-color: var(--accent); }
.wd.missed .dot { background: var(--soft); border-style: dashed; }
.wd.none .dot { border-color: transparent; background: var(--soft); opacity: .5; }
.wd.is-today { color: var(--text); font-weight: 650; }
.wd.is-today .dot { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.wd.is-today.complete .dot { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Списки задач ---------- */
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.progress { height: 6px; background: var(--soft); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 0 6px 6px 0; transition: width .3s ease; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; width: 100%; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
.check {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--hint) 70%, transparent);
  display: grid; place-items: center; color: var(--accent-ink); transition: .18s;
}
.check svg { width: 17px; height: 17px; transform: scale(0); transition: transform .18s cubic-bezier(.3, 1.6, .5, 1); }
.row.done .check { background: var(--accent); border-color: var(--accent); }
.row.done .check svg { transform: scale(1); }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row .t span { display: block; color: var(--hint); font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.row.done .t b { color: var(--hint); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--hint) 60%, transparent); }
.icon-btn { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--hint); }
.icon-btn:active { background: var(--soft); }
.icon-btn svg { width: 18px; height: 18px; }
.empty { padding: 22px 18px; text-align: center; color: var(--hint); }

.add { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.add input, .field {
  flex: 1; min-width: 0; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); outline: none;
}
.add input:focus, .field:focus { border-color: var(--accent); }
.btn {
  padding: 11px 16px; border-radius: 12px; font-weight: 650; background: var(--accent); color: var(--accent-ink);
  transition: transform .1s;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--soft); color: var(--text); }
.btn[disabled] { opacity: .5; }

/* ---------- Рейтинг ---------- */
.lead { margin: 2px 2px 0; color: var(--hint); font-size: 14px; }
.rank-row { display: grid; grid-template-columns: 34px 40px 1fr auto; gap: 10px; align-items: center; padding: 11px 14px; }
.rank-row + .rank-row { border-top: 1px solid var(--line); }
.rank-row.me { background: var(--accent-soft); }
.rank-n { text-align: center; font-weight: 700; color: var(--hint); font-variant-numeric: tabular-nums; }
.rank-n.medal { font-size: 22px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  color: #fff; background-size: cover; background-position: center; overflow: hidden;
}
.rank-name { min-width: 0; }
.rank-name b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-name span { font-size: 13px; color: var(--hint); }
.streak-pill { display: inline-flex; align-items: center; gap: 4px; font-weight: 750; font-variant-numeric: tabular-nums; }
.streak-pill svg { width: 18px; height: 18px; color: var(--accent); }
.rank-sep { text-align: center; color: var(--hint); letter-spacing: .3em; padding: 2px 0; }

/* ---------- Профиль ---------- */
.profile-head { display: flex; align-items: center; gap: 14px; padding: 4px 2px; }
.profile-head .avatar { width: 56px; height: 56px; font-size: 20px; }
.profile-head b { font-size: 20px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 14px 8px; text-align: center; }
.tile b { display: block; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--hint); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 14px; }
.cal .h { text-align: center; font-size: 11px; color: var(--hint); }
.cal .c { aspect-ratio: 1; border-radius: 9px; background: var(--soft); display: grid; place-items: center; font-size: 11px; color: var(--hint); }
.cal .c.complete { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.cal .c.partial { background: color-mix(in srgb, var(--accent) 38%, transparent); color: var(--text); }
.cal .c.missed { background: transparent; border: 1.5px dashed var(--line); }
.cal .c.none { opacity: .35; }
.cal .c.pad { background: none; }
.cal .c.is-today { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row small { display: block; color: var(--hint); font-size: 13px; }
.switch { position: relative; flex: none; width: 50px; height: 30px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 30px; background: var(--line); transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
select.field { flex: none; width: auto; padding: 8px 10px; }

/* ---------- Администратор ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.bar { height: 6px; border-radius: 6px; background: var(--soft); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.edit-form { display: grid; gap: 8px; padding: 12px 14px; }
.edit-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Навигация и мелочи ---------- */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
#nav .inner { display: flex; width: 100%; max-width: 560px; }
#nav button { flex: 1; height: var(--nav-h); display: grid; place-items: center; align-content: center; gap: 2px; font-size: 11px; color: var(--hint); font-weight: 550; }
#nav button svg { width: 24px; height: 24px; }
#nav button.active { color: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 14px; max-width: 86vw;
  opacity: 0; pointer-events: none; transition: .22s; z-index: 20; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.center { min-height: 60vh; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; color: var(--hint); padding: 20px; }
.center .flame { width: 56px; height: 56px; color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.center .flame svg { width: 100%; height: 100%; }
.skeleton { background: linear-gradient(90deg, var(--soft), var(--line), var(--soft)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
