/* ============================================================
   GYM Track — Apple Liquid Glass
   Дизайн-система в дусі apple.com / iOS 26:
   · рідке скло: blur + saturate + specular-підсвітки
   · градієнтні hairline-краї (mask-composite)
   · капсульні кнопки (radius 980px) — Apple Blue
   · сегмент-контроли, activity ring, ambient-шпалери
   ============================================================ */

:root {
  /* Палітра Apple (dark) */
  --bg: #05060a;
  --bg-soft: rgba(255, 255, 255, 0.055);
  --card: rgba(255, 255, 255, 0.06);
  --card-hover: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --text-dim: rgba(245, 245, 247, 0.62);
  --text-faint: rgba(245, 245, 247, 0.42);
  --accent: #0a84ff;          /* systemBlue · dark */
  --accent-hi: #409cff;
  --accent-dark: #0060df;
  --accent-soft: rgba(10, 132, 255, 0.15);
  --ok: #30d158;              /* systemGreen */
  --danger: #ff453a;          /* systemRed */
  --warn: #ff9f0a;            /* systemOrange */
  --over: #bf5af2;            /* systemPurple */
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.50);
  --radius: 26px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", "Inter", "Segoe UI", system-ui, sans-serif;

  /* Рідке скло */
  --glass-blur: blur(30px) saturate(1.9);
  --glass-sheen: linear-gradient(
    160deg,
    rgba(255, 255, 255, 0.115),
    rgba(255, 255, 255, 0.035) 38%,
    rgba(255, 255, 255, 0.02) 62%,
    rgba(255, 255, 255, 0.075)
  );
  --hairline: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.50),
    rgba(255, 255, 255, 0.10) 30%,
    rgba(255, 255, 255, 0.04) 55%,
    rgba(255, 255, 255, 0.22)
  );
  --specular:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  --focus-ring: 0 0 0 4px color-mix(in srgb, var(--accent) 32%, transparent);
  color-scheme: dark;
}

body[data-theme="light"] {
  /* Палітра apple.com (light) */
  --bg: #f5f5f7;
  --bg-soft: rgba(29, 29, 31, 0.045);
  --card: rgba(255, 255, 255, 0.62);
  --card-hover: rgba(255, 255, 255, 0.85);
  --border: rgba(29, 29, 31, 0.08);
  --border-strong: rgba(29, 29, 31, 0.14);
  --text: #1d1d1f;
  --text-dim: rgba(29, 29, 31, 0.62);
  --text-faint: rgba(29, 29, 31, 0.45);
  --accent: #0071e3;          /* apple.com blue */
  --accent-hi: #0077ed;
  --accent-dark: #0051ba;
  --accent-soft: rgba(0, 113, 227, 0.11);
  --ok: #1d9a45;
  --danger: #d70015;
  --warn: #c93400;
  --over: #8944ab;
  --shadow: 0 22px 54px rgba(29, 29, 31, 0.12);
  --glass-sheen: linear-gradient(
    160deg,
    rgba(255, 255, 255, 0.85),
    rgba(255, 255, 255, 0.40) 38%,
    rgba(255, 255, 255, 0.30) 62%,
    rgba(255, 255, 255, 0.62)
  );
  --hairline: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.95),
    rgba(29, 29, 31, 0.10) 30%,
    rgba(29, 29, 31, 0.05) 55%,
    rgba(255, 255, 255, 0.70)
  );
  --specular:
    inset 0 1px 0 rgba(255, 255, 255, 0.90),
    inset 0 -1px 0 rgba(255, 255, 255, 0.45);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.014em;
  overflow-x: hidden;
}

/* ---------- Ambient-шпалери: кольорові плями під склом ---------- */
body::before {
  content: "";
  position: fixed;
  inset: -22%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(42% 34% at 18% 12%, rgba(10, 132, 255, 0.30), transparent 68%),
    radial-gradient(38% 32% at 84% 8%,  rgba(191, 90, 242, 0.20), transparent 66%),
    radial-gradient(44% 36% at 88% 78%, rgba(255, 55, 95, 0.13), transparent 66%),
    radial-gradient(46% 38% at 8% 84%,  rgba(100, 210, 255, 0.14), transparent 66%),
    radial-gradient(30% 26% at 52% 48%, rgba(48, 209, 88, 0.08), transparent 66%);
  animation: ambientDrift 46s ease-in-out infinite alternate;
  will-change: transform;
}
body[data-theme="light"]::before {
  background:
    radial-gradient(42% 34% at 18% 12%, rgba(0, 113, 227, 0.16), transparent 68%),
    radial-gradient(38% 32% at 84% 8%,  rgba(137, 68, 171, 0.13), transparent 66%),
    radial-gradient(44% 36% at 88% 78%, rgba(255, 149, 0, 0.11), transparent 66%),
    radial-gradient(46% 38% at 8% 84%,  rgba(100, 210, 255, 0.15), transparent 66%),
    radial-gradient(30% 26% at 52% 48%, rgba(52, 199, 89, 0.09), transparent 66%);
}
@keyframes ambientDrift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to   { transform: translate3d(1.5%, 1.5%, 0) scale(1.07); }
}

