:root {
  --bg: #08090b;
  --bg-soft: #0e1013;
  --card: #121519;
  --card-2: #171b20;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f3f4f6;
  --muted: #9aa1ab;
  --dim: #6b7280;
  --accent: #e60000;
  --accent-soft: rgba(230, 0, 0, .14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .12);
  --radius: 18px;
  --tap: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

button, input { font-family: inherit; }
button { cursor: pointer; color: inherit; }

#app {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 18px calc(96px + var(--safe-b));
}

/* ---- общее ---- */
.eyebrow {
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
  margin: 0 0 6px;
}

h1 { font-size: 34px; line-height: 1.12; margin: 0; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 17px; margin: 0; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

.top { padding: calc(26px + var(--safe-t)) 0 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.stack > * + * { margin-top: 12px; }
.section { margin-top: 26px; }

/* ---- главный экран ---- */
.day-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.day-card:active { transform: scale(.992); border-color: var(--line-strong); }
.day-card.is-next { border-color: rgba(230, 0, 0, .45); background: linear-gradient(180deg, rgba(230,0,0,.08), rgba(230,0,0,0) 60%), var(--card); }
.day-num { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.day-title { font-size: 23px; font-weight: 650; letter-spacing: -.01em; margin-top: 4px; }
.day-meta { color: var(--muted); font-size: 15px; margin-top: 4px; }
.day-list { margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.day-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-size: 14.5px; color: var(--muted); padding: 8px 0; border-bottom: 1px solid var(--line);
}
.day-row:last-child { border-bottom: 0; }
.day-row b { color: var(--text); font-weight: 500; flex: 1; min-width: 0; }
.day-row span { flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--dim); }
.tag {
  display: inline-block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 10px; margin-top: 10px;
}

.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat span { font-size: 13px; color: var(--dim); }

/* ---- напоминания ---- */
.reminder {
  border: 1px solid rgba(230, 0, 0, .35);
  background: linear-gradient(180deg, rgba(230,0,0,.10), rgba(230,0,0,.02));
  border-radius: var(--radius);
  padding: 16px 18px;
}
.reminder .rt { font-weight: 600; margin-bottom: 4px; }
.reminder .rd { color: var(--muted); font-size: 15px; }

/* ---- экран тренировки ---- */
.wk-head { padding: calc(18px + var(--safe-t)) 0 10px; }
.wk-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg-soft); display: grid; place-items: center; padding: 0;
}
.icon-btn svg { width: 20px; height: 20px; stroke: var(--text); }
.progress-line { height: 3px; background: rgba(255,255,255,.08); border-radius: 2px; margin: 14px 0 0; overflow: hidden; }
.progress-line i { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }

