:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --card: var(--tg-theme-secondary-bg-color, #232e3c);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #8a97a3);
  --accent: var(--tg-theme-button-color, #3390ec);
  --accent-txt: var(--tg-theme-button-text-color, #ffffff);
  --ok: #34c759;
  --danger: #ff453a;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 78px;               /* місце під таббар */
  overscroll-behavior-y: contain;
}

#app { max-width: 640px; margin: 0 auto; padding: 16px 14px 8px; }

.muted { color: var(--hint); font-size: 14px; line-height: 1.4; }
.mt { margin-top: 14px; }

/* ── Шапка дня ── */
.day-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.day-emoji {
  font-size: 34px; width: 56px; height: 56px; flex: 0 0 56px;
  display: grid; place-items: center;
  background: var(--card); border-radius: var(--radius);
}
.day-head-txt h1 { margin: 0; font-size: 21px; line-height: 1.15; }
.day-head-txt p { margin: 3px 0 0; }

/* ── Чіпи ── */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  background: var(--card); color: var(--hint);
  font-size: 12px; font-weight: 600;
  padding: 6px 11px; border-radius: 20px;
}

/* ── Прогрес ── */
.progress-card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.progress-row { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 10px; }
.streak { font-size: 15px; }
.bar { height: 9px; background: rgba(128,128,128,.25); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--ok); border-radius: 6px; transition: width .35s ease; }