.hidden { display: none !important; }

::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(245, 245, 247, 0.18);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
body[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(29, 29, 31, 0.24);
  background-clip: content-box;
}

:focus-visible { outline: none; box-shadow: var(--focus-ring); }
input:focus-visible, select:focus-visible { box-shadow: none; }

/* ============================================================
   РІДКЕ СКЛО — спільна основа поверхонь
   ============================================================ */
.card,
.exercise-card,
.history-item,
.stat-card,
.auth-card,
.pr-card,
#rest-timer,
.toast {
  position: relative;
  background: var(--glass-sheen);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow:
    var(--shadow),
    var(--specular);
}

/* Градієнтний hairline-край (лінзування) */
.card::before,
.exercise-card::before,
.history-item::before,
.stat-card::before,
.auth-card::before,
.pr-card::before,
#rest-timer::before,
.toast::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--hairline);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* Верхній лінзовий відблиск */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 55% at 50% -18%, rgba(255, 255, 255, 0.10), transparent 62%);
  pointer-events: none;
}
body[data-theme="light"] .card::after {
  background: radial-gradient(120% 55% at 50% -18%, rgba(255, 255, 255, 0.55), transparent 62%);
}

/* Рухомий sheen-блик по склу (екран входу і святкування рекорду) */
.auth-card::after,
.pr-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(120% 55% at 50% -18%, rgba(255, 255, 255, 0.10), transparent 62%),
    linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.09) 50%, transparent 58%);
  background-size: auto, 260% 100%;
  background-position: 0 0, -140% 0;
  background-repeat: no-repeat;
  animation: sheenSweep 7s ease-in-out infinite;
}
body[data-theme="light"] .auth-card::after,
body[data-theme="light"] .pr-card::after {
  background:
    radial-gradient(120% 55% at 50% -18%, rgba(255, 255, 255, 0.55), transparent 62%),
    linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.65) 50%, transparent 58%);
  background-size: auto, 260% 100%;
  background-position: 0 0, -140% 0;
  background-repeat: no-repeat;
}
@keyframes sheenSweep {
  0% { background-position: 0 0, -140% 0; }
  60%, 100% { background-position: 0 0, 140% 0; }
}
.card > *,
.auth-card > *,
.pr-card > * { position: relative; z-index: 1; }

/* ============================================================
   КНОПКИ — капсули в дусі apple.com
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: 980px;
  background: var(--bg-soft);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 590;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    transform 0.18s cubic-bezier(0.25, 1, 0.35, 1),
    background 0.18s,
    border-color 0.18s,
    box-shadow 0.18s,
    opacity 0.15s;
  user-select: none;
}
.btn:hover { background: var(--card-hover); transform: translateY(-1px); }
.btn:active { transform: scale(0.965); }
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent) 55%, var(--accent-dark));
  border-color: color-mix(in srgb, var(--accent-hi) 55%, rgba(255, 255, 255, 0.35));
  color: #ffffff;
  font-weight: 600;
  box-shadow:
    0 10px 28px color-mix(in srgb, var(--accent) 38%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-hi) 55%, var(--accent));
  box-shadow:
    0 14px 34px color-mix(in srgb, var(--accent) 46%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -1px 0 rgba(0, 0, 0, 0.10);
}

.btn-ghost { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--card-hover); }

.btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 36%, transparent);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
}
.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border-color: color-mix(in srgb, var(--danger) 58%, transparent);
}
.btn-sm { padding: 7px 15px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 999px;
  transition: 0.15s;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.icon-btn:focus-visible { box-shadow: var(--focus-ring); }

/* ============================================================
   ЕКРАН ВХОДУ — Apple-герой
   ============================================================ */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
#auth-screen::before,
#auth-screen::after {
  content: "";
  position: absolute;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  filter: blur(110px);
  z-index: 0;
  pointer-events: none;
  animation: blobFloat 14s ease-in-out infinite alternate;
}
#auth-screen::before {
  background: radial-gradient(circle, rgba(10, 132, 255, 0.34), transparent 70%);
  top: -220px; left: -180px;
}
#auth-screen::after {
  background: radial-gradient(circle, rgba(191, 90, 242, 0.26), transparent 70%);
  bottom: -220px; right: -180px;
  animation-delay: -7s;
}
body[data-theme="light"] #auth-screen::before { background: radial-gradient(circle, rgba(0, 113, 227, 0.20), transparent 70%); }
body[data-theme="light"] #auth-screen::after  { background: radial-gradient(circle, rgba(191, 90, 242, 0.16), transparent 70%); }
@keyframes blobFloat {
  from { transform: translate3d(0, -18px, 0) scale(1); }
  to   { transform: translate3d(26px, 18px, 0) scale(1.08); }
}

