/* Fit — мобільний застосунок тренера. Один стилевий файл, без збірки. */

:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-input: #1e222b;
  --line: #272c37;
  --text: #eef1f6;
  --muted: #98a1b3;
  --faint: #6b7488;
  --accent: #7c5cff;
  --accent-soft: rgba(124, 92, 255, .16);
  --ok: #35d07f;
  --ok-soft: rgba(53, 208, 127, .14);
  --warn: #ffb020;
  --danger: #ff5a5a;
  --danger-soft: rgba(255, 90, 90, .14);
  --radius: 16px;
  --tap: 46px;
  --topbar-h: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8;
    --bg-elev: #ffffff;
    --bg-input: #f0f2f6;
    --line: #e2e5ec;
    --text: #131722;
    --muted: #6b7385;
    --faint: #929aab;
    --accent: #6a45f5;
    --accent-soft: rgba(106, 69, 245, .1);
    --ok: #17a55e;
    --ok-soft: rgba(23, 165, 94, .12);
    --danger: #dc3b3b;
    --danger-soft: rgba(220, 59, 59, .1);
  }
}

* { box-sizing: border-box; }

/* Ховаємо через атрибут hidden, а нижче в файлі елементам задано display:
   flex/grid/block. Звичайне правило специфічніше за браузерне [hidden],
   тож без цього рядка hidden просто не працює. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }

/* Іконки скрізь однакові: тонкий контур, який успадковує колір тексту. */
svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Каркас ---------- */

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; gap: 6px;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-titles { flex: 1; min-width: 0; }
.topbar h1 {
  font-size: 19px; font-weight: 650; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.topbar-actions { display: flex; gap: 4px; }

.view {
  padding: calc(var(--topbar-h) + var(--safe-top) + 12px) 14px
           calc(72px + var(--safe-bottom));
  max-width: 720px; margin: 0 auto;
}

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 8px; color: var(--faint); font-size: 11px; font-weight: 500;
}
.tabbar a.active { color: var(--accent); }
.tabbar svg { width: 23px; height: 23px; }

.offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  padding: calc(var(--safe-top) + 6px) 12px 6px;
  background: var(--warn); color: #241a00;
  font-size: 13px; font-weight: 600; text-align: center;
}

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--line); border-radius: 13px;
  background: var(--bg-elev); color: var(--text);
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #04220f; }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--text);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: var(--bg-input); }

/* ---------- Блоки ---------- */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card-tight { padding: 0; overflow: hidden; }

.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 22px 2px 9px;
  font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--faint);
}
.section-title:first-child { margin-top: 4px; }

.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 13px 14px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  color: inherit; font: inherit; cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--bg-input); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 15.5px; }
.row-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.row-side { color: var(--faint); font-size: 13px; text-align: right; flex: none; }
.chevron { width: 18px; height: 18px; color: var(--faint); flex: none; }

.avatar {
  width: 40px; height: 40px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 15px;
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-input); color: var(--muted);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: rgba(255, 176, 32, .14); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.empty {
  padding: 44px 20px; text-align: center; color: var(--muted);
}
.empty-title { font-weight: 650; color: var(--text); margin-bottom: 5px; font-size: 16px; }
.empty p { font-size: 14px; line-height: 1.5; }
.empty .btn { margin-top: 16px; }

.skeleton {
  height: 74px; border-radius: var(--radius); margin-bottom: 12px;
  background: linear-gradient(100deg, var(--bg-elev) 30%, var(--bg-input) 50%, var(--bg-elev) 70%);
  background-size: 220% 100%;
  animation: sk 1.2s ease-in-out infinite;
}
@keyframes sk { to { background-position: -120% 0; } }

/* ---------- Сьогодні ---------- */

.day-head { margin: 0 2px 16px; }
.day-head h2 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.day-head p { color: var(--muted); font-size: 14px; margin-top: 3px; }

.session {
  display: flex; gap: 12px; align-items: stretch;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  color: inherit; font: inherit;
}
.session:active { transform: scale(.99); }
.session.is-done { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.session-time {
  flex: none; width: 52px;
  font-size: 17px; font-weight: 700; letter-spacing: -.02em;
}
.session-time small { display: block; font-size: 11px; font-weight: 600; color: var(--faint); }
.session-body { flex: 1; min-width: 0; }
.session-name { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.session-day { font-size: 14px; color: var(--muted); margin-top: 2px; }
.session-meta { margin-top: 8px; }

/* ---------- Тиждень ---------- */

.week-day { margin-bottom: 18px; }
.week-day h3 {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); margin: 0 2px 7px;
}
.week-day.is-today h3 { color: var(--accent); }
.week-empty { color: var(--faint); font-size: 13.5px; padding: 4px 2px 0; }

/* ---------- Форми ---------- */

label.field { display: block; margin-bottom: 13px; }
label.field > span, .auth label > span {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
input, textarea, select {
  width: 100%; min-height: var(--tap); padding: 11px 13px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid transparent; border-radius: 12px;
  font: inherit; font-size: 16px; /* 16px — інакше iOS зумить при фокусі */
  appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); background: var(--bg-elev);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a1b3' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 18px;
  padding-right: 36px;
}
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }
.hint { font-size: 12.5px; color: var(--faint); margin-top: -7px; margin-bottom: 13px; }

