/* Оформление как в iOS-приложении: тёмная база, оранжевый акцент, крупные цифры. */
:root {
  --bg: #000;
  --card: #1c1c1e;
  --card-2: #2c2c2e;
  --sep: #2c2c2e;
  --text: #fff;
  --muted: #a1a1a6;
  --muted-2: #8e8e93;
  --faint: #636366;
  --accent: #ff8a3d;
  --accent-ink: #000;
  --accent-soft: #2a1a0e;
  --success: #38c770;
  --warning: #ffd60a;
  --danger: #ff6961;
  --record: #ffc733;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  color: var(--text);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; }

/* Широкий экран (компьютер): приложение по центру, шириной телефона. */
#app { max-width: 480px; margin: 0 auto; min-height: 100%; position: relative; }

.splash { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.logo { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }
.logo span, .accent { color: var(--accent); }
.muted { color: var(--muted); }
.faint { color: var(--muted-2); }
.num { font-variant-numeric: tabular-nums; }

/* Экран: вкладка или экран из стека. */
.screen {
  min-height: 100vh;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 40px);
  display: flex; flex-direction: column; gap: 16px;
}
.screen.plain { padding-bottom: calc(var(--safe-bottom) + 32px); }
.stack-layer { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto;
  -webkit-overflow-scrolling: touch; max-width: 480px; margin: 0 auto; animation: slide-in .22s ease-out; }
@keyframes slide-in { from { transform: translateX(24px); } to { transform: none; } }

.tab-head { display: flex; flex-direction: column; gap: 4px; }
.tab-head-row { display: flex; justify-content: flex-end; min-height: 44px; }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; }
.subtitle { color: var(--muted); font-size: 17px; }
.coach-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; margin-bottom: 4px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.subtitle-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.streak { display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; }
.section-title { font-size: 20px; font-weight: 600; }
.caps { font-size: 13px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .4px; padding: 6px 4px 0; }

.topbar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.topbar-title { font-size: 17px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; gap: 8px; }

.round-btn { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar-btn { width: 44px; height: 44px; border-radius: 22px; border: 2px solid var(--accent); background: var(--card);
  font-size: 17px; font-weight: 600; }

/* Карточки и списки */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; }
.card.tight { padding: 0; }
.group { background: var(--card); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 48px; border: none;
  background: none; width: 100%; text-align: left; }
