/* ============ Сезон 1 — дизайн-токены ============ */
:root {
  /* пространство: шкала ×4 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  /* типографика */
  --t-xs: 11px; --t-sm: 13px; --t-base: 15px; --t-lg: 17px; --t-xl: 22px; --t-2xl: 30px;
  /* цветовые роли: нейтральная база + ОДИН акцент (гоночный оранжевый) */
  --bg: #0c0d10;
  --surface: #14161b;
  --surface-2: #1b1e25;
  --border: #272b34;
  --border-soft: #1e222a;
  --text: #eef0f4;
  --muted: #9aa1ad;
  --subtle: #69707e;
  --accent: #f2622d;
  --accent-press: #d9531f;
  --accent-tint: rgba(242, 98, 45, .13);
  --on-accent: #160f0a;
  --danger: #e05252;
  /* форма и тень */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --shadow: 0 6px 28px rgba(24, 12, 6, .38);
  --ease: cubic-bezier(.32, .72, 0, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--t-base)/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
b { font-weight: 600; }

button {
  font: inherit; color: inherit; background: none; border: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

input, textarea {
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s3) var(--s4);
  width: 100%;
  transition: border-color .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { resize: none; }

/* ============ Кнопки ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s3) var(--s5);
  border-radius: var(--r-md);
  font-weight: 600; font-size: var(--t-base);
  transition: transform .12s var(--ease), background .15s var(--ease), opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-block { width: 100%; }
.btn-mini { padding: var(--s1) var(--s3); font-size: var(--t-sm); border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent); }
.icon-btn { font-size: 18px; padding: var(--s2); border-radius: var(--r-sm); line-height: 1; }
.icon-btn:active { transform: scale(.94); }
@media (hover: hover) {
  .btn-secondary:hover { background: var(--border-soft); }
  .icon-btn:hover { background: var(--surface-2); }
}

/* ============ Каркас ============ */
#app { max-width: 480px; margin: 0 auto; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.screen { padding: 0 var(--s4); display: flex; flex-direction: column; gap: var(--s5); }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s4); max-width: 480px; margin: 0 auto;
}
.wordmark {
  font-size: var(--t-sm); font-weight: 700; letter-spacing: .14em; color: var(--text);
}
.top-meta { font-size: var(--t-xs); color: var(--subtle); font-variant-numeric: tabular-nums; }

h1 { font-size: var(--t-2xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin: 0; text-wrap: balance; }
.sec-title { font-size: var(--t-sm); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 var(--s3); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; }
.sec-count { font-size: var(--t-sm); color: var(--subtle); font-variant-numeric: tabular-nums; }

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: var(--s4);
}

/* ============ Карточка уровня (двойной кант) ============ */
.level-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s1);
  box-shadow: var(--shadow);
}
.level-core {
  background: var(--surface-2);
  border-radius: calc(var(--r-lg) - var(--s1));
  padding: var(--s4);
}
.level-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--s3); }
.level-rank { font-size: var(--t-xl); font-weight: 700; letter-spacing: -.01em; }
.level-num { font-size: var(--t-sm); color: var(--muted); margin-top: 2px; }
.streak {
  font-size: var(--t-sm); color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: var(--s1) var(--s3);
  font-variant-numeric: tabular-nums;
}
.xpbar { height: 8px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.xpbar-fill {
  height: 100%; background: var(--accent); border-radius: 999px;
  transition: width .5s var(--ease);
}
.xp-nums {
  display: flex; justify-content: space-between; margin-top: var(--s2);
  font-size: var(--t-xs); color: var(--subtle); font-variant-numeric: tabular-nums;
}

/* ============ Босс-баннер ============ */
.boss-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  background: var(--accent-tint); border: 1px solid var(--accent);
  border-radius: var(--r-md); padding: var(--s3) var(--s4);
  font-weight: 600; font-size: var(--t-sm);
}

/* ============ Сегментированный контрол ============ */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border-radius: var(--r-md); padding: var(--s1); }
.seg-btn {
  padding: var(--s2); border-radius: var(--r-sm);
  font-size: var(--t-sm); font-weight: 600; color: var(--subtle);
  transition: background .15s var(--ease), color .15s;
}
.seg-btn.active { background: var(--surface-2); color: var(--text); }

