:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efeb;
  --border: #e5e2dc;
  --text: #1b1a17;
  --muted: #6f6b63;
  --accent: #e5540f;
  --accent-hover: #cc4a0c;
  --accent-contrast: #ffffff;
  --accent-soft: #fde8dd;
  --success: #1c8f4d;
  --success-soft: #dcf3e5;
  --danger: #cf3434;
  --danger-soft: #fbe3e3;
  --gold: #a87300;
  --gold-soft: #fbefcf;
  --shadow: 0 1px 2px rgba(20, 16, 10, .04), 0 6px 20px rgba(20, 16, 10, .05);
  --radius: 16px;
  --radius-sm: 10px;
  --tab-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111112;
    --surface: #1b1b1d;
    --surface-2: #252528;
    --border: #2f2f33;
    --text: #f2f1ee;
    --muted: #9c998f;
    --accent: #ff7a3d;
    --accent-hover: #ff8f5c;
    --accent-contrast: #1a0d05;
    --accent-soft: #3a2317;
    --success: #43d17f;
    --success-soft: #16301f;
    --danger: #ff6b6b;
    --danger-soft: #3a1b1b;
    --gold: #f2c14e;
    --gold-soft: #3a3016;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111112;
  --surface: #1b1b1d;
  --surface-2: #252528;
  --border: #2f2f33;
  --text: #f2f1ee;
  --muted: #9c998f;
  --accent: #ff7a3d;
  --accent-hover: #ff8f5c;
  --accent-contrast: #1a0d05;
  --accent-soft: #3a2317;
  --success: #43d17f;
  --success-soft: #16301f;
  --danger: #ff6b6b;
  --danger-soft: #3a1b1b;
  --gold: #f2c14e;
  --gold-soft: #3a3016;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior-y: none;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, .chip, .tabbar, .sidebar, .appbar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; letter-spacing: -.02em; }
