:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card-2: #162032;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;
  --blue: #3b82f6;
  --blue-2: #2563eb;
  --green: #4ade80;
  --danger: #f87171;
  --radius: 14px;
  --top: 58px;
  --tabbar: 0px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; width: 100%; }
html, body { margin: 0; background: var(--bg); width: 100%; }
body { min-height: 100dvh; overflow-x: hidden; }
/* Режим «как приложение» с домашнего экрана iPhone */
@media all and (display-mode: standalone) {
  body { overscroll-behavior: none; }
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
}
@supports (-webkit-touch-callout: none) {
  body { -webkit-user-select: none; }
  input, textarea, select { -webkit-user-select: text; }
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button, a { -webkit-tap-highlight-color: transparent; }
#app {
  min-height: 100dvh; width: 100%; min-width: 0;
  background: var(--bg); display: flex; flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  min-height: var(--top); padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
  flex-wrap: nowrap; width: 100%; box-sizing: border-box;
}
.brand {
  font-size: 18px; font-weight: 700; color: #f1f5f9;
  background: none; border: 0; padding: 8px 0;
  flex: none; white-space: nowrap; margin-right: auto;
}
.nav {
  display: flex; gap: 4px; flex-wrap: nowrap; align-items: center;
  flex: none;
}
.nav button {
  background: transparent; border: 0; color: var(--muted);
  padding: 8px 12px; border-radius: 8px; white-space: nowrap;
  flex: none;
}
.nav button.on { background: var(--blue-2); color: #fff; }
.nav button:hover { color: #f1f5f9; }
.logout-card { margin-top: 18px; }
.logout-card .btn { margin-bottom: 8px; }
.tabbar { display: none !important; }
.tabbar.is-hidden { display: none !important; }
#app.nested .fab { display: none; }

.feed {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 8px 16px calc(24px + var(--tabbar));
  box-sizing: border-box;
  position: relative;
}
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + var(--tabbar));
  z-index: 22;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-size: 32px;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.fab:hover { background: var(--blue-2); }
.fab:active { transform: scale(0.96); }
.feed-list { display: flex; flex-direction: column; gap: 10px; }
.wcard {
  position: relative;
  width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 14px 14px 18px; color: var(--text);
  display: flex; align-items: center; gap: 10px;
  min-height: 76px;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
.wcard::before {
  content: '';
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--line);
}
.wcard-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.wcard-go {
  flex: none; width: 28px; height: 28px; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(148,163,184,.12); color: var(--muted);
  font-size: 20px; line-height: 1;
}
.wcard:active { transform: scale(.985); background: #243247; }
.wcard:active .wcard-go { background: var(--blue-2); color: #fff; }
.wcard.is-today { border-color: #3b82f6; }
.wcard.is-done::before { background: #166534; }
.wcard.kind-strength::before { background: #3b82f6; }
.wcard.kind-cardio::before { background: #22c55e; }
.wcard.kind-mix::before { background: #a78bfa; }
.wcard-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.wcard-date { font-size: 14px; font-weight: 700; color: #cbd5e1; text-transform: capitalize; }
.wcard-time { font-size: 13px; color: var(--faint); flex: none; }
.wcard-kind { font-size: 18px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.wcard-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  color: var(--muted); font-size: 12px;
}
.wcard-chip {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(15,23,42,.55); border: 1px solid var(--line);
}
.wcard-chip.muted { color: var(--faint); }
.wcard-badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(148,163,184,.16); color: #cbd5e1; font-weight: 700; font-size: 11px;
}
.wcard-badge.strength { background: rgba(59,130,246,.18); color: #93c5fd; }
.wcard-badge.cardio { background: rgba(34,197,94,.18); color: #86efac; }
.wcard-badge.mix { background: rgba(167,139,250,.18); color: #c4b5fd; }
.wcard-badge.done {
  background: rgba(74,222,128,.14); color: var(--green);
}

.workout-detail {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 8px 12px calc(24px + var(--tabbar));
  box-sizing: border-box;
}
.column {
  width: 100%;
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.column.today { border-color: #3b82f6; }
.column.done { box-shadow: inset 3px 0 0 #166534; }
.column.drop-target { outline: 2px solid var(--blue); }
.col-head { padding: 14px 14px 8px; }
.col-date { font-size: 18px; font-weight: 700; letter-spacing: .02em; text-transform: capitalize; }
.col-kind {
  margin-top: 6px; font-size: 22px; font-weight: 700; line-height: 1.2;
}
.col-kind.kind-strength { color: #93c5fd; }
.col-kind.kind-cardio { color: #86efac; }
.col-kind.kind-mix { color: #c4b5fd; }
.column.kind-strength { border-color: #3b82f6; }
.column.kind-cardio { border-color: #22c55e; }
.column.kind-mix { border-color: #a78bfa; }
.col-muscles { margin-top: 4px; color: #93c5fd; font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.col-name, .col-notes { margin-top: 4px; color: var(--muted); font-size: 13px; }
.done-flag { margin-top: 6px; color: var(--green); font-size: 12px; font-weight: 650; }
.col-body { overflow: visible; padding: 0 10px 10px; flex: 1; }
.col-progress { margin-top: 12px; }
.col-progress-head {
  display: flex; justify-content: space-between; align-items: baseline;
  color: var(--faint); font-size: 12px; margin-bottom: 6px;
}
.col-progress-head b { color: #f8fafc; }
.col-progress .track { height: 8px; background: #0f172a; border-radius: 99px; overflow: hidden; }
.col-progress .track i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.col-foot { display: flex; flex-direction: column; gap: 6px; padding: 0 10px 12px; }
.col-foot.sticky-foot {
  position: sticky; bottom: 0; z-index: 8;
  background: linear-gradient(180deg, transparent, var(--card) 28%);
  padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.col-foot.sticky-foot .btn { width: 100%; min-height: 48px; }
.col-more {
  margin: 0 10px 14px; padding: 10px 12px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
}
.col-more summary { cursor: pointer; font-weight: 650; color: var(--muted); }
.col-more[open] summary { margin-bottom: 10px; }
.col-more .btn, .col-more .btn-ghost { width: 100%; margin-top: 6px; min-height: 44px; }

.ex {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 8px; overflow: hidden;
}
.ex.done-ex { border-color: #14532d; }
.ex.dragging { opacity: .45; }
.ex-top { display: flex; align-items: flex-start; gap: 4px; }
.grip {
  border: 0; background: transparent; color: var(--faint);
  padding: 10px 8px; font-size: 16px; line-height: 1; touch-action: none; cursor: grab;
}
.ex-name {
  flex: 1; text-align: left; background: none; border: 0;
  padding: 10px 8px 4px 0; font-weight: 700; font-size: 16px; color: #f8fafc;
  min-width: 0; overflow-wrap: anywhere;
}
.copy-btn {
  flex: none; margin: 8px 8px 0 0; padding: 6px 10px;
  background: #0f172a; border: 1px solid var(--line); border-radius: 8px;
  color: #93c5fd; font-size: 12px; font-weight: 650; white-space: nowrap;
}
.copy-btn:hover { border-color: var(--blue); color: #fff; }
.ex-body {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 0 12px 8px 36px; color: var(--text);
}
.hint { display: block; color: var(--faint); font-size: 13px; margin: 0 12px 6px 36px; }
.set-line { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; font-size: 15px; }
.set-line .mark { color: var(--green); width: 16px; flex: none; }
.set-line .mark.off { color: var(--faint); }
.set-line .note { color: var(--faint); font-size: 12px; }
.ex-menu {
  flex: none; margin: 8px 8px 0 0; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 10px; background: #0f172a;
  color: #93c5fd; font-size: 16px;
}
.session-title {
  margin: 0 0 10px; text-transform: none; font-size: 26px; line-height: 1.2;
}
.session-tabs {
  display: flex; gap: 4px; margin: 0 0 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
}
.session-tabs button {
  flex: 1; min-height: 42px; background: transparent; border: 0;
  color: var(--muted); border-radius: 8px; font-weight: 650; font-size: 15px;
}
.session-tabs button.on { background: var(--blue-2); color: #fff; }

.btn, .btn-ghost, .btn-ok {
  border-radius: 10px; border: 0; font-weight: 650;
}
.btn { background: var(--blue); color: #fff; padding: 12px 16px; }
.btn:hover { background: var(--blue-2); }
.btn.secondary { background: #334155; }
.btn.secondary:hover { background: #475569; }
.btn.danger { background: #b91c1c; }
.btn-ghost {
  background: transparent; color: var(--muted); border: 0; padding: 8px; text-align: left;
}
.btn-ok {
  background: #166534; color: #fff; min-height: 56px; font-size: 22px; width: 100%;
}
.wide { width: 100%; }

.mode-switch {
  display: inline-flex; gap: 4px; margin: 12px 16px 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
}
.mode-switch button {
  background: transparent; border: 0; color: var(--muted);
  padding: 8px 14px; border-radius: 8px; font-weight: 650;
}
.mode-switch button.on { background: var(--blue-2); color: #fff; }

.cal-page { max-width: 560px; }
.mcal-head {
  display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px;
  margin: 8px 0 16px;
}
.mcal-head h2 {
  margin: 0; text-align: center; font-size: 22px; text-transform: capitalize;
}
.mcal-head button {
  min-height: 44px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font-size: 22px;
}
.mcal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  margin-bottom: 6px; color: var(--faint); font-size: 12px; text-align: center;
}
.mcal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.mcal-cell {
  position: relative; min-height: 64px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--muted); padding: 8px 6px; text-align: left;
  display: flex; flex-direction: column; gap: 4px;
}
.mcal-cell.empty { background: transparent; border-color: transparent; }
.mcal-cell b { font-size: 14px; color: var(--text); }
.mcal-cell small { color: #93c5fd; font-size: 11px; }
.mcal-cell:not(.empty) { cursor: pointer; }
.mcal-cell:not(.empty):hover { background: rgba(59,130,246,.12); }
.mcal-cell.has-workout { color: #e2e8f0; }
.mcal-cell.day-strength {
  background: rgba(59,130,246,.16); border-color: #3b82f6;
}
.mcal-cell.day-strength:hover { background: rgba(59,130,246,.28); }
.mcal-cell.day-cardio {
  background: rgba(34,197,94,.16); border-color: #22c55e;
}
.mcal-cell.day-cardio:hover { background: rgba(34,197,94,.28); }
.mcal-cell.day-mix {
  background: rgba(167,139,250,.16); border-color: #a78bfa;
}
.mcal-cell.day-mix:hover { background: rgba(167,139,250,.28); }
.mcal-cell.is-today { outline: 2px solid #f8fafc; outline-offset: 1px; }
.mcal-dot {
  position: absolute; top: 8px; right: 8px;
  min-width: 8px; height: 8px; border-radius: 999px;
  background: #3b82f6; font-size: 10px; line-height: 8px;
  color: #fff; font-weight: 700; text-align: center;
  padding: 0 3px; box-sizing: border-box;
}
.mcal-dot.day-cardio { background: #22c55e; color: #052e16; }
.mcal-dot.day-mix { background: #a78bfa; color: #1e1b4b; }
.mcal-dot:not(:empty) { min-width: 16px; height: 16px; line-height: 16px; }
.cal-legend { margin-top: 14px; }
.leg-s { color: #60a5fa; }
.leg-c { color: #4ade80; }
.leg-m { color: #c4b5fd; }
.type-legend {
  margin: 0 0 12px;
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
}
.stats-switch {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
}
.stats-switch button {
  flex: 1; min-width: 64px; min-height: 40px; background: transparent; border: 0;
  color: var(--muted); border-radius: 8px; font-weight: 650; font-size: 14px;
}
.stats-switch button.on { background: var(--blue-2); color: #fff; }
.stats-block .stats-switch { margin: 0 0 12px; }
.stats-block { margin: 8px 0 22px; }
.strength-block .section-title { color: #93c5fd; }
.cardio-block .section-title { color: #86efac; }
.totals-2 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.totals-2 > .total:nth-child(3):last-child { grid-column: 1 / -1; }
.total.tone-s { border-color: rgba(59,130,246,.45); box-shadow: inset 3px 0 0 #3b82f6; }
.total.tone-c { border-color: rgba(34,197,94,.45); box-shadow: inset 3px 0 0 #22c55e; }
.bar i.bar-s { background: #3b82f6; }
.bar i.bar-c { background: #22c55e; }

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, #1e3a5f 0%, transparent 55%),
    var(--bg);
  overflow: hidden;
}
.login-stage {
  width: 100%;
  max-width: 1040px;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(220px, 42dvh) auto;
}
.login-hero {
  position: relative;
  overflow: hidden;
  animation: loginHeroIn .7s ease-out both;
}
.login-hero-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  filter: saturate(1.05) contrast(1.04);
}
.login-hero-fade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .12) 0%, transparent 28%, transparent 48%, rgba(15, 23, 42, .55) 72%, var(--bg) 100%),
    linear-gradient(90deg, var(--bg) 0%, transparent 18%, transparent 82%, var(--bg) 100%);
}
.login-card, .panel, .modal {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
}
.login-wrap .login-card {
  width: 100%;
  max-width: 420px;
  margin: -36px auto 0;
  padding: 28px 22px 32px;
  position: relative;
  z-index: 2;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, rgba(30, 41, 59, .92) 0%, var(--bg) 100%);
  box-shadow: none;
  animation: loginFormIn .55s ease-out .12s both;
}
.login-brand {
  margin: 0;
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.05;
  color: #f8fafc;
}
.login-tag {
  margin: 8px 0 4px;
  color: #93c5fd;
  font-size: 15px;
  font-weight: 600;
}
.login-hint {
  margin: 14px 0 0;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.35;
}
@keyframes loginHeroIn {
  from { opacity: 0; transform: scale(1.04); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes loginFormIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (min-width: 860px) {
  .login-wrap { padding: 0 24px; align-items: center; }
  .login-stage {
    min-height: min(720px, 100dvh);
    grid-template-columns: 1.05fr .95fr;
    grid-template-rows: 1fr;
    align-items: stretch;
    gap: 0;
  }
  .login-hero {
    border-radius: 0;
    min-height: 100%;
  }
  .login-hero-img { object-position: center 12%; }
  .login-hero-fade {
    background:
      linear-gradient(90deg, transparent 0%, transparent 42%, rgba(15, 23, 42, .55) 72%, var(--bg) 100%),
      linear-gradient(180deg, rgba(15, 23, 42, .2) 0%, transparent 30%, transparent 70%, rgba(15, 23, 42, .35) 100%);
  }
  .login-wrap .login-card {
    margin: 0;
    max-width: none;
    align-self: center;
    border-radius: 0;
    background: transparent;
    padding: 48px 40px 48px 8px;
    animation: loginFormIn .55s ease-out .18s both;
  }
  .login-brand { font-size: 48px; }
}
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; color: var(--muted); font-size: 13px; }
.field input, .field select, .field textarea, .search, .note-input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 16px; outline: none; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .search:focus, .note-input:focus { border-color: var(--blue); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.err { color: var(--danger); min-height: 1.2em; }
.ok { color: var(--green); }

.page {
  width: 100%; max-width: 920px; margin: 0 auto;
  padding: 20px 16px calc(80px + var(--tabbar));
  min-width: 0; box-sizing: border-box;
}
.admin-page .totals { margin-top: 12px; }
.admin-users { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.admin-user {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between;
}
.admin-user.is-sys { border-color: #3b82f6; }
.admin-user.is-off { opacity: .55; }
.admin-user-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-user-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-top .btn-ghost { margin-left: auto; color: var(--muted); }
.admin-tabbar { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
.plan-actions { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 16px; }
.plan-days { display: flex; flex-direction: column; gap: 10px; }
.plan-day {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.plan-day.is-rest { opacity: .75; }
.plan-day-head {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; margin-bottom: 6px;
}
.plan-day-head em { color: #93c5fd; font-style: normal; font-weight: 650; margin-left: auto; }
.plan-ex { margin: 0; padding-left: 18px; }
.plan-ex li { margin: 2px 0; }
.page h1, .page-title {
  margin: 0 0 8px; font-size: 28px; font-weight: 700;
  text-transform: none; letter-spacing: 0;
}
.page h2, .section-title {
  margin: 28px 0 12px; font-size: 18px; font-weight: 700;
  letter-spacing: 0; text-transform: none; color: #f8fafc;
}
.back { background: none; border: 0; color: #93c5fd; padding: 0 0 12px; min-height: 44px; }

.totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.total { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.total b { display: block; font-size: 22px; margin-top: 4px; overflow-wrap: anywhere; }
.total span { color: var(--faint); font-size: 12px; }
button.total.is-tile {
  display: block; width: 100%; text-align: left; color: inherit; cursor: pointer;
  appearance: none; font: inherit;
}
button.total.is-tile:active { transform: scale(0.98); }
.total .tile-hint {
  display: block; margin-top: 6px; font-size: 11px; color: var(--muted); font-weight: 550;
}

.session { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(40px + var(--tabbar)); min-width: 0; }
.prev-block, .today-block { margin: 14px 0; }
.kicker { color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: .08em; margin-bottom: 8px; }
.prev-line { color: var(--muted); padding: 2px 0 2px 18px; }
.swipe-row {
  position: relative;
  margin-bottom: 8px;
  border-radius: 14px;
  overflow: hidden;
  touch-action: pan-y;
  background: transparent;
}
.swipe-actions {
  position: absolute; inset: 0 0 0 auto;
  width: 88px;
  display: flex; align-items: stretch; justify-content: stretch;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}
.swipe-row.open .swipe-actions,
.swipe-row.swiping .swipe-actions {
  opacity: 1;
  pointer-events: auto;
}
.swipe-del {
  width: 100%; border: 0; border-radius: 0 14px 14px 0;
  background: #b91c1c; color: #fff; font-weight: 700; font-size: 13px;
}
.swipe-front {
  position: relative; z-index: 1;
  transition: transform .2s ease;
  will-change: transform;
  background: var(--bg);
  border-radius: 14px;
}
.swipe-row.open .swipe-front { transform: translateX(-88px); }
.swipe-front .set-row,
.swipe-front .ex,
.swipe-front .wcard {
  margin-bottom: 0;
  border-radius: 14px;
}
.set-row {
  display: flex; gap: 10px; align-items: flex-start; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 8px; text-align: left;
}
.tick {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--faint);
  background: transparent; color: transparent; flex: none; font-size: 16px;
}
.tick.on { background: #14532d; border-color: var(--green); color: var(--green); }
.banner {
  background: #052e16; color: #bbf7d0; border-radius: 12px; padding: 12px 14px; margin: 10px 0;
}
.banner.pr-banner {
  background: linear-gradient(145deg, #14532d, #052e16);
  border: 1px solid #22c55e;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.25);
}
.banner.day-banner { background: #0f172a; color: #86efac; border: 1px solid #166534; }
.banner b { display: block; }
.banner .line { font-size: 20px; font-weight: 700; margin: 4px 0; }
.set-cmp { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.set-was { font-size: 12px; color: var(--faint); }
.set-delta { font-size: 12px; font-weight: 700; color: #86efac; }
.set-delta.same { color: var(--muted); font-weight: 550; }
.pr-list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.pr-row {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px;
}
.pr-row .pr-line { font-size: 17px; font-weight: 700; color: #86efac; margin-top: 2px; }
.vol-weeks { display: flex; flex-direction: column; gap: 12px; margin: 0 0 16px; }
.vol-week {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.vol-week-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.vol-row {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 8px; align-items: center;
  margin-bottom: 6px; font-size: 13px;
}
.vol-row .track { height: 6px; background: #0f172a; border-radius: 99px; overflow: hidden; }
.vol-row .track i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.vol-row b { font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.tpl-chip {
  border: 1px solid var(--line); background: var(--card); color: #e2e8f0;
  border-radius: 999px; padding: 10px 14px; font-weight: 650;
}
.tpl-chip:disabled { opacity: .35; }
.rest-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.rest-preset {
  border: 0; border-radius: 8px; min-height: 32px; padding: 0 8px;
  background: #1e3a5f; color: #bfdbfe; font-weight: 650; font-size: 12px;
}
.rest-preset.on { background: #fff; color: #1d4ed8; }
.rest-fab.open { flex-wrap: wrap; max-width: calc(100vw - 28px); }

.kinds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.kinds button {
  background: #0f172a; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 8px 12px;
}
.kinds button.on { background: rgba(59,130,246,.18); color: #bfdbfe; border-color: var(--blue); }
.step { margin-bottom: 10px; }
.step span { display: block; color: var(--faint); font-size: 12px; margin-bottom: 6px; }
.step-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; gap: 8px; }
.step-row button {
  min-height: 56px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: 28px;
}
.step-row input { text-align: center; font-size: 28px; font-weight: 700; min-height: 56px; }
.note-input { margin: 8px 0 12px; }
.composer { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.composer-more-btn { width: 100%; text-align: center; margin: 4px 0 8px; color: #93c5fd; }
.composer-extra { display: none; }
.composer-extra.open { display: block; }
.composer-sticky {
  position: sticky; bottom: 0; z-index: 6;
  margin: 8px -12px -12px; padding: 10px 12px max(10px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, var(--card) 24%);
}
.session-nav {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center;
  margin: 0 0 12px;
}
.session-nav .btn { min-height: 40px; padding: 8px 10px; }
.session-nav .btn:disabled { opacity: .35; }
.rest-fab {
  position: fixed;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 24;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid #93c5fd;
  background: linear-gradient(160deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35), 0 10px 28px rgba(37, 99, 235, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  line-height: 1;
}
.rest-fab-ico { font-size: 13px; opacity: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.rest-fab b { font-size: 17px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.rest-fab.open {
  width: auto;
  min-width: 160px;
  height: auto;
  border-radius: 16px;
  padding: 10px 12px;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}
.rest-fab-info {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  margin-right: 4px;
}
.rest-fab-info span { font-size: 11px; color: #93c5fd; }
.rest-fab-info b { font-size: 22px; color: #fff; }
.rest-fab-skip, .rest-fab-min {
  border: 0; border-radius: 10px; min-height: 36px; padding: 0 10px;
  background: #2563eb; color: #fff; font-weight: 650;
}
.rest-fab-min { background: #334155; min-width: 36px; }
.bar-tip {
  margin: 0 0 8px; padding: 8px 12px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line); color: #f8fafc; font-size: 14px;
}
.bars .bar {
  appearance: none; border: 0; background: transparent; padding: 0; color: inherit;
  cursor: pointer;
}
.bars .bar.on i { outline: 2px solid #fff; }
.hist-box {
  margin-top: 16px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.hist-box summary { cursor: pointer; font-weight: 650; }
.feed-tools {
  display: flex; gap: 8px; align-items: center; margin: 0 0 12px;
}
.feed-filter { margin: 0; flex: 1; min-height: 44px; }
.feed-today { flex: none; white-space: nowrap; min-height: 44px; padding: 8px 10px; }
.ex-row-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 8px; overflow: hidden;
}
.ex-row-card.needs-group { border-color: #854d0e; }
.ex-row-main {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  text-align: left; background: none; border: 0; padding: 12px 14px; color: inherit;
}
.ex-row-name { font-weight: 700; grid-column: 1; }
.ex-row-meta { font-size: 12px; grid-column: 1; }
.ex-row-chev { grid-row: 1 / span 2; align-self: center; color: var(--faint); font-size: 18px; }
.ex-row-card .ex-card-fields { padding: 0 14px 14px; }
.check-line {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  color: var(--muted); font-size: 14px;
}
.effort { margin: 12px 0; }
.effort-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  color: var(--faint); font-size: 12px; margin-bottom: 8px;
}
.effort-head b { color: #f8fafc; font-size: 13px; }
.effort-scale {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px;
}
.effort-chip {
  min-height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: #0f172a; color: var(--muted); font-weight: 700; font-size: 15px;
}
.effort-chip.on { background: var(--blue-2); color: #fff; border-color: var(--blue); }
.effort-chip.easy.on { background: #166534; border-color: var(--green); }
.effort-chip.hard.on { background: #9a3412; border-color: #fb923c; }
.effort-hint {
  display: flex; justify-content: space-between; margin-top: 6px;
  color: var(--faint); font-size: 11px;
}
.effort-tag, .effort-mini {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px;
  background: rgba(251,146,60,.15); color: #fdba74; font-size: 12px; font-weight: 650;
}
.effort-mini { margin-left: 6px; padding: 1px 6px; font-size: 11px; }

.modal-back {
  position: fixed; inset: 0; background: rgba(2,6,23,.72); z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
}
.modal-back.center {
  align-items: center;
  padding: 16px;
}
.modal { width: min(560px, 100%); max-height: min(88dvh, 760px); overflow: auto; padding: 16px; }
.modal h2 { margin: 0 0 8px; }
.confirm-modal { max-width: 340px; text-align: center; margin: 0 auto; }
.confirm-modal p { margin: 0 0 16px; color: var(--text); font-size: 16px; line-height: 1.4; }
.confirm-modal .confirm-pass { text-align: left; margin: 0 0 12px; }
.confirm-modal .confirm-pass input { text-align: center; letter-spacing: 0.2em; font-size: 18px; }
.confirm-modal .err { margin: 0 0 12px; min-height: 1.2em; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confirm-actions .btn { min-height: 48px; font-size: 16px; }
.search { margin-bottom: 10px; }
.pick-item, .repeat-item {
  width: 100%; text-align: left; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; margin-bottom: 8px;
}
.pick-item small, .repeat-item small { display: block; color: var(--faint); margin-top: 4px; }
.group-label { color: var(--faint); font-size: 12px; margin: 10px 0 6px; }

.chart-wrap { height: 240px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.chart-wrap canvas { width: 100%; height: 220px; display: block; }
.switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.switch button { background: var(--card); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 8px 12px; }
.switch button.on { background: var(--blue-2); color: #fff; border-color: var(--blue); }

.bars {
  display: flex; align-items: flex-end; gap: 4px;
  height: 160px; margin-top: 8px; padding: 0 2px 28px;
  overflow: hidden; width: 100%; max-width: 100%; box-sizing: border-box;
}
.bar {
  flex: 1 1 0; min-width: 0; position: relative;
  display: flex; flex-direction: column; align-items: center;
  height: 100%; justify-content: flex-end; gap: 0;
}
.bar i {
  display: block; width: 100%; max-width: 24px;
  background: var(--blue); border-radius: 4px 4px 0 0; min-height: 2px;
}
.bar em {
  position: absolute; left: 50%; bottom: -22px;
  transform: translateX(-50%);
  font-style: normal; color: var(--faint); font-size: 9px; line-height: 1;
  white-space: nowrap; pointer-events: none;
}
.bar em.sparse { display: none; }

.cal { display: flex; flex-direction: column; gap: 3px; width: 100%; min-width: 0; overflow: hidden; }
.cal-row {
  display: grid;
  grid-template-columns: 20px repeat(21, minmax(0, 1fr));
  gap: 2px;
  align-items: center;
  width: 100%;
}
.cal-dow { color: var(--faint); font-size: 10px; line-height: 1; }
.cal-cell {
  width: 100%; aspect-ratio: 1; height: auto; min-width: 0;
  border-radius: 2px; background: #1e293b; border: 1px solid #334155; display: block;
}
.cal-cell.day-strength.lv1 { background: rgba(59,130,246,.35); border-color: transparent; }
.cal-cell.day-strength.lv2 { background: rgba(59,130,246,.62); border-color: transparent; }
.cal-cell.day-strength.lv3 { background: #3b82f6; border-color: transparent; }
.cal-cell.day-cardio.lv1 { background: rgba(34,197,94,.35); border-color: transparent; }
.cal-cell.day-cardio.lv2 { background: rgba(34,197,94,.62); border-color: transparent; }
.cal-cell.day-cardio.lv3 { background: #22c55e; border-color: transparent; }
.cal-cell.day-mix.lv1 { background: rgba(167,139,250,.35); border-color: transparent; }
.cal-cell.day-mix.lv2 { background: rgba(167,139,250,.62); border-color: transparent; }
.cal-cell.day-mix.lv3 { background: #a78bfa; border-color: transparent; }

.muscle { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.muscle-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.muscle-head span { color: var(--text); font-weight: 650; }
.muscle-head b { color: var(--muted); font-size: 14px; flex: none; }
.muscle .track { height: 8px; background: #0f172a; border-radius: 99px; overflow: hidden; }
.muscle .track i { display: block; height: 100%; background: var(--blue); }

.weight-form { padding: 14px; }
.weight-form .step-row { margin-top: 8px; }
.weight-form .btn { margin-top: 12px; }

.hist { padding: 8px 0 14px; border-bottom: 1px solid var(--line); }
.hist-date { color: #93c5fd; font-weight: 700; margin-bottom: 4px; }
.weight-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ex-row { display: grid; grid-template-columns: 1fr 120px 130px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ex-row button.link { background: none; border: 0; color: #f8fafc; text-align: left; font-weight: 650; }
select.slim { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; width: 100%; }
.settings-lead { margin: 0 0 14px; }
.settings-switch { margin: 0 0 16px; display: flex; width: 100%; }
.settings-switch button { flex: 1; }
.settings-card { padding: 16px; margin: 0 0 14px; }
.settings-h2 { margin: 0 0 8px; font-size: 18px; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.birth-row {
  display: grid; grid-template-columns: 1fr 1.2fr 1.2fr; gap: 8px; margin-top: 6px;
}
.birth-row select {
  min-height: 48px; width: 100%; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  padding: 8px 10px; font-size: 16px;
}
.age-live { margin-top: 8px; color: var(--muted); font-size: 14px; }
.age-live b { color: #f8fafc; }
.about-box {
  width: 100%; min-height: 140px; resize: vertical;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font: inherit; color: inherit; box-sizing: border-box;
}
.tip-line { font-size: 13px; margin: 0 0 14px; }
.ex-card-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.ex-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px;
}
.ex-card-title {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: #f8fafc; font-weight: 700; font-size: 16px; padding: 0; min-height: 40px;
}
.ex-card-meta { margin: 4px 0 10px; font-size: 13px; }
.ex-card-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field.mini { margin: 0; }
.field.mini select { min-height: 44px; }
.merge-box summary {
  cursor: pointer; font-weight: 700; font-size: 15px; padding: 4px 0;
}
.merge-box[open] summary { margin-bottom: 10px; }

.empty {
  margin: 24px auto; max-width: 460px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 24px; text-align: center;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.app-main { flex: 1; min-height: 0; min-width: 0; width: 100%; }

@media (min-width: 861px) {
  .mode-switch { align-self: flex-start; margin-left: max(16px, calc(50% - 280px)); }
}
@media (max-width: 860px) {
  :root { --tabbar: calc(56px + env(safe-area-inset-bottom, 0px)); }
  html {
    height: 100%;
    background: var(--bg);
  }
  html, body {
    overflow: hidden;
    width: 100%;
    max-width: 100%;
  }
  body {
    /* iOS: 100dvh часто короче экрана → полоса под таббаром */
    height: 100%;
    min-height: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    position: fixed;
    inset: 0;
    width: 100%;
  }
  #app {
    height: 100%;
    min-height: 100%;
    min-height: -webkit-fill-available;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
  }
  .app-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    width: 100%;
    max-width: 100%;
    padding-top: max(10px, env(safe-area-inset-top, 0px));
  }
  .topbar { display: none !important; }
  .tabbar {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    width: 100%; max-width: 100%; box-sizing: border-box;
    background: var(--card); border-top: 1px solid var(--line);
    /* safe-area только внутри таббара, без лишних 6px сверху отступа */
    padding: 6px 6px max(6px, env(safe-area-inset-bottom, 0px));
    gap: 4px;
  }
  .tabbar.is-hidden { display: none !important; }
  #app.nested {
    --tabbar: 0px;
  }
  .tabbar button {
    min-height: 44px; min-width: 0; background: transparent; border: 0;
    color: var(--muted); font-weight: 650; border-radius: 10px; font-size: 12px;
    padding: 6px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .tabbar button.on { background: var(--blue-2); color: #fff; }

  .feed {
    padding: 8px 12px calc(88px + var(--tabbar));
    max-width: none;
  }
  .feed-list { gap: 12px; }
  .fab {
    right: 14px;
    bottom: calc(14px + var(--tabbar));
    width: 54px;
    height: 54px;
    font-size: 30px;
  }
  .wcard {
    min-height: 88px; padding: 16px 12px 16px 16px; border-radius: 18px;
    gap: 12px;
  }
  .wcard-date { font-size: 13px; }
  .wcard-time { font-size: 12px; }
  .wcard-kind { font-size: 19px; }
  .wcard-meta { gap: 8px; font-size: 12px; }
  .wcard-chip { padding: 4px 10px; min-height: 26px; }
  .wcard-go { width: 36px; height: 36px; font-size: 24px; }
  .workout-detail { padding: 0 0 calc(28px + var(--tabbar)); max-width: none; }
  .workout-detail .column {
    border-radius: 0; border-left: 0; border-right: 0; min-height: calc(100dvh - var(--top) - var(--tabbar));
  }
  .workout-detail .col-head { padding: 12px 16px 10px; }
  .workout-detail .col-body { padding: 0 12px 12px; }
  .workout-detail .col-foot.sticky-foot {
    padding: 12px 12px max(12px, env(safe-area-inset-bottom, 0px));
  }
  .workout-detail .col-more { margin: 0 12px 16px; }
  .session { padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
  .workout-detail .back { font-size: 16px; min-height: 44px; padding: 8px 0; }
  .workout-detail .col-date { font-size: 15px; }
  .workout-detail .col-kind { font-size: 24px; }
  .workout-detail .ex {
    border-radius: 14px; margin-bottom: 10px;
  }
  .workout-detail .grip { display: none; }
  .workout-detail .ex-name { padding: 14px 14px 6px; font-size: 17px; min-height: 48px; }
  .workout-detail .ex-body { padding: 0 14px 10px; font-size: 16px; min-height: 44px; }
  .workout-detail .hint { margin: 0 14px 8px; }
  .workout-detail .copy-btn {
    margin: 10px 12px 0 0; min-height: 40px; padding: 8px 12px; font-size: 13px;
  }
  .workout-detail .add-set {
    width: calc(100% - 8px); margin: 0 4px 12px; min-height: 48px; font-size: 15px;
  }
  .mode-switch {
    display: flex; width: calc(100% - 24px); margin: 4px 12px 10px;
  }
  .mode-switch button { flex: 1; min-height: 44px; font-size: 15px; }
  .mcal-head h2 { font-size: 18px; }
  .mcal-cell { min-height: 48px; padding: 6px 4px; }
  .mcal-cell small { font-size: 10px; }

  .page {
    padding: 16px 12px calc(28px + var(--tabbar));
    max-width: none;
    width: 100%;
    overflow-x: hidden;
  }
  .page h1, .page-title { font-size: 22px; }
  .page h2, .section-title { font-size: 16px; margin: 22px 0 10px; }
  .totals { grid-template-columns: 1fr 1fr; gap: 8px; }
  .totals-2 { grid-template-columns: 1fr 1fr; }
  .totals-2 > .total:nth-child(3):last-child { grid-column: 1 / -1; }
  .total { padding: 12px; }
  .total b { font-size: 18px; }
  .stats-switch { width: 100%; }
  .stats-switch button { min-width: 0; font-size: 13px; padding: 8px 6px; }
  .stats-block { margin: 8px 0 18px; min-width: 0; }
  .ex-row { grid-template-columns: 1fr; }
  select.slim { width: 100%; min-height: 44px; }
  .profile-grid { grid-template-columns: 1fr; }
  .birth-row { grid-template-columns: 1fr 1.15fr 1.15fr; gap: 6px; }
  .ex-card-fields { grid-template-columns: 1fr; }
  .settings-switch { width: 100%; margin-bottom: 14px; }
  .settings-page .mode-switch { width: 100%; margin: 0 0 14px; }
  .session { padding: 12px 12px calc(28px + var(--tabbar)); max-width: none; }
  .session h1 { font-size: 22px !important; overflow-wrap: anywhere; }
  .row-actions { flex-direction: column; }
  .row-actions .btn, .row-actions .btn-ghost { width: 100%; min-height: 44px; text-align: center; }
  .col-foot .btn, .col-foot .btn-ghost { min-height: 44px; }
  .switch { gap: 8px; }
  .switch button { min-height: 40px; flex: 1 1 calc(33% - 8px); text-align: center; }
  .bars { height: 140px; padding-bottom: 22px; gap: 2px; }
  .bar em { font-size: 8px; bottom: -18px; }
  .cal {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cal-row {
    gap: 2px;
    min-width: 0;
    grid-template-columns: 16px repeat(21, minmax(0, 1fr));
  }
  .cal-dow { font-size: 9px; }
  .chart-wrap { width: 100%; max-width: 100%; overflow: hidden; }
  .weight-form .step-row { grid-template-columns: 56px minmax(0, 1fr) 56px; }
  .login-wrap { height: 100%; overflow-y: auto; }
  .login-stage { min-height: 100%; }
  .login-wrap .login-card { padding: 24px 18px 28px; margin-top: -28px; }
  .empty { margin: 16px 12px; }
}