.auth-card {
  width: 100%;
  max-width: 430px;
  border-radius: 32px;
  padding: 38px 32px;
  z-index: 1;
  animation: cardIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
/* Каскадна поява блоків картки входу */
.auth-card > * { animation: fadeSoft 0.55s backwards; }
.auth-card > *:nth-child(1) { animation-delay: 0.10s; }
.auth-card > *:nth-child(2) { animation-delay: 0.18s; }
.auth-card > *:nth-child(3) { animation-delay: 0.26s; }
.auth-card > *:nth-child(4) { animation-delay: 0.34s; }
.auth-card > *:nth-child(n+5) { animation-delay: 0.40s; }

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.035em;
  background: linear-gradient(92deg, var(--text) 8%, var(--accent) 52%, var(--over) 96%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.auth-logo-icon {
  width: 58px;
  height: 58px;
  color: var(--accent);
  margin-bottom: 12px;
  animation: logoFloat 3.2s ease-in-out infinite;
  filter: drop-shadow(0 14px 30px color-mix(in srgb, var(--accent) 45%, transparent));
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-7px) rotate(3deg); }
}
.auth-sub { color: var(--text-dim); font-size: 15px; margin-top: 4px; font-weight: 500; }

/* Сегмент-контрол (iOS) */
.auth-tabs,
.seg {
  display: flex;
  gap: 3px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.auth-tabs { margin-bottom: 24px; }
.auth-tab {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 590;
  font-size: 14px;
  cursor: pointer;
  transition: 0.2s;
}
.auth-tab:focus-visible { box-shadow: var(--focus-ring); }
.auth-tab.active {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text);
  box-shadow:
    0 3px 12px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  animation: pillPop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
body[data-theme="light"] .auth-tab.active,
body[data-theme="light"] .seg button.active {
  background: #ffffff;
  box-shadow: 0 3px 12px rgba(29, 29, 31, 0.14), inset 0 1px 0 rgba(255, 255, 255, 1);
}

/* ============================================================
   ФОРМИ
   ============================================================ */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12.5px; color: var(--text-dim); font-weight: 590; }