h2 { font-size: 18px; letter-spacing: -.01em; }
h3 { font-size: 16px; }
p { margin: 0; }
svg { display: block; }
.num, .tabular { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.ico { width: 20px; height: 20px; flex: none; }
[data-icon] { display: inline-flex; }

/* ---------- Оболонка застосунку ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; }
.view {
  max-width: 880px; margin: 0 auto;
  padding: 4px 16px calc(var(--tab-h) + 32px + env(safe-area-inset-bottom));
}
body.has-active-bar .view { padding-bottom: calc(var(--tab-h) + 120px + env(safe-area-inset-bottom)); }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }

/* Верхня панель екрана: компактний заголовок з'являється під час прокручування */
.appbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, background-color .2s;
}
.appbar.scrolled {
  border-bottom-color: var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.appbar-inner {
  max-width: 880px; margin: 0 auto; height: 52px; padding: 0 8px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
}
.appbar-side { display: flex; align-items: center; gap: 4px; min-width: 0; }
.appbar-side.right { justify-content: flex-end; }
.appbar-title {
  font-weight: 700; font-size: 16px; max-width: 52vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s;
}
.appbar.scrolled .appbar-title { opacity: 1; transform: none; }
.back-btn {
  display: inline-flex; align-items: center; gap: 2px;
  height: 38px; padding: 0 10px 0 2px; border: 0; border-radius: 10px;
  background: none; color: var(--accent); font-weight: 600; font-size: 16px; cursor: pointer;
}
.back-btn .ico { width: 24px; height: 24px; }

/* Великий заголовок екрана */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 32px; font-weight: 800; letter-spacing: -.03em; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* Нижня панель вкладок */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: stretch;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  transition: color .15s;
}
.tabbar a .ico { width: 24px; height: 24px; transition: transform .12s; }
.tabbar a.active { color: var(--accent); }
.tabbar a:active .ico { transform: scale(.88); }
.tab-main-btn {
  width: 52px; height: 52px; margin-top: -24px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-contrast);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 45%, transparent), 0 0 0 4px var(--bg);
  transition: transform .12s;
}
.tabbar a .tab-main-btn .ico { width: 26px; height: 26px; stroke-width: 2.4; }
.tabbar a.tab-main:active .ico { transform: none; }
.tab-main:active .tab-main-btn { transform: scale(.93); }
.nav-dot {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 0 2px var(--surface);
}
.tabbar .nav-dot { top: -12px; left: calc(50% + 16px); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.active { color: var(--accent); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ico { width: 18px; height: 18px; }
.icon-btn:disabled { opacity: .35; pointer-events: none; }

/* Панель активного тренування над вкладками */
.active-bar {
  position: fixed; z-index: 29; left: 10px; right: 10px;
  bottom: calc(var(--tab-h) + 32px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-radius: 16px;
  background: var(--accent); color: var(--accent-contrast);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent);
  animation: slide .25s ease-out;
}
.active-bar:active { transform: scale(.985); }
.active-bar-text { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.active-bar-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.active-bar-text small { opacity: .85; font-size: 12px; }
.active-bar-time { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex: none; animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .6); }
  70% { box-shadow: 0 0 0 9px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* Бічна панель (комп'ютер) */
.sidebar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; padding: 4px 10px 20px; }
.brand img { border-radius: 10px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a, .side-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; font-weight: 600; color: var(--muted);
  transition: background-color .15s, color .15s;
}
.side-nav a:hover, .side-link:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active, .side-link.active { background: var(--accent-soft); color: var(--accent); }
.side-nav .nav-dot { position: static; margin-left: auto; box-shadow: none; width: 8px; height: 8px; }
.side-bottom { margin-top: auto; display: grid; gap: 10px; }
.side-live {
  display: grid; gap: 2px; padding: 12px 14px; border-radius: 14px;
  background: var(--accent); color: var(--accent-contrast);
}
.side-live .row { gap: 8px; font-weight: 700; }
.side-live small { opacity: .85; }
.side-live .active-bar-time { font-size: 22px; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    padding: 22px 14px 18px;
    background: var(--surface); border-right: 1px solid var(--border);
  }
  .tabbar, .active-bar { display: none !important; }
  .view, body.has-active-bar .view { padding: 4px 32px 56px; }
  .appbar-inner { padding: 0 24px; }
  .appbar a[href="#/settings"], .appbar .mobile-only { display: none; }
}

/* ---------- Макет ---------- */
.stack { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 26px 0 12px; }
.section-title h2 { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.grid-2 { display: grid; gap: 14px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Кнопки та поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn .ico { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn.lg { height: 50px; padding: 0 22px; font-size: 16px; border-radius: 14px; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.dashed { border-style: dashed; background: transparent; color: var(--muted); }
.btn.dashed:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .75; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.form-row { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .form-row { grid-template-columns: 2fr 1fr auto; align-items: end; } }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--muted);
}
.badge .ico { width: 13px; height: 13px; }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Головна ---------- */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 22px; border-radius: 20px;
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 70%, #7a1d00) 100%);
  color: #fff; box-shadow: var(--shadow);
}
.hero h1 { color: #fff; }
.hero p { opacity: .88; margin-top: 4px; }
.hero .btn { background: #fff; border-color: #fff; color: #7a2a05; }
.hero .btn:hover { background: #fff3ec; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 14px 16px; }
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat-label .ico { width: 15px; height: 15px; }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.up { color: var(--success); }
.down { color: var(--danger); }

.pr-list { display: grid; gap: 2px; }
.pr-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pr-item:last-child { border-bottom: 0; padding-bottom: 0; }
.pr-item:first-child { padding-top: 0; }
.pr-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-soft); color: var(--gold);
}
.pr-icon .ico { width: 18px; height: 18px; }
.pr-main { flex: 1; min-width: 0; }
.pr-main b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-value { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.empty {
  text-align: center; padding: 40px 20px;
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  color: var(--muted);
}
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.empty-icon .ico { width: 28px; height: 28px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty .row { justify-content: center; margin-top: 16px; }

/* ---------- Графіки ---------- */
.chart { width: 100%; overflow: hidden; }
.chart svg { width: 100%; height: auto; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .dot.last { fill: var(--accent); }
.chart .dot:hover { r: 6; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .bar.current { opacity: 1; }
.chart .bar-value { fill: var(--text); font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-empty { padding: 36px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- Редактор тренування ---------- */
.wk-head { display: grid; gap: 12px; }
.wk-name {
  width: 100%; border: 0; background: transparent; outline: none;
  font-size: 22px; font-weight: 750; letter-spacing: -.02em; padding: 0;
}
.wk-name::placeholder { color: var(--muted); opacity: .6; }
.wk-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.timer-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.timer-pill .ico { width: 16px; height: 16px; }
.timer-pill.sm { height: 32px; padding: 0 10px; font-size: 14px; }
.wk-meta .input { width: auto; height: 34px; font-size: 14px; border-radius: 10px; }

.ex-card { padding: 14px 14px 12px; }
.ex-card-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.ex-card-head h3 { font-size: 16.5px; color: var(--accent); }
.ex-card-head .spacer { min-width: 0; }
.ex-tools { display: flex; gap: 2px; margin: -4px -4px 0 0; }
.prev-line { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }

.sets { display: grid; gap: 6px; }
.set-row {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr) 40px 28px;
  padding: 4px; border-radius: 12px; transition: background .15s;
}
.set-row.head { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: 0; padding-bottom: 0; }
.set-row.head > * { text-align: center; }
.set-row.done { background: var(--success-soft); }
.set-num {
  width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--muted);
}
.set-prev { text-align: center; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.set-input {
  width: 100%; height: 38px; text-align: center; padding: 0 4px;
  border: 1px solid transparent; border-radius: 10px; background: var(--surface-2);
  font-weight: 650; font-variant-numeric: tabular-nums; outline: none;
}
.set-input:focus { border-color: var(--accent); background: var(--surface); }
.set-input::placeholder { color: var(--muted); opacity: .6; font-weight: 500; }
.set-row.done .set-input { background: transparent; }
.set-check {
  width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.set-check:hover { border-color: var(--success); color: var(--success); }
.set-check.on { background: var(--success); border-color: var(--success); color: #fff; }
.set-check .ico { width: 18px; height: 18px; stroke-width: 2.6; }
.set-del { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: .6; }
.set-del:hover { opacity: 1; color: var(--danger); background: var(--danger-soft); }
.set-del .ico { width: 15px; height: 15px; }
.add-set { margin-top: 8px; }

@media (max-width: 420px) {
  .set-row { grid-template-columns: 26px minmax(0, .9fr) minmax(0, 1.1fr) minmax(0, 1fr) 38px 24px; gap: 5px; }
  .set-prev { font-size: 12px; }
}

.wk-footer { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

/* ---------- Історія ---------- */
.month-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 10px; }
.month-title:first-child { margin-top: 0; }
.wk-card-head { display: flex; align-items: flex-start; gap: 10px; }
.wk-card-head .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.wk-card-actions { display: flex; gap: 2px; margin: -6px -6px 0 auto; }
.wk-stats { display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0; font-size: 13px; color: var(--muted); }
.wk-stats b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; margin-right: 2px; }
.ex-summary { display: grid; gap: 6px; }
.ex-summary-row { display: flex; align-items: baseline; gap: 10px; font-size: 14px; }
.ex-summary-row .name { flex: 1; min-width: 0; }
.ex-summary-row .best { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pr-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
details.wk-details { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
details.wk-details summary { cursor: pointer; font-size: 13px; font-weight: 650; color: var(--accent); list-style: none; }
details.wk-details summary::-webkit-details-marker { display: none; }
details.wk-details summary::after { content: " ▾"; }
details.wk-details[open] summary::after { content: " ▴"; }
.detail-ex { margin-top: 12px; }
.detail-ex h4 { font-size: 14px; margin-bottom: 6px; }
.set-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.set-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 8px; background: var(--surface-2);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.set-chip i { font-style: normal; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.wk-notes { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; color: var(--muted); white-space: pre-wrap; }

/* ---------- Прогрес ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
@media (min-width: 600px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.kpi span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi b { font-size: 18px; font-variant-numeric: tabular-nums; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 8px 8px; }
.table td { padding: 9px 8px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; text-align: right; }
.table-wrap { overflow-x: auto; }

/* ---------- Вправи ---------- */
.ex-list { display: grid; gap: 0; }
.ex-group-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.ex-group-title:first-child { margin-top: 0; }
.ex-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; background: var(--surface); border: 1px solid var(--border);
  margin-top: -1px;
}
.ex-row:first-of-type { border-radius: 14px 14px 0 0; }
.ex-row:last-of-type { border-radius: 0 0 14px 14px; }
.ex-row:only-of-type { border-radius: 14px; }
.ex-row .name { flex: 1; min-width: 0; }
.ex-row .name b { font-weight: 600; display: block; }
.ex-row .name small { color: var(--muted); font-size: 12.5px; }
.ex-row.clickable { cursor: pointer; }
.ex-row.clickable:hover { background: var(--surface-2); }
.ex-group { display: flex; flex-direction: column; }

/* ---------- Модальне вікно ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 8, 5, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  animation: slide .2s ease-out;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; }
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; }
.modal-head h2 { flex: 1; }
.modal-tools { padding: 0 16px 10px; display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.modal-body { padding: 0 16px 16px; overflow-y: auto; }
.modal-text { padding: 0 16px; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 16px; }
.pick-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 10px; border: 0; border-radius: 10px; background: transparent;
  text-align: left; cursor: pointer;
}
.pick-row:hover { background: var(--surface-2); }
.pick-row .name { flex: 1; min-width: 0; }
.pick-row .name b { display: block; font-weight: 600; }
.pick-row .name small { color: var(--muted); font-size: 12.5px; }
.pick-row .ico { color: var(--accent); }
.pick-create { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 10px; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateY(24px); opacity: 0; } }

/* ---------- Таймер відпочинку ---------- */
.rest {
  position: fixed; z-index: 40; left: 12px; right: 12px;
  bottom: calc(var(--tab-h) + 32px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
  background: var(--text); color: var(--bg);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: slide .2s ease-out;
}
body.has-active-bar .rest { bottom: calc(var(--tab-h) + 104px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .rest, body.has-active-bar .rest { bottom: 24px; left: 272px; right: 24px; } }
.rest-bar { height: 4px; background: color-mix(in srgb, var(--bg) 20%, transparent); }
.rest-fill { height: 100%; width: 100%; background: var(--accent); transition: width .25s linear; }
.rest-body { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; }
.rest-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; opacity: .75; }
.rest-label .ico { width: 16px; height: 16px; }
.rest-time { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.rest-actions { display: flex; gap: 6px; margin-left: auto; }
.rest .btn { background: color-mix(in srgb, var(--bg) 14%, transparent); border-color: transparent; color: var(--bg); }
.rest .btn:hover { background: color-mix(in srgb, var(--bg) 24%, transparent); }
@media (max-width: 420px) { .rest-label { display: none; } }

/* ---------- Сповіщення ---------- */
.toast {
  position: fixed; z-index: 60; left: 50%; top: calc(env(safe-area-inset-top) + 12px);
  transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Налаштування ---------- */
.setting { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.setting:first-of-type { border-top: 0; padding-top: 4px; }
.setting .label { flex: 1; min-width: 180px; }
.setting .label b { display: block; font-weight: 600; }
.setting .label small { color: var(--muted); font-size: 13px; }
.setting .input { width: 110px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.set-input:focus-visible, .input:focus-visible, .wk-name:focus-visible { outline: none; }

/* ---------- Діалоги (замість системних confirm) ---------- */
.modal-backdrop.center { align-items: center; padding: 24px; }
.modal-backdrop.center .modal { max-width: 360px; border-radius: 22px; animation: pop .18s ease-out; }
.dialog { padding: 24px 20px 18px; text-align: center; }
.dialog-icon {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.dialog-icon.danger { background: var(--danger-soft); color: var(--danger); }
.dialog-icon .ico { width: 26px; height: 26px; }
.dialog h2 { margin-bottom: 6px; }
.dialog p { color: var(--muted); font-size: 14.5px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-solid:hover { filter: brightness(1.05); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }

/* Ручка шторки на телефоні */
@media (max-width: 639px) {
  .modal-backdrop:not(.center) .modal::before {
    content: ""; display: block; width: 38px; height: 5px; border-radius: 3px;
    background: var(--border); margin: 8px auto 0; flex: none;
  }
}

/* ---------- Встановлення застосунку ---------- */
.install-card { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.install-card img { border-radius: 14px; flex: none; box-shadow: var(--shadow); }
.install-card .text { flex: 1; min-width: 0; }
.install-card .text b { display: block; }
.install-card .text small { color: var(--muted); font-size: 13px; }
.ios-steps { display: grid; gap: 10px; text-align: left; margin-top: 14px; }
.ios-steps div { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.ios-steps b { width: 26px; height: 26px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 13px; }

/* Картки-кнопки у стилі застосунку */
.pick-row:active, .ex-row.clickable:active { transform: scale(.99); background: var(--surface-2); }

/* Поля 16px на телефоні — щоб iOS не збільшував масштаб при фокусі */
@media (max-width: 899px) {
  .input, .select, .textarea, .set-input { font-size: 16px; }
}

/* Режим встановленого застосунку */
@media (display-mode: standalone) {
  body { overscroll-behavior: none; }
}

/* ---------- Тренування: список вправ ---------- */
.wk-progress { display: grid; gap: 6px; }
.wk-progress-text { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wk-progress-text b { color: var(--text); }
.wk-progress-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.wk-progress-bar i { display: block; height: 100%; border-radius: inherit; background: var(--success); transition: width .3s ease; }

.wk-ex-list { display: grid; gap: 10px; }
.wk-ex-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px 14px 14px; cursor: pointer;
  transition: transform .1s, border-color .15s, background-color .15s;
}
.wk-ex-row:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.wk-ex-row:active { transform: scale(.985); }
.wk-ex-row .name { flex: 1; min-width: 0; display: grid; gap: 2px; }
.wk-ex-row .name b { font-weight: 650; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-ex-row .name small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.wk-ex-num {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); font-weight: 750; font-size: 15px;
}
.wk-ex-num .ico { width: 20px; height: 20px; stroke-width: 2.6; }
.wk-ex-row.started .wk-ex-num { background: var(--accent-soft); color: var(--accent); }
.wk-ex-row.complete .wk-ex-num { background: var(--success); color: #fff; }
.wk-ex-row.complete { background: color-mix(in srgb, var(--success-soft) 55%, var(--surface)); }
.wk-ex-count { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.wk-ex-row.complete .wk-ex-count { color: var(--success); }
.wk-ex-row .chev { color: var(--muted); width: 18px; height: 18px; }

/* ---------- Тренування: окремий екран вправи ---------- */
.ex-screen-head { display: grid; gap: 6px; padding-top: 2px; }
.ex-screen-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ex-screen-meta span { flex: 1; }
.ex-screen-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -.025em; }
.ex-dots { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.ex-dots a { width: 24px; height: 6px; border-radius: 999px; background: var(--border); transition: background-color .15s, width .15s; }
.ex-dots a.complete { background: var(--success); }
.ex-dots a.current { width: 36px; background: var(--accent); }
.ex-screen-head + .ex-card .set-row { padding-top: 6px; padding-bottom: 6px; }
.ex-screen-head + .ex-card .set-input, .ex-screen-head + .ex-card .set-check { height: 44px; }
.ex-screen-head + .ex-card .set-check { width: 44px; }
.ex-screen-head + .ex-card .set-row { grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr) 44px 28px; }
@media (max-width: 420px) {
  .ex-screen-head + .ex-card .set-row { grid-template-columns: 26px minmax(0, .9fr) minmax(0, 1.1fr) minmax(0, 1fr) 44px 24px; }
}

.ex-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.ex-nav .btn { height: auto; min-height: 58px; padding: 8px 12px; justify-content: flex-start; white-space: normal; }
.ex-nav .btn.next { justify-content: flex-end; text-align: right; }
.ex-nav-label { display: grid; min-width: 0; line-height: 1.25; }
.ex-nav-label small { font-size: 11.5px; font-weight: 600; opacity: .7; }
.ex-nav-label { overflow: hidden; }

/* ---------- Групи м'язів ---------- */
.muscle-total { display: grid; gap: 8px; margin-bottom: 18px; }
.muscle-total-text { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.muscle-total-text b { font-size: 20px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.muscle-list { display: grid; gap: 14px 28px; }
@media (min-width: 640px) { .muscle-list { grid-template-columns: 1fr 1fr; } }
.muscle-row { display: grid; gap: 6px; }
.muscle-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.muscle-top b { font-weight: 650; }
.muscle-num { display: inline-flex; align-items: center; gap: 4px; font-weight: 750; font-variant-numeric: tabular-nums; }
.muscle-num small { color: var(--muted); font-weight: 600; font-size: 13px; }
.muscle-num .ico { width: 16px; height: 16px; stroke-width: 2.6; color: var(--success); }
.muscle-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.muscle-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.muscle-bar.total { height: 12px; }
.muscle-bar.total i { background: linear-gradient(90deg, var(--accent), #ffa94d); }
.muscle-row.low .muscle-bar i { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.muscle-row.full .muscle-bar i { background: var(--success); }
.muscle-row.other .muscle-bar i { background: var(--muted); opacity: .5; }
.muscle-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.mini-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.mini-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.mini-bar.full i { background: var(--success); }

/* ---------- Профіль ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #ff8a4c, var(--accent));
  color: #fff; font-weight: 750; font-size: 15px; letter-spacing: .02em;
}
.avatar .ico { width: 55%; height: 55%; }
.avatar.xs { width: 26px; height: 26px; font-size: 11px; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.lg { width: 68px; height: 68px; font-size: 24px; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.avatar-link { display: inline-flex; padding: 2px; border-radius: 50%; }
.avatar-link:active { transform: scale(.94); }
.side-profile { gap: 10px; }
.side-profile-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head-text { min-width: 0; }
.profile-head-text h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-head-text p { margin-top: 2px; font-size: 14px; }
.kpi small { display: block; font-size: 11.5px; font-weight: 650; margin-top: 1px; }

.form-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: span 2; }
}
.segmented.days { display: grid; grid-template-columns: repeat(7, 1fr); }
.segmented.days button { padding: 8px 0; font-size: 15px; }
.group-targets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
@media (min-width: 640px) { .group-targets { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.group-target {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--surface-2);
}
.group-target span { flex: 1; font-weight: 600; font-size: 14px; }
.group-target .input { width: 58px; height: 36px; text-align: center; font-weight: 700; padding: 0 4px; }
.segmented.growth { display: grid; grid-template-columns: repeat(4, 1fr); }
.segmented.growth button { padding: 8px 4px; }
.muscle-total p { margin-top: 2px; }

/* ---------- Бібліотека вправ: пошук і фільтри ---------- */
.browser-tools { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); margin-bottom: 16px; }
.modal-tools.browser-tools { margin-bottom: 0; }
.search-box {
  position: relative; display: flex; align-items: center;
  height: 46px; padding: 0 6px 0 14px; gap: 10px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  transition: border-color .15s, box-shadow .15s;
}
.modal .search-box { background: var(--surface-2); border-color: transparent; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box > .ico { color: var(--muted); width: 19px; height: 19px; }
.search-input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; font-size: 16px; }
.search-input::placeholder { color: var(--muted); opacity: .8; }
.search-input::-webkit-search-cancel-button { display: none; }

.filter-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pill-select {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 30px 0 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 650; cursor: pointer;
  width: 220px; max-width: 65%;
}
.pill-select > .ico { width: 16px; height: 16px; color: var(--muted); }
.pill-select .caret { position: absolute; right: 10px; width: 14px; height: 14px; color: var(--muted); pointer-events: none; }
.pill-select select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; outline: none;
  font: inherit; color: inherit; cursor: pointer; min-width: 0; text-overflow: ellipsis;
  position: absolute; inset: 0; padding: 0 30px 0 14px; width: 100%;
}
.pill-select:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }

.browser-list { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.ex-section { min-width: 0; }
.create-link { margin-top: 2px; color: var(--muted); font-weight: 600; }
.create-link:hover { color: var(--accent); }
.ex-section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 8px; }
.ex-section-head h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ex-section-head span { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; }
.ex-section-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
}
.modal .ex-section-list { border: 0; border-radius: 0; background: transparent; }
.ex-section-list .pick-row { border-radius: 0; border-top: 1px solid var(--border); padding: 10px 12px; }
.ex-section-list .pick-row:first-child { border-top: 0; }
.modal .ex-section-list .pick-row { border-radius: 12px; border-top: 0; padding: 9px 8px; }
.pick-row.static { cursor: default; }
.pick-row.static:hover, .pick-row.static:active { background: transparent; transform: none; }
.pick-row .name small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-row .name b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-ico {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.ex-ico .ico { width: 19px; height: 19px; }
.ex-ico.machine { background: var(--surface-2); color: var(--text); }
.pick-row .ico.add { color: var(--accent); width: 20px; height: 20px; }
.pick-row .ico.chev { color: var(--muted); width: 18px; height: 18px; }
.ex-used { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.more-btn { margin-top: 6px; color: var(--accent); }
.more-btn .ico { width: 16px; height: 16px; }
.list-empty { text-align: center; color: var(--muted); padding: 28px 12px 8px; }
.list-empty .ico { width: 28px; height: 28px; margin: 0 auto 8px; opacity: .6; }
.ex-screen-model { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--muted); margin-top: -2px; }
.ex-screen-model .ico { width: 16px; height: 16px; }

/* =========================================================
   Дизайн 2.0: глибина, акценти, анімації
   ========================================================= */
:root { --spring: cubic-bezier(.3, 1.45, .5, 1); --ease-out: cubic-bezier(.2, .8, .2, 1); }

/* Блок привітання */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 24px 22px; border-radius: 24px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 196, 150, .55) 0%, transparent 55%),
    linear-gradient(140deg, #ff7a33 0%, #e5540f 45%, #a3330a 100%);
  box-shadow: 0 12px 30px -10px rgba(229, 84, 15, .55);
}
.hero::before, .hero::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%;
  background: rgba(255, 255, 255, .09);
}
.hero::before { width: 240px; height: 240px; right: -70px; bottom: -130px; animation: float 9s ease-in-out infinite; }
.hero::after { width: 120px; height: 120px; left: 38%; top: -70px; animation: float 11s ease-in-out -3s infinite reverse; }
@keyframes float { 50% { transform: translate(-14px, 10px) scale(1.06); } }
.hero-main { display: grid; gap: 4px; justify-items: start; min-width: 0; }
.hero-date { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .8); }
.hero h1 { font-size: 27px; font-weight: 800; letter-spacing: -.03em; }
.hero p { color: rgba(255, 255, 255, .88); margin-top: 0; opacity: 1; }
.hero .btn { margin-top: 12px; box-shadow: 0 6px 16px rgba(80, 20, 0, .25); }
.hero .btn:hover { transform: translateY(-1px); }
.hero-ring { position: relative; width: 104px; height: 104px; flex: none; }
.hero-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hero-ring circle { fill: none; stroke-width: 9; }
.ring-track { stroke: rgba(255, 255, 255, .22); }
.ring-progress { stroke: #fff; stroke-linecap: round; stroke-dasharray: 100; }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #fff; line-height: 1.1; }
.ring-text b { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ring-text small { font-size: 10.5px; font-weight: 600; opacity: .85; }
@media (max-width: 420px) {
  .hero { padding: 20px 18px; gap: 12px; }
  .hero h1 { font-size: 23px; }
  .hero-ring { width: 88px; height: 88px; }
  .ring-text b { font-size: 20px; }
}

/* Картки статистики */
.stat-label .ico {
  width: 28px; height: 28px; padding: 6px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent);
}
.stat-value { font-weight: 800; letter-spacing: -.03em; }

/* Кнопки */
.btn { transition: background-color .15s, border-color .15s, transform .15s var(--spring), box-shadow .15s, filter .15s; }
.btn.primary,
.btn.primary:hover {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 85%, #fff) 0%, var(--accent) 100%);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn.primary:hover { filter: brightness(1.06); }

/* Інтерактивні картки: легке підняття */
@media (hover: hover) {
  .wk-card { transition: transform .2s var(--ease-out), box-shadow .2s; }
  .wk-ex-row:hover, .card.pick-row:hover, .wk-card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -12px rgba(20, 16, 10, .25); }
}

/* Нижня панель: «пігулка» під активною вкладкою, як у нативних застосунках */
.tabbar a > :not(.nav-dot) { position: relative; z-index: 1; }
.tabbar .nav-dot { z-index: 2; }
.tabbar a:not(.tab-main)::before {
  content: ""; position: absolute; top: 8px; left: 50%; width: 54px; height: 30px; margin-left: -27px;
  border-radius: 15px; background: var(--accent-soft);
  opacity: 0; transform: scale(.4); transition: opacity .2s, transform .3s var(--spring);
}
.tabbar a.active:not(.tab-main)::before { opacity: 1; transform: scale(1); }
.tabbar a.active:not(.tab-main) .ico { animation: tabPop .45s var(--spring); }
.tab-main.active .tab-main-btn { animation: tabPop .45s var(--spring); }
@keyframes tabPop { 0% { transform: scale(.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* Модальні вікна та сповіщення */
.modal-backdrop { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal { animation: sheetIn .38s var(--ease-out); }
.modal-backdrop.center .modal { animation: pop .32s var(--spring); }
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }
.toast { transition: opacity .25s, transform .35s var(--spring); border-radius: 14px; padding: 11px 18px; }

/* Таймер відпочинку: пульсація в останні секунди */
.rest-fill { background: linear-gradient(90deg, var(--accent), #ffb347); }
.rest.ending .rest-time { color: #ffb347; animation: tick 1s ease-in-out infinite; }
@keyframes tick { 50% { transform: scale(1.12); } }

/* Виконаний підхід */
.set-row.pop { animation: rowFlash .7s ease-out; }
.set-row.pop .set-check { animation: checkPop .5s var(--spring); }
@keyframes checkPop { 0% { transform: scale(.55); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes rowFlash { from { background: color-mix(in srgb, var(--success) 40%, transparent); } }

/* Підсумок тренування */
.summary h2 { font-size: 22px; font-weight: 800; }
.summary-badge {
  width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #43d17f, #1c8f4d); color: #fff;
  box-shadow: 0 10px 24px -8px rgba(28, 143, 77, .6);
  animation: badgeIn .6s var(--spring) .1s both;
}
.summary-badge.gold { background: linear-gradient(140deg, #ffd43b, #e8a200); box-shadow: 0 10px 24px -8px rgba(232, 162, 0, .6); }
.summary-badge .ico { width: 36px; height: 36px; stroke-width: 2.4; }
@keyframes badgeIn { from { transform: scale(0) rotate(-30deg); opacity: 0; } }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.summary-grid > div { padding: 12px 8px; border-radius: 14px; background: var(--surface-2); display: grid; }
.summary-grid b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.summary-grid > div > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.summary-prs { display: grid; gap: 6px; margin-top: 12px; text-align: left; }
.summary-prs > div { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--gold-soft); color: var(--gold); font-size: 13.5px; }
.summary-prs span { flex: 1; min-width: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-prs .ico { width: 16px; height: 16px; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* ---------- Поява екрана: плавне «виринання» блоків по черзі ---------- */
@media (prefers-reduced-motion: no-preference) {
  .view.enter > *,
  .view.enter .stack > *,
  .view.enter .stats > *,
  .view.enter .grid-2 > *,
  .view.enter .wk-ex-list > *,
  .view.enter .kpis > *,
  .view.enter .ex-section { animation: rise .55s var(--ease-out) both; }
  .view.enter > :nth-child(2), .view.enter .stack > :nth-child(2), .view.enter .stats > :nth-child(2), .view.enter .grid-2 > :nth-child(2), .view.enter .wk-ex-list > :nth-child(2), .view.enter .kpis > :nth-child(2), .view.enter .ex-section:nth-child(2) { animation-delay: .05s; }
  .view.enter > :nth-child(3), .view.enter .stack > :nth-child(3), .view.enter .stats > :nth-child(3), .view.enter .wk-ex-list > :nth-child(3), .view.enter .kpis > :nth-child(3), .view.enter .ex-section:nth-child(3) { animation-delay: .1s; }
  .view.enter > :nth-child(4), .view.enter .stack > :nth-child(4), .view.enter .stats > :nth-child(4), .view.enter .wk-ex-list > :nth-child(4), .view.enter .kpis > :nth-child(4), .view.enter .ex-section:nth-child(4) { animation-delay: .15s; }
  .view.enter > :nth-child(5), .view.enter .stack > :nth-child(5), .view.enter .wk-ex-list > :nth-child(5), .view.enter .ex-section:nth-child(5) { animation-delay: .2s; }
  .view.enter > :nth-child(6), .view.enter .stack > :nth-child(6), .view.enter .wk-ex-list > :nth-child(6), .view.enter .ex-section:nth-child(6) { animation-delay: .25s; }
  .view.enter > :nth-child(n+7), .view.enter .stack > :nth-child(n+7), .view.enter .wk-ex-list > :nth-child(n+7), .view.enter .ex-section:nth-child(n+7) { animation-delay: .3s; }
  .view.enter .stack .stack > * { animation: none; }

  .view.enter .muscle-bar i, .view.enter .mini-bar i, .view.enter .wk-progress-bar i {
    transform-origin: left; animation: fillX 1s var(--ease-out) .2s both;
  }
  .view.enter .chart .line { stroke-dasharray: 1; animation: draw 1.2s var(--ease-out) .15s both; }
  .view.enter .chart .area { animation: fadeIn .9s ease .5s both; }
  .view.enter .chart .dot { transform-box: fill-box; transform-origin: center; animation: dotIn .35s var(--spring) both; animation-delay: calc(.35s + var(--i) * 30ms); }
  .view.enter .chart .bar { transform-box: fill-box; transform-origin: bottom; animation: growY .7s var(--ease-out) both; animation-delay: calc(.1s + var(--i) * 50ms); }
  .view.enter .chart .bar-value { animation: fadeIn .4s ease .7s both; }
  .view.enter .ring-progress { animation: ringIn 1.3s var(--ease-out) .25s both; }
  .view.enter .ex-dots a { animation: dotIn .3s var(--spring) both; }
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes fillX { from { transform: scaleX(0); } }
@keyframes growY { from { transform: scaleY(0); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes dotIn { from { transform: scale(0); opacity: 0; } }
@keyframes ringIn { from { stroke-dashoffset: 100; } }

/* Для тих, хто вимкнув анімації в системі */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* ---------- Виправлення верстки ---------- */
.chart-head.nowrap, .row.nowrap { flex-wrap: nowrap; }
.chart-head .grow { flex: 1; min-width: 0; }
.segmented.metrics { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
@media (min-width: 640px) { .segmented.metrics { display: inline-grid; width: auto; } }
.segmented.metrics button { padding: 7px 10px; }
.table.nowrap td, .table.nowrap th { white-space: nowrap; }

/* ---------- Вхід і акаунт ---------- */
.auth { min-height: calc(100vh - 180px); display: grid; place-items: center; padding: 8px 0 24px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px 22px 18px; text-align: center; display: grid; gap: 14px; }
.auth-logo { margin: 0 auto; border-radius: 18px; box-shadow: 0 10px 24px -10px rgba(229, 84, 15, .6); }
.auth-card h1 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-top: -4px; }
.auth-card > p { margin-top: -8px; font-size: 14.5px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.auth-tabs button { padding: 9px 0; font-size: 14px; }
.auth-form { display: grid; gap: 12px; text-align: left; }
.pass-wrap { position: relative; display: block; }
.pass-wrap .input { padding-right: 46px; }
.pass-toggle { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.pass-toggle:active { transform: translateY(-50%) scale(.92); }
.auth-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13.5px; font-weight: 600; text-align: left; }
.auth-note { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--gold-soft); color: var(--gold); font-size: 13px; font-weight: 600; }
.auth-note .ico { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.auth-hint { display: flex; align-items: center; justify-content: center; gap: 6px; margin: -2px 0 -6px; }
.auth-hint .ico { width: 16px; height: 16px; }

.account-card { display: grid; gap: 12px; }
.account-row { display: flex; align-items: center; gap: 12px; }
.account-row .name { flex: 1; min-width: 0; display: grid; }
.account-row .name b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-row .name small { color: var(--muted); font-size: 12.5px; }
.account-actions { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px; margin: 0 -4px -4px; }
.cloud-badge {
  position: relative; width: 42px; height: 42px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.cloud-badge .ico { width: 22px; height: 22px; }
.cloud-badge::after {
  content: ""; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--muted); display: none;
}
.cloud-badge[data-state]::after { display: block; }
.cloud-badge[data-state="ok"]::after, .cloud-badge[data-state="idle"]::after { background: var(--success); }
.cloud-badge[data-state="offline"]::after { background: var(--gold); }
.cloud-badge[data-state="syncing"]::after { background: var(--accent); animation: tick 1s ease-in-out infinite; }
.account-card.guest .cloud-badge { background: var(--surface-2); color: var(--muted); }
.btn.disabled { opacity: .5; pointer-events: none; }
