/* ============================================================
   FitTrack — Design System
   Тёмная тема · акцент энергии (лайм) · мобильная-first
   ============================================================ */

:root {
  /* Поверхности */
  --bg: #0f1115;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(132,204,22,0.10), transparent 60%),
             radial-gradient(900px 500px at -10% 10%, rgba(34,197,94,0.08), transparent 55%),
             #0f1115;
  --surface: #161a21;
  --surface-2: #1d222b;
  --surface-3: #252b36;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.13);

  /* Текст */
  --text: #f3f5f8;
  --text-dim: #a3acba;
  --text-faint: #6b7280;

  /* Акцент */
  --primary: #a3e635;
  --primary-press: #84cc16;
  --primary-soft: rgba(163,230,53,0.14);
  --accent-2: #22c55e;
  --grad-primary: linear-gradient(135deg, #c6f432 0%, #65d36e 55%, #22c55e 100%);

  /* Семантика */
  --danger: #f87171;
  --danger-soft: rgba(248,113,113,0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251,191,36,0.14);
  --info: #60a5fa;
  --info-soft: rgba(96,165,250,0.14);

  /* Группа мышц (чипы) */
  --tag-legs: #60a5fa;
  --tag-chest: #f472b6;
  --tag-back: #a78bfa;
  --tag-shoulders: #fbbf24;
  --tag-arms: #34d399;
  --tag-core: #fb923c;
  --tag-fullbody: #a3e635;

  /* Геометрия */
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* Тени */
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --shadow-soft: 0 6px 18px rgba(0,0,0,0.25);
  --glow: 0 8px 24px rgba(132,204,22,0.30);

  /* Layout */
  --header-h: 56px;
  --nav-h: 68px;
  --max-w: 520px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

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

html, body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-grad);
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  gap: 12px;
  padding-inline: 16px;
  background: rgba(15,17,21,0.72);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.app-header .h-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.app-header .h-sub { font-size: 12px; color: var(--text-dim); }
.app-header .spacer { flex: 1; }
.app-header .icon-btn { margin-left: 4px; }

/* ---------- View ---------- */
.view {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 18px);
  animation: fade .28s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: rgba(18,21,27,0.86);
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  border-top: 1px solid var(--border);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-faint);
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 8px 4px;
  transition: color .18s ease, transform .12s ease;
}
.nav-item svg { width: 23px; height: 23px; }
.nav-item .nav-label { font-size: 10.5px; font-weight: 600; }
.nav-item.active { color: var(--primary); }
.nav-item.active svg { transform: translateY(-1px); filter: drop-shadow(0 4px 8px rgba(163,230,53,0.35)); }
.nav-item:active { transform: scale(0.92); }

.nav-item.center {
  position: relative;
  flex: 0 0 64px;
}
.nav-fab {
  width: 56px; height: 56px;
  margin-top: -22px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad-primary);
  color: #0c1100;
  box-shadow: var(--glow);
  border: 3px solid rgba(15,17,21,0.9);
  transition: transform .12s ease;
}
.nav-item.center:active .nav-fab { transform: scale(0.92); }
.nav-fab svg { width: 26px; height: 26px; }
.nav-item.center .nav-label { color: var(--primary); font-weight: 700; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { letter-spacing: -0.02em; line-height: 1.2; }
.h-xxl { font-size: 28px; font-weight: 800; }
.h-xl { font-size: 22px; font-weight: 800; }
.h-lg { font-size: 18px; font-weight: 700; }
.h-md { font-size: 16px; font-weight: 700; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 2px 12px;
}
.section-title h2 { font-size: 17px; font-weight: 800; }
.section-title .link { font-size: 13px; color: var(--primary); font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
}
.card-2 { background: var(--surface-2); }
.card-tight { padding: 12px; }
.card + .card { margin-top: 12px; }

/* Hero-карточка следующей тренировки */
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 20px;
  background: linear-gradient(135deg, rgba(163,230,53,0.16), rgba(34,197,94,0.06) 60%, var(--surface));
}
.hero::after {
  content: "";
  position: absolute; inset: auto -30% -60% auto;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(163,230,53,0.35), transparent 70%);
  filter: blur(8px);
}
.hero .hero-kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.hero h3 { font-size: 24px; font-weight: 800; margin-top: 4px; }
.hero .hero-meta { display: flex; gap: 14px; margin-top: 12px; color: var(--text-dim); font-size: 13px; }
.hero .hero-meta span { display: inline-flex; align-items: center; gap: 5px; }
.hero .hero-meta svg { width: 15px; height: 15px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 13px 20px;
  transition: transform .12s ease, filter .18s ease, background .18s ease;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--grad-primary); color: #0c1100; box-shadow: var(--glow); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 22px; font-size: 16px; }