input, select {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: -0.01em;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
body[data-theme="light"] input,
body[data-theme="light"] select {
  background: rgba(255, 255, 255, 0.66);
  border-color: rgba(29, 29, 31, 0.10);
}
input:focus, select:focus {
  border-color: color-mix(in srgb, var(--accent) 62%, transparent);
  box-shadow: var(--focus-ring);
  background: color-mix(in srgb, var(--bg-soft) 55%, transparent);
}
input::placeholder { color: var(--text-faint); font-weight: 400; }
input:disabled { opacity: 0.5; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

select {
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path d="M1 1.5L6 6.5L11 1.5" stroke="rgba(245,245,247,0.5)" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>');
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}
body[data-theme="light"] select {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path d="M1 1.5L6 6.5L11 1.5" stroke="rgba(29,29,31,0.5)" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>');
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  background: color-mix(in srgb, var(--danger) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 36%, transparent);
  padding: 10px 14px;
  border-radius: 14px;
}
.auth-note { margin-top: 22px; text-align: center; font-size: 12px; color: var(--text-faint); }

/* ============================================================
   ШАПКА — глобальна навігація apple.com
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  backdrop-filter: blur(22px) saturate(1.9);
  -webkit-backdrop-filter: blur(22px) saturate(1.9);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.022em;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.brand .brand-mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
  filter: drop-shadow(0 4px 12px color-mix(in srgb, var(--accent) 50%, transparent));
}

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 980px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 590;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s, color 0.16s, border-color 0.16s, box-shadow 0.16s;
}
.nav-btn:focus-visible { box-shadow: var(--focus-ring); }
.nav-btn .n-ico { display: flex; align-items: center; }
.nav-btn .n-ico svg { width: 17px; height: 17px; }
.nav-btn:hover { color: var(--text); background: var(--bg-soft); }
.nav-btn.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 4px 14px rgba(0, 0, 0, 0.22);
  animation: pillPop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
@keyframes pillPop { from { transform: scale(0.82); opacity: 0.4; } }
.nav-btn.active .n-ico { color: var(--accent); }
body[data-theme="light"] .nav-btn.active {
  background: #ffffff;
  border-color: rgba(29, 29, 31, 0.06);
  box-shadow: 0 4px 14px rgba(29, 29, 31, 0.12);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 590;
  color: var(--text-dim);
  padding: 5px 14px 5px 6px;
  border-radius: 980px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  cursor: pointer;
  transition: 0.16s;
  white-space: nowrap;
}
.user-chip:focus-visible { box-shadow: var(--focus-ring); }
.user-chip:hover {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 42%, transparent);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
}
.user-chip .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
body[data-theme="light"] .user-chip .avatar {
  background: linear-gradient(160deg, rgba(10, 132, 255, 0.16), rgba(191, 90, 242, 0.12));
  border-color: rgba(29, 29, 31, 0.10);
}

/* ============================================================
   КОНТЕЙНЕР / ТИПОГРАФІКА
   ============================================================ */
.container { max-width: 1060px; margin: 0 auto; padding: 30px 18px 66px; position: relative; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeSoft { from { opacity: 0; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(0.985); } to { opacity: 1; transform: none; } }

/* Каскадна поява блоків при вході в розділ */
.view > * { animation: cardIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.view > *:nth-child(1) { animation-delay: 0.02s; }
.view > *:nth-child(2) { animation-delay: 0.07s; }
.view > *:nth-child(3) { animation-delay: 0.12s; }
.view > *:nth-child(4) { animation-delay: 0.17s; }
.view > *:nth-child(5) { animation-delay: 0.22s; }
.view > *:nth-child(6) { animation-delay: 0.27s; }
.view > *:nth-child(7) { animation-delay: 0.32s; }
.view > *:nth-child(8) { animation-delay: 0.37s; }
.view > *:nth-child(n+9) { animation-delay: 0.42s; }

/* Картки-показники статистики з'являються хвилею */
.grid-cards > * { animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.grid-cards > *:nth-child(1) { animation-delay: 0.14s; }
.grid-cards > *:nth-child(2) { animation-delay: 0.19s; }
.grid-cards > *:nth-child(3) { animation-delay: 0.24s; }
.grid-cards > *:nth-child(4) { animation-delay: 0.29s; }

.footer { text-align: center; color: var(--text-faint); font-size: 12px; padding: 26px; }

h2.view-title {
  font-size: clamp(28px, 4.4vw, 38px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin-bottom: 4px;
}
p.view-sub { color: var(--text-dim); font-size: 15px; margin-bottom: 24px; }

/* ============================================================
   КАРТКИ
   ============================================================ */
.card {
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.card h3 {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.018em;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.card h3 .hint { font-size: 12px; color: var(--text-faint); font-weight: 500; letter-spacing: -0.005em; }

/* Герой-картка: activity ring */
.hero-card {
  display: flex;
  align-items: center;
  gap: 22px;
}
/* Світіння вішають на сам <svg>, а не на .ring-fill: фільтр на внутрішніх
   елементах SVG обрізається прямокутними межами елемента, і світіння
   «заливає» бокс — під кільцем з'являється помітний світлий квадрат */
.hero-card .ring { width: 134px; height: 134px; flex-shrink: 0; animation: ringGlow 3.6s ease-in-out infinite; }
.ring-track { fill: none; stroke: rgba(255, 255, 255, 0.09); stroke-width: 11; }
body[data-theme="light"] .ring-track { stroke: rgba(29, 29, 31, 0.08); }
.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 11;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Дихання світла на кільці прогресу */
@keyframes ringGlow {
  0%, 100% { filter: drop-shadow(0 0 12px color-mix(in srgb, var(--accent) 55%, transparent)); }
  50% { filter: drop-shadow(0 0 20px color-mix(in srgb, var(--accent) 78%, transparent)); }
}
.ring-num {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  fill: var(--text);
  font-family: var(--font);
}
.ring-lbl { font-size: 11px; fill: var(--text-faint); font-family: var(--font); letter-spacing: 0.02em; }
.hero-stats { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 15px 12px; min-width: 0; }
.hs-num {
  display: block;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.022em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hs-lbl { font-size: 11.5px; color: var(--text-dim); font-weight: 500; }

.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   ПРОГРЕС-БАРИ
   ============================================================ */
.prog {
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.28), inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}
body[data-theme="light"] .prog {
  background: rgba(29, 29, 31, 0.07);
  box-shadow: inset 0 1px 3px rgba(29, 29, 31, 0.10);
}
.prog-fill {
  position: relative;
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  animation: growW 0.7s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
@keyframes growW { from { width: 0; } }
.prog-fill::after {
  content: "";
  position: absolute;
  top: 0; left: 8%; right: 8%; height: 46%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.02));
}
.prog.over .prog-fill { background: linear-gradient(90deg, #8944ab, #bf5af2) !important; }

.muscle-row { margin-bottom: 16px; }
.muscle-row:last-child { margin-bottom: 0; }
.muscle-row .row-top {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
  font-size: 13.5px;
}
.muscle-row .row-top .dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px color-mix(in srgb, currentColor 60%, transparent);
}
.muscle-row .row-top .m-name { font-weight: 650; letter-spacing: -0.012em; }
.muscle-row .row-top .m-val {
  color: var(--text);
  font-weight: 650;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 14.5px;
  letter-spacing: -0.02em;
}

.status-chip {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  padding: 3px 10px;
  border-radius: 980px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.10);
}
body[data-theme="light"] .status-chip { background: rgba(29, 29, 31, 0.045); border-color: rgba(29, 29, 31, 0.09); }
.status-low { color: var(--danger); }
.status-mid { color: var(--warn); }
.status-ok { color: var(--ok); }
.status-over { color: var(--over); }
.status-focus {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  background: var(--accent-soft);
}
.status-focus svg { width: 10px; height: 10px; }

.overall-week { margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.overall-week .row-top { display: flex; align-items: center; gap: 10px; font-size: 13.5px; margin-bottom: 8px; }
.overall-week .row-top b { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.overall-week .row-top span:last-child { margin-left: auto; color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

/* Бейджі */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 650;
  padding: 3px 10px;
  border-radius: 980px;
  border: 1px solid transparent;
}

/* ============================================================
   КАТАЛОГ ВПРАВ
   ============================================================ */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px;
  border-radius: 980px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 590;
  cursor: pointer;
  transition: 0.16s;
}
span.chip.tpl-chip { display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.chip:focus-visible { box-shadow: var(--focus-ring); }
.chip.active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.20);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  animation: pillPop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
body[data-theme="light"] .chip.active { background: #ffffff; box-shadow: 0 3px 10px rgba(29, 29, 31, 0.12); }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 9px;
  max-height: 430px;
  overflow-y: auto;
  padding: 2px;
  margin-top: 12px;
}
.cat-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 13px 7px 11px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: transform 0.18s cubic-bezier(0.25, 1, 0.35, 1), background 0.16s, border-color 0.16s, box-shadow 0.16s;
  animation: tileIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
/* Хвиля tile-ів при відкритті каталогу та зміні фільтра */
.cat-tile:nth-child(1) { animation-delay: 0.02s; }
.cat-tile:nth-child(2) { animation-delay: 0.04s; }
.cat-tile:nth-child(3) { animation-delay: 0.06s; }
.cat-tile:nth-child(4) { animation-delay: 0.08s; }
.cat-tile:nth-child(5) { animation-delay: 0.10s; }
.cat-tile:nth-child(6) { animation-delay: 0.12s; }
.cat-tile:nth-child(7) { animation-delay: 0.14s; }
.cat-tile:nth-child(8) { animation-delay: 0.16s; }
.cat-tile:nth-child(9) { animation-delay: 0.18s; }
.cat-tile:nth-child(10) { animation-delay: 0.20s; }
.cat-tile:nth-child(11) { animation-delay: 0.22s; }
.cat-tile:nth-child(12) { animation-delay: 0.24s; }
.cat-tile:nth-child(n+13) { animation-delay: 0.26s; }
@keyframes tileIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
body[data-theme="light"] .cat-tile { background: rgba(255, 255, 255, 0.6); }
.cat-tile:hover {
  background: var(--card-hover);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
body[data-theme="light"] .cat-tile:hover {
  border-color: rgba(29, 29, 31, 0.14);
  box-shadow: 0 12px 26px rgba(29, 29, 31, 0.12);
}
.cat-tile:active { transform: scale(0.94); }
.cat-tile:focus-visible { box-shadow: var(--focus-ring); }
.cat-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: color-mix(in srgb, currentColor 14%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.cat-ico svg { width: 24px; height: 24px; }
.cat-name {
  font-size: 10.8px;
  line-height: 1.3;
  color: var(--text-dim);
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cat-tile:hover .cat-name { color: var(--text); }
.cat-tile.added { border-color: color-mix(in srgb, var(--accent) 48%, transparent); }
.cat-check {
  position: absolute;
  top: 7px;
  right: 9px;
  width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 50%, transparent);
}

/* ============================================================
   ТРЕНУВАННЯ
   ============================================================ */
.add-exercise-box { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.add-exercise-box select, .add-exercise-box input { flex: 1; min-width: 180px; width: auto; }

.exercise-card {
  border-radius: 24px;
  padding: 17px 19px;
  margin-bottom: 14px;
}
.exercise-card .ex-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.exercise-card .ex-head .ex-name { font-weight: 650; font-size: 15px; letter-spacing: -0.014em; }
.exercise-card .ex-head .spacer { flex: 1; }

.sets-table { width: 100%; border-collapse: collapse; }
.sets-table th {
  text-align: left;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 590;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 5px 8px;
}
.sets-table td { padding: 4px 8px; }
.sets-table tbody tr { transition: background 0.14s; border-radius: 12px; }
.sets-table tbody tr:hover { background: rgba(255, 255, 255, 0.045); }
body[data-theme="light"] .sets-table tbody tr:hover { background: rgba(29, 29, 31, 0.035); }
.sets-table .set-num { color: var(--text-faint); font-weight: 650; font-size: 13px; width: 34px; font-variant-numeric: tabular-nums; }
.sets-table input { width: 90px; padding: 9px 11px; border-radius: 11px; }
.sets-table .unit-lbl { color: var(--text-faint); font-size: 12px; margin-left: 6px; }
/* RIR, підказаний автоматично — пунктирна рамка */
.sets-table .inp-rir.auto { border-style: dashed; border-color: color-mix(in srgb, var(--accent) 44%, var(--border)); color: var(--text-dim); }
.sets-table .set-sum { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.workout-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.workout-meta input { max-width: 230px; }

/* ============================================================
   ІСТОРІЯ
   ============================================================ */
.month-header {
  font-weight: 650;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin: 22px 4px 10px;
}
.month-header:first-of-type { margin-top: 0; }
#hist-search { margin-bottom: 16px; }

.history-item {
  border-radius: 24px;
  padding: 12px 15px;
  margin-bottom: 10px;
  transition: border-color 0.16s, transform 0.16s;
}
.history-item:hover {
  border-color: rgba(255, 255, 255, 0.30);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35), var(--specular);
}
body[data-theme="light"] .history-item:hover {
  border-color: rgba(29, 29, 31, 0.18);
  box-shadow: 0 14px 30px rgba(29, 29, 31, 0.14), var(--specular);
}
.history-item.open { border-color: color-mix(in srgb, var(--accent) 46%, var(--border-strong)); }
.history-item .h-head { display: flex; align-items: center; gap: 13px; cursor: pointer; user-select: none; }
.h-date-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 56px;
  height: 56px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
body[data-theme="light"] .h-date-block { background: rgba(29, 29, 31, 0.045); }
.h-date-block .h-daynum { font-size: 21px; font-weight: 700; line-height: 1.05; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.h-date-block .h-weekday { font-size: 10px; color: var(--text-dim); text-transform: capitalize; line-height: 1.1; }
.h-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.h-info .h-title {
  font-weight: 650;
  font-size: 14.5px;
  letter-spacing: -0.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.h-info .h-sub {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.h-chevron { margin-left: auto; color: var(--text-faint); font-size: 22px; line-height: 1; transition: transform 0.22s ease; flex-shrink: 0; }
.history-item.open .h-chevron { transform: rotate(90deg); color: var(--accent); }
.history-item .h-details {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 0.22s ease;
}
.h-details .d-ex { font-size: 13.5px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.h-details .d-ex .d-sets { color: var(--text-dim); font-variant-numeric: tabular-nums; }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 46px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
}
.empty-state .big {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--accent);
  opacity: 0.92;
}
.empty-state .big svg { width: 48px; height: 48px; animation: bob 3.4s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ============================================================
   СТАТИСТИКА / ГРАФІКИ
   ============================================================ */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card { border-radius: 22px; padding: 16px 18px; }
.stat-card .num {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-card .lbl { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; font-weight: 500; }

.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
svg .grid-line { stroke: rgba(245, 245, 247, 0.10); stroke-width: 1; stroke-dasharray: 2 7; }
body[data-theme="light"] svg .grid-line { stroke: rgba(29, 29, 31, 0.12); }
svg .axis-label { fill: var(--text-faint); font-size: 11px; font-family: var(--font); animation: fadeSoft 0.5s 0.12s backwards; }
svg .bar-label { fill: var(--text-dim); font-size: 11px; font-weight: 650; font-family: var(--font); animation: fadeSoft 0.4s backwards; }

/* Анімації появи графіків (Swift Charts style) */
svg .bar {
  transform-box: fill-box;
  transform-origin: bottom center;
  animation: barGrow 0.65s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
@keyframes barGrow { from { transform: scaleY(0); } }
svg .line-area { animation: fadeSoft 0.7s 0.1s backwards; }
svg .line-path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: lineDraw 1.1s cubic-bezier(0.4, 0, 0.2, 1) 0.15s forwards;
}
@keyframes lineDraw { to { stroke-dashoffset: 0; } }
svg .pt {
  transform-box: fill-box;
  transform-origin: center;
  animation: ptPop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4) backwards;
}
@keyframes ptPop { from { opacity: 0; transform: scale(0); } }
svg .trend-line { animation: fadeSoft 0.6s 0.8s backwards; }

.dist-row { margin-bottom: 11px; }
.dist-row .row-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.dist-row .row-top .d-pct { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.dist-bar {
  height: 9px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.20);
}
body[data-theme="light"] .dist-bar { background: rgba(29, 29, 31, 0.07); }
.dist-fill { height: 100%; border-radius: 999px; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2); animation: growW 0.7s cubic-bezier(0.22, 1, 0.36, 1) backwards; }

.select-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.select-row select { flex: 1; min-width: 200px; width: auto; }

.prs-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.prs-table th { text-align: left; color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; padding: 6px 8px; }
.prs-table td { padding: 8px; border-top: 1px solid var(--border); }
.prs-table tbody tr { transition: background 0.14s; }
.prs-table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
body[data-theme="light"] .prs-table tbody tr:hover { background: rgba(29, 29, 31, 0.03); }
.prs-table .pr-num { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================================================
   НАЛАШТУВАННЯ
   ============================================================ */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.settings-grid .card { margin-bottom: 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.set-row:last-of-type { border-bottom: none; }
.set-row .s-lbl { font-size: 14px; font-weight: 500; }
.set-row .s-lbl small { display: block; color: var(--text-faint); font-size: 12px; font-weight: 400; }
.set-row select, .set-row input { width: 170px; }

.seg button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 590;
  font-family: inherit;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.18s;
}
.seg button:focus-visible { box-shadow: var(--focus-ring); }
.seg button.active {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: pillPop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}

/* Журнал ваги та методологія */
.wlog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.wlog-row:last-of-type { border-bottom: none; }
.wlog-row b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.mini-list { margin: 6px 0 0; padding-left: 18px; color: var(--text-dim); font-size: 12.5px; }
.mini-list li { margin-bottom: 5px; }
.mini-list li::marker { color: var(--accent); }

/* ============================================================
   СВЯТКУВАННЯ РЕКОРДУ
   ============================================================ */
#pr-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 10, 0.55);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  animation: fadeIn 0.2s ease;
}
#pr-overlay.hidden { display: none; }
.pr-card {
  text-align: center;
  border-radius: 36px;
  padding: 36px 48px;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.55),
    0 0 90px color-mix(in srgb, var(--accent) 22%, transparent),
    var(--specular);
  animation: prPop 0.55s cubic-bezier(0.18, 1.4, 0.4, 1);
}
.pr-trophy {
  display: flex;
  justify-content: center;
  color: var(--accent);
  animation: trophyFloat 1.2s ease-in-out infinite alternate;
  filter: drop-shadow(0 14px 30px color-mix(in srgb, var(--accent) 50%, transparent));
}
.pr-trophy svg { width: 62px; height: 62px; }
@keyframes prPop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes trophyFloat { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-8px) rotate(4deg); } }
.pr-title { font-size: 22px; font-weight: 700; letter-spacing: -0.022em; color: var(--accent); margin-top: 12px; }
.pr-text { color: var(--text); margin-top: 5px; font-size: 15px; }
.pr-text b { font-variant-numeric: tabular-nums; }
.pr-hint { color: var(--text-faint); font-size: 11.5px; margin-top: 14px; }
.pr-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.pr-confetti i {
  position: absolute;
  top: -24px;
  display: block;
  border-radius: 2px;
  animation-name: confettiFall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes confettiFall { to { transform: translateY(112vh) rotate(680deg); } }

/* Делоад-рекомендація */
.deload-box {
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.deload-box b { color: var(--accent); font-size: 13.5px; }
.deload-box span { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }

/* ============================================================
   ТАЙМЕР ВІДПОЧИНКУ
   ============================================================ */
#rest-timer {
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px 10px 24px;
  border-radius: 980px;
  animation: riseIn 0.45s cubic-bezier(0.2, 1.1, 0.3, 1) backwards;
}
@keyframes riseIn { from { opacity: 0; transform: translateX(-50%) translateY(18px) scale(0.9); } }
#rest-timer.hidden { display: none; }
#rest-timer .rt-time {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 62px;
  text-align: center;
  letter-spacing: -0.02em;
}
#rest-timer.done .rt-time { color: var(--ok); }
/* Пульсуюче світіння, коли відпочинок завершено */
#rest-timer.done { animation: doneGlow 1.5s ease-in-out infinite; }
@keyframes doneGlow {
  0%, 100% { box-shadow: var(--shadow), var(--specular); }
  50% { box-shadow: var(--shadow), 0 0 0 5px color-mix(in srgb, var(--ok) 24%, transparent), var(--specular); }
}
.rt-btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  padding: 7px 13px;
  border-radius: 980px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 590;
  transition: 0.15s;
}
.rt-btn:hover { color: var(--text); border-color: var(--border-strong); }
.rt-btn:focus-visible { box-shadow: var(--focus-ring); }

/* ============================================================
   БАЛАНС М'ЯЗІВ
   ============================================================ */
.balance .b-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.split-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--bg-soft); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18); }
body[data-theme="light"] .split-bar { box-shadow: inset 0 1px 2px rgba(29, 29, 31, 0.10); }
.split-bar .seg-a { height: 100%; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); animation: growW 0.7s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.b-pct {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.b-note { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }

/* Шаблони-чипси */
.tpl-chip { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.tpl-chip svg { width: 12px; height: 12px; }
.chip-x { border: none; background: none; color: var(--text-faint); font-size: 11px; cursor: pointer; padding: 0 2px; }
.chip-x:hover { color: var(--danger); }
.badge-soft {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
body[data-theme="light"] .badge-soft { background: rgba(29, 29, 31, 0.045); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  animation: toastIn 0.32s cubic-bezier(0.2, 0.9, 0.25, 1.18);
}
.toast.error { border-color: color-mix(in srgb, var(--danger) 52%, transparent); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============================================================
   АДАПТИВНІСТЬ
   ============================================================ */
.nav-btn { display: inline-flex; align-items: center; gap: 7px; }

/* Мобільні пристрої (iPhone ≈ 402×874 та схожі) */
@media (max-width: 700px) {
  * { -webkit-tap-highlight-color: transparent; }
  body { touch-action: manipulation; }

  .topbar-inner { gap: 8px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .brand { font-size: 16px; }

  /* backdrop-filter на topbar створює containing block для fixed .nav —
     на мобільному вимикаємо, інакше таб-бар не пригвинтиться до низу */
  .topbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
  }

  /* Плаваюча скляна капсула-навігація (iOS 26 tab bar) */
  .nav {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 60;
    border-radius: 32px;
    background: var(--glass-sheen);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow:
      0 18px 44px rgba(0, 0, 0, 0.50),
      inset 0 1px 0 rgba(255, 255, 255, 0.22);
    padding: 7px 9px;
    margin: 0;
    gap: 3px;
    overflow: hidden;
  }
  body[data-theme="light"] .nav { border-color: rgba(29, 29, 31, 0.08); box-shadow: 0 18px 44px rgba(29, 29, 31, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9); }
  .nav-btn {
    flex: 1;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    font-weight: 590;
    padding: 7px 2px;
    border-radius: 24px;
  }
  .nav-btn .n-ico svg { width: 22px; height: 22px; }
  .nav-btn.active {
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  }
  .nav-btn.active .n-ico { color: var(--accent); }

  .user-chip { padding: 5px 13px 5px 6px; }
  .user-chip .u-name { display: none; }

  .container { padding: 20px 14px calc(110px + env(safe-area-inset-bottom)); }
  .footer { display: none; }

  /* 16px — щоб iOS не зумив поле при фокусі */
  input, select { font-size: 16px; }

  .grid-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hero-card { gap: 16px; }
  .hero-card .ring { width: 110px; height: 110px; }
  .ring-num { font-size: 23px; }
  .ring-lbl { font-size: 10px; }
  .hero-stats { gap: 12px 10px; }
  .hs-num { font-size: 16.5px; }
  .card-actions { flex-direction: column; }
  .card-actions .btn { width: 100%; }
  .card { padding: 17px 18px; border-radius: 24px; }
  h2.view-title { font-size: 26px; }
  p.view-sub { font-size: 13.5px; margin-bottom: 16px; }

  .toast { bottom: calc(104px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); text-align: center; }
  #rest-timer { bottom: calc(104px + env(safe-area-inset-bottom)); width: max-content; }

  .sets-table input { width: 74px; }
  .workout-meta input { max-width: none; width: 100%; }
  .workout-meta label { width: 100%; }
  .add-exercise-box select, .add-exercise-box input { min-width: 0; width: 100%; flex: 1 1 100%; }
  .add-exercise-box .btn { flex: 1 1 auto; }

  .select-row select { width: 100%; }
  .settings-grid { grid-template-columns: 1fr; }
  .set-row { flex-wrap: wrap; }
  .set-row select, .set-row input { width: 100%; }
  .seg { width: 100%; justify-content: space-between; }

  .chart-wrap svg { min-width: 560px; }
  .pr-card { padding: 30px 34px; margin: 0 20px; border-radius: 32px; }
  .auth-card { padding: 32px 24px; border-radius: 30px; }
}

@media (max-width: 480px) {
  .sets-table th:nth-child(5),
  .sets-table td:nth-child(5) { display: none; }
  .sets-table input { width: 64px; }
  .sets-table .inp-rir { width: 50px; }
}

/* Повага до reduced motion: вимикаємо всю анімацію */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