/* ---------- Редактор програми ---------- */

.day-tabs {
  display: flex; gap: 7px; overflow-x: auto; margin: 0 -14px 14px; padding: 0 14px 2px;
  scrollbar-width: none;
}
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
  flex: none; padding: 8px 14px; border-radius: 11px;
  background: var(--bg-elev); border: 1px solid var(--line);
  color: var(--muted); font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap;
}
.day-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.ex-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.ex-item:last-child { border-bottom: 0; }
.ex-item-main { flex: 1; min-width: 0; cursor: pointer; }
.ex-item-name { font-weight: 600; font-size: 15px; }
.ex-item-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ex-move { display: flex; flex-direction: column; gap: 2px; flex: none; }
.ex-move button {
  width: 30px; height: 24px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 7px; background: var(--bg-input); color: var(--muted); cursor: pointer;
}
.ex-move svg { width: 15px; height: 15px; }
.ex-move button[disabled] { opacity: .3; }

/* ---------- Екран тренування ---------- */

.wo-ex { margin-bottom: 12px; }
.wo-ex-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 14px 11px; border-bottom: 1px solid var(--line);
}
.wo-ex-head h3 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.wo-target { font-size: 13px; color: var(--muted); margin-top: 3px; }
.wo-last { font-size: 12.5px; color: var(--accent); margin-top: 4px; }

.set-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: 0; }
.set-no {
  flex: none; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--bg-input);
  font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.set-row input { min-height: 40px; padding: 8px 10px; text-align: center; font-size: 16px; font-weight: 600; }
.set-unit { flex: none; font-size: 12px; color: var(--faint); width: 20px; }
.set-check {
  flex: none; width: 40px; height: 40px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--bg-input); color: var(--faint); cursor: pointer;
}
.set-row.is-done .set-check { background: var(--ok); border-color: var(--ok); color: #04220f; }
.set-row.is-done .set-no { background: var(--ok-soft); color: var(--ok); }

.wo-note { padding: 10px 14px 14px; }
.wo-note textarea { min-height: 56px; font-size: 15px; }

.wo-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; gap: 10px; padding: 10px 14px calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.wo-footer .btn { flex: 1; }
.view.has-footer { padding-bottom: calc(96px + var(--safe-bottom)); }

.save-state {
  font-size: 12px; color: var(--faint); text-align: center;
  padding: 2px 0 10px;
}
.save-state.is-offline { color: var(--warn); }

/* ---------- Історія ---------- */

.hist-row { display: flex; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.hist-row:last-child { border-bottom: 0; }
.hist-date { flex: none; width: 58px; font-size: 13px; font-weight: 650; color: var(--muted); }
.hist-body { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); }
.hist-body b { color: var(--text); font-weight: 600; }

/* ---------- Модалка ---------- */

.modal-back {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .55);
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(20px + var(--safe-bottom));
  animation: up .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes up { from { transform: translateY(28px); } }
.modal-grip {
  width: 38px; height: 4px; border-radius: 3px; background: var(--line);
  margin: 4px auto 14px;
}
.modal h2 { font-size: 19px; font-weight: 650; margin-bottom: 14px; letter-spacing: -.01em; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

.picker-search { margin-bottom: 10px; }
.picker-list { max-height: 46vh; overflow-y: auto; margin: 0 -16px; }

/* ---------- Тости ---------- */

.toast-root {
  position: fixed; left: 0; right: 0; z-index: 70;
  bottom: calc(84px + var(--safe-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 90%; padding: 11px 16px; border-radius: 13px;
  background: #23283a; color: #fff; font-size: 14px; font-weight: 550;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  animation: up .2s ease;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); color: #04220f; }

/* ---------- Вхід ---------- */

.auth {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.auth-card { width: 100%; max-width: 360px; }
.auth-logo {
  font-size: 34px; font-weight: 750; letter-spacing: -.04em;
  color: var(--accent); text-align: center;
}
.auth-lead { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 26px; }
.auth label { display: block; margin-bottom: 13px; }
.auth-error {
  background: var(--danger-soft); color: var(--danger);
  padding: 10px 13px; border-radius: 11px; font-size: 13.5px; margin-bottom: 13px;
}
.auth .btn { margin-top: 4px; }