.ex-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 16px 18px;
  margin-top: 12px;
  transition: border-color .2s ease, opacity .2s ease;
}
.ex-card.is-active { border-color: rgba(230,0,0,.5); }
.ex-card.is-done { opacity: .5; }
.ex-top { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.ex-name { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.ex-sub { color: var(--dim); font-size: 14px; margin-top: 3px; }
.ex-focus { color: var(--muted); font-size: 14px; margin-top: 8px; }
.ex-sets-text { color: var(--dim); font-size: 14px; white-space: nowrap; }

.sets { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.set-dot {
  width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line-strong);
  background: var(--bg-soft); display: grid; place-items: center; font-size: 16px; font-weight: 600;
  color: var(--muted); padding: 0;
}
.set-dot.on { background: var(--ok-soft); border-color: rgba(52,211,153,.5); color: var(--ok); }
.set-dot.current { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px rgba(230,0,0,.35) inset; }

.ex-inputs { display: flex; gap: 10px; margin-top: 14px; }
.field { flex: 1; }
.field label { display: block; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; }
.field input {
  width: 100%; height: var(--tap); border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--bg-soft); color: var(--text); font-size: 19px; font-weight: 600; padding: 0 14px;
  -moz-appearance: textfield;
}
.field input::-webkit-outer-spin-button, .field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input:focus { outline: none; border-color: var(--accent); }

.weight-input { display: flex; gap: 6px; }
.weight-input button {
  flex: none; width: 44px; height: var(--tap); border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--bg-soft); color: var(--text); font-size: 20px; padding: 0;
}
.weight-input input { flex: 1; min-width: 0; text-align: center; }
.weight-input.need input { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(230,0,0,.18); }
.weight-input.need button { border-color: rgba(230,0,0,.5); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--tap); padding: 0 20px; border-radius: 14px; border: 1px solid var(--line-strong);
  background: var(--card-2); color: var(--text); font-size: 16px; font-weight: 600; letter-spacing: .01em;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-ghost { background: transparent; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #04110c; }
.btn[disabled] { opacity: .4; pointer-events: none; }

.last-line { margin-top: 12px; font-size: 14px; color: var(--dim); border-top: 1px solid var(--line); padding-top: 10px; }
.last-line b { color: var(--muted); font-weight: 500; }
.hint { margin-top: 10px; font-size: 14px; color: var(--ok); }

/* ---- таймер ---- */
.timer-screen {
  position: fixed; inset: 0; z-index: 60;
  background: radial-gradient(circle at 50% 0%, #17090a 0%, var(--bg) 55%);
  display: flex; flex-direction: column;
  padding: calc(18px + var(--safe-t)) 20px calc(24px + var(--safe-b));
}
.timer-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.timer-phase { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; font-weight: 700; color: var(--accent); }
.timer-name { font-size: 17px; color: var(--muted); margin-top: 4px; }
.timer-mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-wrap { position: relative; width: min(74vw, 320px); aspect-ratio: 1; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.07); stroke-width: 6; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.ring-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-clock { font-size: clamp(52px, 17vw, 76px); font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.timer-sub { margin-top: 8px; color: var(--dim); font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.timer-hint { text-align: center; color: var(--muted); font-size: 16px; margin-top: 22px; max-width: 320px; }
.timer-actions { display: flex; flex-direction: column; gap: 10px; }
.timer-actions .btn { height: 62px; font-size: 17px; }
.timer-actions-row { display: flex; gap: 10px; }
.timer-actions-row .btn { flex: 1; height: 48px; font-size: 15px; }

.timer-screen.is-ready .ring-fg { stroke: var(--ok); }
.timer-screen.is-ready .timer-phase { color: var(--ok); }
.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---- настройки ---- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .sl { font-weight: 500; }
.set-row .sd { font-size: 13px; color: var(--dim); margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg-soft); font-size: 20px; color: var(--text); }
.stepper span { min-width: 62px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.switch { width: 52px; height: 32px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg-soft); position: relative; padding: 0; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--dim); transition: all .18s ease; }
.switch.on { background: var(--accent-soft); border-color: rgba(230,0,0,.5); }
.switch.on i { left: 25px; background: var(--accent); }

/* ---- прогресс ---- */
.prog-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "main right" "chart right";
  gap: 4px 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.prog-row:last-child { border-bottom: 0; }
.prog-main { grid-area: main; min-width: 0; }
.prog-name { font-size: 15px; font-weight: 500; line-height: 1.28; }
.prog-meta { font-size: 12.5px; color: var(--dim); margin-top: 3px; }
.prog-right { grid-area: right; text-align: right; min-width: 66px; }
.prog-val { font-size: 18px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prog-delta { font-size: 13px; color: var(--dim); }
.prog-delta.up { color: var(--ok); }
.prog-delta.down { color: #f87171; }
.prog-row svg { grid-area: chart; margin-top: 4px; }

/* ---- история ---- */
.hist-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.hist-item:last-child { border-bottom: 0; }
.hist-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.hist-date { font-size: 13px; color: var(--dim); }
.hist-sets { font-size: 15px; color: var(--muted); margin-top: 4px; }
.empty { color: var(--dim); text-align: center; padding: 40px 0; font-size: 15px; }

/* ---- нижняя навигация ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(8, 9, 11, .86);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + var(--safe-b));
}
.tabbar-inner { max-width: 620px; margin: 0 auto; display: flex; }
.tab {
  flex: 1; background: none; border: 0; padding: 6px 0 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--dim); font-size: 11px; letter-spacing: .04em;
}
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tab.on { color: var(--text); }
.tab.on svg { stroke: var(--accent); }

/* ---- прочее ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%);
  background: #1d2126; border: 1px solid var(--line-strong); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 15px; z-index: 80;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.rules-list { margin: 0; padding: 0; list-style: none; }
.rules-list li { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--muted); }
.rules-list li:last-child { border-bottom: 0; }
.rules-list b { display: block; color: var(--text); font-size: 16px; margin-bottom: 2px; font-weight: 600; }

.fade-in { animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