.row + .row { border-top: 1px solid var(--sep); }
button.row:disabled { opacity: .4; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-sub { font-size: 13px; color: var(--muted-2); }
.row-value { color: var(--muted); font-size: 15px; }
.row .icon.chev { color: var(--faint); }
.row-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { display: flex; flex-direction: column; gap: 8px; }
.empty-title { font-weight: 600; }

/* Кнопки */
.btn { height: 54px; border-radius: 27px; border: none; width: 100%; font-size: 17px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-start { background: var(--accent); color: #fff; height: 50px; border-radius: 25px; font-size: 18px; }
.btn-secondary { background: var(--card-2); color: var(--text); }
.btn-white { background: #fff; color: #000; }
.btn-danger { background: var(--danger); color: #000; }
.btn-plain { background: none; color: var(--muted); height: 48px; }
.btn:disabled { opacity: .5; }
.pill { height: 40px; padding: 0 18px; border-radius: 20px; border: none; font-size: 15px; font-weight: 600; }
.pill-success { background: var(--success); color: #000; }
.link-btn { border: none; background: none; color: var(--accent); font-size: 17px; padding: 6px 0;
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; }

/* Формы */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.input { height: 52px; border-radius: 12px; border: none; background: var(--card); color: var(--text);
  font-size: 17px; padding: 0 16px; width: 100%; }
.input::placeholder, .num-input::placeholder { color: var(--muted-2); }
.error { color: var(--danger); font-size: 15px; }
.info { color: var(--success); font-size: 15px; }
.check-row { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.35; }
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; margin: 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: 15px; }
.divider::before, .divider::after { content: ''; height: 1px; background: var(--sep); flex: 1; }

/* Нижнее меню */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); width: calc(min(100vw, 480px) - 24px);
  bottom: calc(var(--safe-bottom) + 12px); height: var(--tabbar-h); border-radius: 32px; background: rgba(28,28,30,.94);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border: 1px solid var(--sep);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; z-index: 10; }
.tab { border: none; background: none; color: var(--muted); font-size: 11px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; height: 100%; justify-content: center; position: relative; }
.tab.active { color: var(--accent); }
.tab-center { width: 52px; height: 52px; border-radius: 26px; background: var(--accent); color: #fff; margin-top: -26px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 0 24px rgba(255,138,61,.35); }
.tab.active .tab-center { border: 2px solid #fff; }
/* Счётчик у обычной вкладки — у правого края значка. */
.tab:not(.tab-main) .badge { top: 6px; right: calc(50% - 22px); }
.tab-main { color: var(--accent); font-weight: 600; }
.badge { position: absolute; top: 4px; right: calc(50% - 26px); min-width: 18px; height: 18px; border-radius: 9px;
  background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; padding: 0 5px; }

/* Лист снизу */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: flex;
  align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { width: 100%; max-width: 480px; background: var(--card); border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(var(--safe-bottom) + 16px); max-height: 85vh; overflow-y: auto; display: flex;
  flex-direction: column; gap: 10px; animation: rise .2s ease-out; }
.sheet-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
/* Содержимое листа не сжимается, а прокручивается: иначе длинный список
   упражнений обрезался, а ряд групп мышц схлопывался в полоску. */
.sheet > * { flex-shrink: 0; }
.sheet { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet .chips { min-height: 34px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 96px);
  background: #3a3a3c; color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; z-index: 50;
  max-width: calc(100vw - 32px); text-align: center; }

.banner { background: var(--card-2); border-radius: 12px; padding: 10px 14px; display: flex; align-items: center;
  gap: 10px; font-size: 15px; }
.hint-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted-2); justify-content: center; }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--card-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Сегодня */
.plan-card { border-radius: 20px; display: flex; flex-direction: column; gap: 12px; }
.plan-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.plan-title { font-size: 20px; font-weight: 700; }
.plan-meta { font-size: 15px; color: var(--muted); text-align: right; white-space: nowrap; }
.plan-ex { display: flex; gap: 14px; font-size: 15px; }
.plan-ex b { color: var(--accent); min-width: 24px; }
.resume-card { border: 1px solid var(--accent); }
.progress { height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

/* Тренировка */
.workout-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.workout-title { font-size: 22px; font-weight: 700; }
.ex-card { border-radius: 20px; display: flex; flex-direction: column; gap: 10px; }
.ex-card.current { box-shadow: inset 0 0 0 1.5px var(--accent); }
.ex-name { font-size: 17px; font-weight: 600; color: var(--accent); border: none; background: none; text-align: left; padding: 0; }
.ex-top { display: flex; align-items: flex-start; gap: 8px; }
.ex-top .ex-name { flex: 1; }
.superset-tag { font-size: 12px; font-weight: 600; color: #9e78f0; }
.set-grid { display: grid; grid-template-columns: 34px minmax(0, 1fr) 72px 60px 44px; gap: 8px; align-items: center; }
.set-head { font-size: 13px; color: var(--muted); }
.set-row { border-radius: 10px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.set-row.done { background: rgba(56,199,112,.12); }
.set-no { font-weight: 600; padding-left: 4px; border: none; background: none; text-align: left; }
.set-no.warm { color: var(--warning); }
.set-prev { color: var(--muted-2); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num-input { height: 38px; border-radius: 8px; border: none; background: var(--card-2); color: var(--text); width: 100%;
  text-align: center; font-size: 17px; font-variant-numeric: tabular-nums; padding: 0 4px; }
.check-btn { width: 40px; height: 38px; border-radius: 8px; border: none; background: var(--card-2); color: var(--faint);
  display: flex; align-items: center; justify-content: center; }
.check-btn.on { background: var(--success); color: #000; }
.record-mark { color: var(--record); font-size: 12px; font-weight: 700; }

.rest-bar { position: fixed; left: 50%; transform: translateX(-50%); width: calc(min(100vw, 480px) - 24px);
  bottom: calc(var(--safe-bottom) + 12px); border-radius: 24px; background: rgba(28,28,30,.96); border: 1px solid var(--sep);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; z-index: 30;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.rest-row { display: flex; align-items: center; justify-content: space-between; }
.rest-time { font-size: 34px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; text-align: center; }
.rest-btn { width: 60px; height: 44px; border-radius: 22px; border: none; background: var(--card-2); font-size: 15px; }

/* Установка */
.install { min-height: 100vh; display: flex; flex-direction: column; padding: calc(var(--safe-top) + 48px) 20px 160px; gap: 24px; }
.install-hero { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.app-icon { width: 84px; height: 84px; border-radius: 20px; }
.step-no { width: 32px; height: 32px; border-radius: 16px; background: var(--accent); color: #000; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.install-arrow { position: fixed; bottom: calc(var(--safe-bottom) + 8px); left: 50%; transform: translateX(-50%);
  color: var(--accent); animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 8px; } }

.summary-hero { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 24px 0 8px; }
.summary-hero .trophy { width: 88px; height: 88px; border-radius: 44px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; }

.ex-thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--card-2); flex-shrink: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 34px; padding: 0 14px; border-radius: 17px; border: none; background: var(--card); color: var(--text);
  font-size: 15px; white-space: nowrap; flex-shrink: 0; }
.chip.on { background: var(--accent); color: #000; font-weight: 600; }
.weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.weekdays .chip { padding: 0; }

/* Чат */
.chat-layer { display: flex; flex-direction: column; overflow: hidden; }
.chat-head { padding: calc(var(--safe-top) + 12px) 16px 8px; border-bottom: 1px solid var(--sep); }
.chat-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.bubble { display: flex; }
.bubble.mine { justify-content: flex-end; }
.bubble-body { max-width: 80%; background: var(--card); border-radius: 18px; padding: 8px 12px; display: flex; flex-direction: column;
  gap: 4px; border: none; text-align: left; font-size: 16px; line-height: 1.35; }
.bubble.mine .bubble-body { background: #3a2412; }
.bubble.pending .bubble-body { opacity: .75; }
.bubble-time { font-size: 11px; color: var(--muted-2); align-self: flex-end; }
.bubble-quote { font-size: 13px; color: var(--muted); border-left: 2px solid var(--accent); padding-left: 8px; }
.msg-media { width: 100%; max-width: 260px; border-radius: 12px; display: block; object-fit: cover; background: var(--card-2); }
.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px calc(var(--safe-bottom) + 8px); border-top: 1px solid var(--sep); background: var(--bg); }
.chat-text { height: 44px; min-height: 44px; border-radius: 22px; padding: 11px 16px; resize: none; line-height: 1.3; }
.card .chip { background: var(--card-2); }
.card .chip.on { background: var(--accent); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--card); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { border: none; background: none; height: 36px; border-radius: 9px; font-size: 13px; color: var(--muted); padding: 0 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.segmented button.on { background: var(--card-2); color: var(--text); font-weight: 600; }
/* Поиск и группы мышц остаются наверху листа, пока список прокручивается. */
.sheet-sticky { position: sticky; top: -20px; z-index: 1; background: var(--card); margin: 0 -16px; padding: 8px 16px 10px;
  display: flex; flex-direction: column; gap: 10px; }
.sheet-sticky .chip { background: var(--card-2); }
.sheet-sticky .chip.on { background: var(--accent); }
/* Отметка выбранного упражнения: номер — порядок, в котором оно встанет. */
.pick-mark { width: 24px; height: 24px; border-radius: 12px; border: 2px solid var(--faint); flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #000; }
.pick-mark.on { background: var(--accent); border-color: var(--accent); }
/* Кнопка «Добавить» — внизу, ближе к пальцу, и не уезжает при прокрутке. */
.sheet-confirm { position: sticky; bottom: calc(-16px - var(--safe-bottom)); background: var(--card); margin: 0 -16px;
  padding: 10px 16px calc(var(--safe-bottom) + 16px); z-index: 1; }
/* Панель над клавиатурой при вводе веса и повторов — как в iOS. */
.keyboard-bar { position: fixed; left: 50%; transform: translateX(-50%); width: min(100vw, 480px); z-index: 35;
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #2c2c2e; border-top: 1px solid #3a3a3c; }
.keyboard-bar button { height: 36px; min-width: 52px; padding: 0 10px; border-radius: 8px; border: none; background: #48484a;
  color: var(--text); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.keyboard-bar .kb-wide { font-size: 13px; font-weight: 500; white-space: nowrap; }
.keyboard-bar .kb-done { background: none; color: var(--accent); }
.superset-badge { font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 999px; background: rgba(255,138,61,.2);
  color: var(--accent); white-space: nowrap; flex-shrink: 0; }
/* Панель отдыха сверху экрана тренировки — как в iOS. */
.rest-top { position: fixed; left: 50%; transform: translateX(-50%); width: min(100vw, 480px); top: 0; z-index: 30;
  padding: calc(var(--safe-top) + 10px) 16px 10px; display: flex; flex-direction: column; gap: 8px;
  background: rgba(28,28,30,.94); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-bottom: 1px solid var(--sep); }
.rest-top .rest-row { gap: 10px; }
.rest-top .rest-time { font-size: 32px; line-height: 1.1; }
.rest-top .rest-btn { width: 52px; height: 40px; }

/* Пояснение под группой, как footer секции в iOS. */
.footnote { font-size: 13px; line-height: 1.35; color: var(--muted-2); padding: 0 16px; margin-top: -6px; }
.stepper { display: inline-flex; border-radius: 9px; overflow: hidden; background: var(--card-2); flex-shrink: 0; }
.stepper button { width: 46px; height: 32px; border: none; background: none; color: var(--text); font-size: 20px; line-height: 1; }
.stepper button + button { border-left: 1px solid var(--sep); }
.stepper button:disabled { color: var(--faint); }

.muscle-chip { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.muscle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.muscle-grid .chip { justify-content: center; font-size: 13px; }
.select { background: none; border: none; color: var(--accent); font: inherit; font-size: 15px; text-align: right; max-width: 55%; }
.step-no { width: 22px; height: 22px; border-radius: 11px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.sheet .muscle-grid .chip:not(.on) { background: var(--card-2); }
.chat-quote { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px 0; border-top: 1px solid var(--sep); background: var(--bg); }
.chat-quote + .chat-input { border-top: none; }
.chat-quote .bubble-quote { flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Помощник */
.coach-report { display: flex; flex-direction: column; gap: 8px; text-align: left; border: 1.5px solid transparent; color: inherit; }
.coach-report.unread { background: var(--accent-soft); border-color: rgba(255,138,61,.55); }
.coach-invite { display: flex; align-items: center; gap: 12px; text-align: left; border: none; color: inherit; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--accent); flex-shrink: 0; display: inline-block; }
.coach-hero { width: 72px; height: 72px; border-radius: 36px; margin: 12px auto 0; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); }
.goal-tile { display: flex; flex-direction: column; gap: 4px; text-align: left; min-height: 86px; border: 1.5px solid transparent; color: inherit; }
.goal-tile.on { background: var(--accent-soft); border-color: var(--accent); }
.goal-input { width: 70px; background: none; border: none; color: var(--text); font-size: 17px; font-weight: 600; text-align: right; }