/* ============ Режимы тренировок ============ */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.mode {
  text-align: left; background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  display: flex; flex-direction: column; gap: 2px;
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .12s var(--ease);
}
.mode:active { transform: scale(.98); }
.mode.selected { border-color: var(--accent); background: var(--accent-tint); }
.mode-name { font-weight: 600; font-size: var(--t-base); }
.mode-time { font-size: var(--t-xs); color: var(--subtle); }
.mode-xp {
  font-size: var(--t-xs); font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.mode.selected .mode-xp::after { content: " ✓"; }
.skip-btn {
  width: 100%; margin-top: var(--s3); padding: var(--s2);
  font-size: var(--t-sm); color: var(--subtle);
  border: 1px dashed transparent; border-radius: var(--r-sm);
  transition: color .15s, border-color .15s;
}
.skip-btn.selected { color: var(--muted); border-color: var(--border); }

/* ============ Квесты ============ */
.quests { display: flex; flex-direction: column; }
.quest {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s1);
  border-bottom: 1px solid var(--border-soft);
  text-align: left; width: 100%;
  transition: opacity .15s;
}
.quest:last-child { border-bottom: none; }
.quest:active { opacity: .7; }
.q-check {
  width: 24px; height: 24px; flex: none;
  border: 1.5px solid var(--border); border-radius: 999px;
  display: grid; place-items: center;
  font-size: 13px; color: var(--on-accent);
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.quest.done .q-check { background: var(--accent); border-color: var(--accent); }
.quest.done .q-check::after { content: "✓"; font-weight: 700; }
.q-label { flex: 1; font-size: var(--t-base); }
.quest.done .q-label { color: var(--muted); }
.q-xp { font-size: var(--t-xs); color: var(--subtle); font-variant-numeric: tabular-nums; }

/* ============ Статистика ============ */
#chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-empty { color: var(--subtle); font-size: var(--t-sm); padding: var(--s5) 0; text-align: center; }
.w-add { display: flex; gap: var(--s2); margin-top: var(--s3); }
.w-add input { flex: 1; }
.w-add .btn { flex: none; }

.season-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.stat-cell { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s3); }
.stat-v { font-size: var(--t-xl); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-k { font-size: var(--t-xs); color: var(--subtle); margin-top: 2px; }

.week-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) 0; border-bottom: 1px solid var(--border-soft);
  font-size: var(--t-sm); font-variant-numeric: tabular-nums;
}
.week-row:last-child { border-bottom: none; }
.week-n { color: var(--subtle); width: 28px; flex: none; }
.week-bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.week-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.week-info { color: var(--muted); flex: none; }
.week-bonus { color: var(--accent); font-weight: 600; flex: none; }

/* ============ Босс ============ */
.boss-hero { text-align: center; }
.boss-hero .big { font-size: 40px; line-height: 1; margin-bottom: var(--s2); }
.boss-hero h3 { margin: 0 0 var(--s1); font-size: var(--t-lg); }
.boss-hero p { margin: 0; color: var(--muted); font-size: var(--t-sm); }
.boss-field {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) 0;
}
.boss-field label { flex: 1; font-size: var(--t-sm); }
.boss-field .rec { font-size: var(--t-xs); color: var(--subtle); display: block; }
.boss-field input { width: 88px; text-align: center; font-variant-numeric: tabular-nums; }
#boss-save { margin-top: var(--s3); }
.boss-row {
  display: flex; justify-content: space-between; gap: var(--s2);
  padding: var(--s2) 0; border-bottom: 1px solid var(--border-soft);
  font-size: var(--t-sm); font-variant-numeric: tabular-nums;
}
.boss-row:last-child { border-bottom: none; }
.boss-date { color: var(--subtle); }
.rec-mark { color: var(--accent); font-weight: 700; }
.empty-note { color: var(--subtle); font-size: var(--t-sm); text-align: center; padding: var(--s4) 0; }