/* ── Картки-нотатки ── */
.note-card {
  display: flex; gap: 9px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; font-size: 14px; line-height: 1.45;
}
.note-card[hidden] { display: none; }  /* hidden має ховати, а не показувати порожню картку */
.note-card.warmup { border-left: 3px solid #ff9f0a; }
.note-card.rest { border-left: 3px solid #bf5af2; }
.note-card.cooldown { border-left: 3px solid #64d2ff; }
.note-card.back { display: block; border-left: 3px solid var(--danger); font-size: 13.5px; line-height: 1.5; }
.note-ico { font-size: 16px; }

/* ── Вправа ── */
.ex {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
  cursor: pointer; user-select: none;
  transition: transform .08s ease, opacity .2s ease;
}
.ex:active { transform: scale(.985); }
.ex.done { opacity: .62; }
.ex.done .ex-name { text-decoration: line-through; }

.check {
  flex: 0 0 26px; width: 26px; height: 26px; margin-top: 1px;
  border: 2px solid var(--hint); border-radius: 50%;
  display: grid; place-items: center;
  transition: background .15s ease, border-color .15s ease;
}
.check svg { width: 15px; height: 15px; opacity: 0; transition: opacity .15s ease; }
.ex.done .check { background: var(--ok); border-color: var(--ok); }
.ex.done .check svg { opacity: 1; }

.ex-body { flex: 1; min-width: 0; }
.ex-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ex-name { font-weight: 600; font-size: 15.5px; line-height: 1.25; }
.ex-reps {
  flex: 0 0 auto; font-weight: 700; font-size: 13px;
  color: var(--accent-txt); background: var(--accent);
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.ex-note { margin: 5px 0 0; color: var(--hint); font-size: 13px; line-height: 1.4; }

/* ── Кнопка / банер завершення ── */
.finish-btn {
  width: 100%; margin: 6px 0 4px; padding: 16px;
  background: var(--ok); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 16.5px; font-weight: 800; cursor: pointer;
  box-shadow: 0 6px 22px rgba(52,199,89,.35);
  animation: pop .25s ease;
}
.finish-btn:active { transform: scale(.98); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.finished-banner {
  margin: 6px 0 4px; padding: 16px; border-radius: var(--radius);
  background: rgba(52,199,89,.14); border: 1px solid rgba(52,199,89,.5);
  color: var(--ok); font-weight: 800; font-size: 16px; text-align: center;
}
.finished-banner span { display: block; margin-top: 5px; color: var(--text); font-weight: 600; font-size: 14px; }

/* ── Таймер відпочинку ── */
.timer-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; border-left: 3px solid #bf5af2;
}
.timer-card-label { font-size: 14px; font-weight: 600; }
.timer-btns { display: flex; gap: 8px; }
.timer-start {
  background: var(--accent); color: var(--accent-txt);
  border: none; border-radius: 20px; padding: 9px 16px;
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.timer-start:active { transform: scale(.95); }

.timer-run {
  position: fixed; left: 0; right: 0;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 60; display: flex; align-items: center; gap: 12px;
  background: var(--card); border-top: 1px solid rgba(128,128,128,.18);
  padding: 12px 16px; box-shadow: 0 -4px 20px rgba(0,0,0,.3);
}
.timer-run[hidden] { display: none; }
.timer-count {
  font-size: 24px; font-weight: 800; min-width: 78px;
  font-variant-numeric: tabular-nums;
}
.timer-run.ding .timer-count { color: var(--ok); }
.timer-progress { flex: 1; height: 8px; background: rgba(128,128,128,.25); border-radius: 5px; overflow: hidden; }
.timer-progress-fill { height: 100%; width: 100%; background: var(--accent); border-radius: 5px; transition: width .2s linear; }
.timer-run.ding .timer-progress-fill { background: var(--ok); }
.timer-cancel {
  background: transparent; color: var(--hint);
  border: 1px solid var(--hint); border-radius: 20px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}

.foot { text-align: center; margin: 16px 0 4px; }

/* ── Святковий оверлей ── */
.celebrate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .3s ease; padding: 24px;
}
/* важливо: hidden має реально ховати оверлей, інакше прозорий display:grid
   перекриває весь екран і перехоплює всі тапи (вкладки/кнопки «мертві») */
.celebrate[hidden] { display: none; }
.celebrate.show { opacity: 1; }
.celebrate-box {
  background: var(--card); border-radius: 24px; padding: 32px 26px;
  text-align: center; max-width: 340px; width: 100%;
  transform: scale(.9); transition: transform .3s cubic-bezier(.2,1.3,.4,1);
}
.celebrate.show .celebrate-box { transform: scale(1); }
.celebrate-emoji { font-size: 60px; animation: bounce .6s ease .1s; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-16px); } 60% { transform: translateY(-6px); } }
.celebrate-msg { font-size: 21px; font-weight: 800; margin: 14px 0 22px; line-height: 1.3; }
.celebrate-close {
  background: var(--accent); color: var(--accent-txt);
  border: none; border-radius: 30px; padding: 13px 30px;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.celebrate-close:active { transform: scale(.97); }

/* ── Вкладки прогрес/програма ── */
.tab-h { font-size: 20px; margin: 6px 0 12px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 18px 14px; text-align: center; }
.stat-num { font-size: 30px; font-weight: 800; line-height: 1; }
.stat-cap { color: var(--hint); font-size: 13px; margin-top: 7px; }

.prog-list { margin: 12px 0 16px; }
.prog-item { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 9px; }
.prog-item .pe { font-size: 24px; flex: 0 0 34px; text-align: center; }
.prog-item .pt { font-weight: 600; font-size: 15px; }
.prog-item .pf { color: var(--hint); font-size: 12.5px; margin-top: 2px; line-height: 1.35; }
.prog-item .pc { margin-left: auto; color: var(--hint); font-size: 12px; white-space: nowrap; }

.btn-danger {
  width: 100%; margin-top: 8px; padding: 14px;
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger); border-radius: var(--radius);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-danger:active { background: rgba(255,69,58,.1); }

/* ── Таббар ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: var(--card);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(128,128,128,.18);
}
.tabbtn {
  flex: 1; background: none; border: none; color: var(--hint);
  font-size: 11px; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px;
}
.tabbtn span { font-size: 21px; }
.tabbtn.active { color: var(--accent); }

/* ── Тост ── */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px);
  background: var(--ok); color: #fff; font-weight: 700; font-size: 15px;
  padding: 13px 20px; border-radius: 30px; max-width: 90%; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); opacity: 0; transition: all .3s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spin { text-align: center; color: var(--hint); padding: 40px 0; }