.btn-sm { padding: 9px 14px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; filter: grayscale(0.3); cursor: not-allowed; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: transform .12s ease, background .18s ease;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Chips / tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.chip-accent { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-info { background: var(--info-soft); color: var(--info); border-color: transparent; }

.mtag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: var(--r-pill);
  color: var(--c, var(--primary));
  background: color-mix(in srgb, var(--c, var(--primary)) 16%, transparent);
}

/* ---------- Inputs ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; }
.input, .select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  padding: 13px 14px;
  outline: none;
  transition: border .18s ease, box-shadow .18s ease;
}
.input:focus, .select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: var(--text-faint); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3acba' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 38px; }

/* Segmented control */
.seg {
  display: flex; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 4px; border-radius: var(--r-pill);
}
.seg button {
  flex: 1; border: none; background: none; color: var(--text-dim);
  font: inherit; font-weight: 700; font-size: 13px;
  padding: 9px 10px; border-radius: var(--r-pill); cursor: pointer;
  transition: all .18s ease;
}
.seg button.active { background: var(--grad-primary); color: #0c1100; }

/* ---------- Progress ring ---------- */
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-val { position: absolute; text-align: center; }
.ring .ring-val .big { font-size: 22px; font-weight: 800; }
.ring .ring-val .lbl { font-size: 10px; color: var(--text-dim); }

/* ---------- Stats grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px;
}
.stat .stat-val { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat .stat-lbl { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.stat .stat-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 10px; }
.stat .stat-ic svg { width: 17px; height: 17px; }

/* ---------- Exercise / workout rows ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.ex-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 13px 14px;
  cursor: pointer; transition: border .18s ease, transform .1s ease;
}
.ex-row:active { transform: scale(0.99); }
.ex-ic {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
  background: var(--surface-3);
}
.ex-meta { flex: 1; min-width: 0; }
.ex-meta .ex-name { font-weight: 700; font-size: 15px; }
.ex-meta .ex-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 1px; }
.chev { color: var(--text-faint); }
.chev svg { width: 20px; height: 20px; }

/* Set rows (active workout) */
.set-row {
  display: grid;
  grid-template-columns: 34px 1fr 1fr 40px;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.set-row:last-child { border-bottom: none; }
.set-row .set-no { font-weight: 700; color: var(--text-dim); font-size: 13px; text-align: center; }
.set-input {
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 9px 8px; text-align: center; color: var(--text);
  font: inherit; font-weight: 700; outline: none; width: 100%;
}
.set-input:focus { border-color: var(--primary); }
.set-check {
  width: 34px; height: 34px; border-radius: 50%; justify-self: center;
  border: 2px solid var(--border-strong); background: none; cursor: pointer;
  display: grid; place-items: center; color: transparent;
  transition: all .15s ease;
}
.set-check.done { background: var(--grad-primary); border-color: transparent; color: #0c1100; }
.set-check svg { width: 18px; height: 18px; }
.set-row.done .set-no { color: var(--primary); }

/* Rest timer pill */
.rest-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  z-index: 45;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: var(--r-pill); padding: 8px 8px 8px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
  animation: rise .25s ease;
}
@keyframes rise { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
.rest-bar .rest-time { font-weight: 800; font-size: 17px; min-width: 46px; }
.rest-bar button { background: var(--primary-soft); color: var(--primary); border: none; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; display: grid; place-items: center; }

/* ---------- Calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-faint); font-weight: 700; padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1; display: grid; place-items: center;
  border-radius: 11px; font-size: 13px; font-weight: 600;
  color: var(--text-dim); position: relative;
}
.cal-day.empty { visibility: hidden; }
.cal-day.today { outline: 2px solid var(--primary); outline-offset: -2px; color: var(--text); }
.cal-day.done { background: var(--grad-primary); color: #0c1100; font-weight: 800; }
.cal-day.done.A { background: linear-gradient(135deg,#c6f432,#65d36e); }
.cal-day.done.B { background: linear-gradient(135deg,#60a5fa,#a78bfa); }
.cal-day .dot { position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); }

/* ---------- Chart (bars) ---------- */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 6px; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; max-width: 26px; border-radius: 7px 7px 4px 4px; background: var(--grad-primary); min-height: 3px; transition: height .4s ease; }
.chart .bar-x { font-size: 10px; color: var(--text-faint); }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 60; display: none; }
.modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); animation: fade .2s ease; }
.modal-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--surface); border-top-left-radius: 24px; border-top-right-radius: 24px;
  border: 1px solid var(--border-strong); border-bottom: none;
  max-width: var(--max-w); margin: 0 auto;
  padding: 10px 18px calc(20px + var(--safe-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: slideUp .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-grip { width: 40px; height: 5px; border-radius: 999px; background: var(--border-strong); margin: 4px auto 14px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--surface-3); border: 1px solid var(--border-strong);
  color: var(--text); padding: 11px 16px; border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
  animation: toastIn .25s ease;
}
.toast.good { border-color: rgba(163,230,53,0.4); }
.toast.warn { border-color: rgba(251,191,36,0.4); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Misc / helpers ---------- */
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-6 { margin-top: 6px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.pill-info { background: var(--warn-soft); border: 1px solid rgba(251,191,36,0.25); color: var(--warn); border-radius: var(--r); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.pill-info svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-dim); }
.kv .v { font-weight: 700; }
.step-list { counter-reset: s; list-style: none; }
.step-list li { counter-increment: s; position: relative; padding-left: 32px; padding-bottom: 12px; font-size: 14px; }
.step-list li::before {
  content: counter(s); position: absolute; left: 0; top: -1px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 800; display: grid; place-items: center;
}
.bullet-list { list-style: none; }
.bullet-list li { position: relative; padding-left: 22px; padding-bottom: 9px; font-size: 13.5px; }
.bullet-list li::before { content: ""; position: absolute; left: 4px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.bad { color: var(--danger); }
.warn-x { color: var(--warn); }
.good-x { color: var(--primary); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.empty-state .emoji { font-size: 40px; }
.empty-state p { color: var(--text-dim); margin-top: 8px; font-size: 14px; }

/* fast reps stepper */
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); font-size: 18px; font-weight: 700; cursor: pointer; }

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }

a { color: inherit; text-decoration: none; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: 0 0 auto; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch::before {
  content: ""; position: absolute; inset: 0;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: 999px; transition: background .2s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--text-dim); transition: transform .22s cubic-bezier(.2,.8,.2,1), background .2s ease;
}
.switch input:checked ~ ::before, .switch:has(input:checked)::before { background: var(--grad-primary); border-color: transparent; }
.switch:has(input:checked)::after { transform: translateX(20px); background: #0c1100; }