/* ============ Тренер ============ */
.coach-intro { text-align: center; }
.coach-face { font-size: 40px; margin-bottom: var(--s2); }
.coach-intro p { color: var(--muted); font-size: var(--t-sm); margin: 0 0 var(--s4); text-wrap: pretty; }
.coach-ask { display: flex; flex-direction: column; gap: var(--s2); }
.coach-loading {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4); background: var(--surface); border-radius: var(--r-lg);
  color: var(--muted); font-size: var(--t-sm);
}
.pit-dots { display: inline-flex; gap: 4px; }
.pit-dots i {
  width: 6px; height: 6px; border-radius: 999px; background: var(--accent);
  animation: pit 1.2s var(--ease) infinite;
}
.pit-dots i:nth-child(2) { animation-delay: .15s; }
.pit-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes pit { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.coach-answer {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r-lg); padding: var(--s4);
  font-size: var(--t-base); white-space: pre-wrap; text-wrap: pretty;
}
.coach-answer .meta { font-size: var(--t-xs); color: var(--subtle); margin-bottom: var(--s2); }

/* ============ Таб-бар ============ */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 480px; margin: 0 auto;
  background: rgba(12, 13, 16, .88);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--border-soft);
  padding: var(--s2) 0 calc(var(--s2) + env(safe-area-inset-bottom));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: var(--t-xs); color: var(--subtle);
  transition: color .15s;
}
.tab-ico { font-size: 20px; filter: grayscale(1) opacity(.55); transition: filter .15s; }
.tab.active { color: var(--text); }
.tab.active .tab-ico { filter: none; }

/* ============ Шторка настроек ============ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, .55);
  opacity: 1; transition: opacity .2s var(--ease);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 480px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s3) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s4);
  transform: translateY(0); transition: transform .25s var(--ease);
}
.sheet.hidden-anim { transform: translateY(105%); }
.sheet-grip { width: 36px; height: 4px; border-radius: 999px; background: var(--border); margin: 0 auto; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); font-size: var(--t-base); }
.set-row input { width: 100px; text-align: center; }
.stepper { display: flex; align-items: center; gap: var(--s2); }
.stepper button {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: var(--t-lg); line-height: 1;
}
.stepper button:active { transform: scale(.94); }
.stepper b { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }

/* ============ Тост ============ */
.toast {
  position: fixed; left: var(--s4); right: var(--s4); z-index: 30;
  bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: 448px; margin: 0 auto;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s3) var(--s4);
  font-size: var(--t-sm); text-align: center;
  box-shadow: var(--shadow);
  animation: toast-in .25s var(--ease);
}
.toast.err { border-color: var(--danger); }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ Онбординг ============ */
.onboard {
  max-width: 480px; margin: 0 auto; padding: var(--s6) var(--s4) var(--s7);
  display: flex; flex-direction: column; gap: var(--s5);
}
.ob-head { text-align: center; display: flex; flex-direction: column; gap: var(--s2); }
.onboard-flag { font-size: 48px; line-height: 1; }
.onboard-sub { color: var(--muted); margin: 0; text-wrap: pretty; font-size: var(--t-sm); }
.ob-progress { display: flex; gap: var(--s2); justify-content: center; margin-top: var(--s2); }
.ob-progress i { width: 28px; height: 4px; border-radius: 999px; background: var(--border); transition: background .2s var(--ease); }
.ob-progress i.on { background: var(--accent); }
.ob-step { display: flex; flex-direction: column; gap: var(--s3); }
.ob-step-title { font-size: var(--t-lg); font-weight: 700; margin: 0 0 var(--s1); letter-spacing: -.01em; }
.ob-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.ob-nav { display: grid; grid-template-columns: 1fr 2fr; gap: var(--s3); margin-top: var(--s2); }
.ob-nav .btn-secondary.hidden { display: none; }
.field { text-align: left; display: block; }
.field-label { display: block; font-size: var(--t-sm); color: var(--muted); margin-bottom: var(--s1); }
.onboard-note { min-height: 1.4em; margin: var(--s1) 0 0; font-size: var(--t-sm); color: var(--accent); }

/* Чипы выбора */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  padding: var(--s2) var(--s4); border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: var(--t-sm); color: var(--muted);
  transition: background .15s var(--ease), color .15s, border-color .15s, transform .12s var(--ease);
}
.chip:active { transform: scale(.96); }
.chip.active { background: var(--accent-tint); border-color: var(--accent); color: var(--text); font-weight: 600; }
.stepper.wide { justify-content: space-between; }
.stepper.wide b { flex: 1; font-size: var(--t-lg); }

/* ============ Locked ============ */
.locked { min-height: 100dvh; display: grid; place-items: center; padding: var(--s5); }
.locked-inner { text-align: center; }
.locked-emoji { font-size: 56px; margin-bottom: var(--s3); }
.locked p { color: var(--muted); }

/* ============ Скелетон загрузки ============ */
.boot { max-width: 480px; margin: 0 auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.sk { background: var(--surface-2); border-radius: var(--r-md); animation: sk 1.2s ease-in-out infinite alternate; }
.sk-card { height: 120px; }
.sk-line { height: 20px; }
.sk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); background: none; animation: none; }
.sk-grid .sk { height: 68px; }
@keyframes sk { from { opacity: .5; } to { opacity: 1; } }

/* ============ Уровень: крупный номер + разбор XP ============ */
#level-card { cursor: pointer; }
.level-num-big { font-size: var(--t-xl); font-weight: 700; letter-spacing: -.01em; }
.level-hint { font-size: var(--t-xs); color: var(--subtle); margin-top: 2px; }
.xp-breakdown { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s2); }
.brk-row { display: flex; justify-content: space-between; font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.brk-row b { color: var(--text); }

/* ============ Прогноз цели ============ */
.proj-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--r-lg); padding: var(--s4); border-left: 3px solid var(--border); }
.proj-card.ok { border-left-color: #4caf6e; }
.proj-card.warn { border-left-color: var(--accent); }
.proj-main { font-size: var(--t-lg); font-weight: 600; letter-spacing: -.01em; }
.proj-sub { font-size: var(--t-sm); color: var(--muted); margin-top: 2px; }

/* ============ Фокус недели + задачи ============ */
.focus-card { display: flex; flex-direction: column; gap: var(--s3); }
.focus-head { font-size: var(--t-base); }
.focus-tasks { display: flex; flex-direction: column; }
.ftask { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--border-soft); text-align: left; width: 100%; }
.ftask:active { opacity: .7; }
.ftask.done span:last-child { color: var(--muted); text-decoration: line-through; }
.ftask.done .q-check { background: var(--accent); border-color: var(--accent); }
.ftask.done .q-check::after { content: "✓"; font-weight: 700; }
.focus-empty { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.focus-sub { font-size: var(--t-sm); color: var(--subtle); margin-top: 2px; }
.btn-sm { padding: var(--s2) var(--s3); font-size: var(--t-sm); border-radius: var(--r-sm); flex: none; }

/* ============ Календарь ============ */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s3); }
.cal-head b { font-size: var(--t-base); }
.cal-nav { width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--t-lg); line-height: 1; }
.cal-nav:active { transform: scale(.94); }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { margin-bottom: 4px; }
.cal-dow span { text-align: center; font-size: var(--t-xs); color: var(--subtle); }
.cal-cell { aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--r-sm); font-size: var(--t-sm); color: var(--muted); background: var(--surface-2); border: 1px solid transparent; font-variant-numeric: tabular-nums; }
.cal-cell.empty { background: none; }
.cal-cell.w { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.cal-cell.q { background: var(--accent-tint); color: var(--text); }
.cal-cell.rest { background: var(--surface-2); color: var(--subtle); }
.cal-cell.m { background: var(--surface-2); color: var(--subtle); opacity: .55; }
.cal-cell.today { border-color: var(--text); }
.cal-cell.out { opacity: .3; }
.cal-cell:not(.empty):active { transform: scale(.92); }
.cal-legend { display: flex; gap: var(--s4); margin-top: var(--s3); font-size: var(--t-xs); color: var(--subtle); flex-wrap: wrap; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .dot { width: 10px; height: 10px; border-radius: 3px; }
.cal-legend .dot.w { background: var(--accent); }
.cal-legend .dot.q { background: var(--accent-tint); border: 1px solid var(--accent); }
.cal-legend .dot.m { background: var(--surface-2); opacity: .55; border: 1px solid var(--border); }
.cal-detail { margin-top: var(--s3); font-size: var(--t-sm); color: var(--muted); min-height: 1.4em; }
.cal-detail b { color: var(--text); }

/* ============ Стата веса/талии ============ */
.w-stats { display: flex; gap: var(--s3); margin-top: var(--s3); }
.wstat { flex: 1; background: var(--surface-2); border-radius: var(--r-md); padding: var(--s3); }
.wstat-v { font-size: var(--t-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.wstat-k { font-size: var(--t-xs); color: var(--subtle); margin-top: 2px; }
.w-add { flex-wrap: wrap; }
.w-add input { flex: 1 1 40%; min-width: 120px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
