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

:root {
  --bg: #0b0b0d;
  --bg-card: #18181c;
  --bg-elevated: #1f1f24;
  --border: rgba(255,255,255,0.08);
  --text: #f2f0ec;
  --text-muted: #a8a6a1;
  --accent: #b6142e;
  --accent-dark: #7d0e20;
  --gold: #c9a24b;
  --green: #4fd18b;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, sans-serif;
  padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}

.screen { display: none; padding: 12px; }
.screen.active { display: block; }

h2 { font-family: "Bebas Neue", "Montserrat", sans-serif; font-size: 1.5rem; margin-bottom: 12px; letter-spacing: 0.5px; }
h3 { font-size: 0.8rem; color: var(--gold); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }

.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.widget-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; margin-bottom: 10px; flex-wrap: wrap; gap: 6px; }

.bar { height: 8px; background: rgba(255,255,255,0.06); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; }

.ring-wrap { position: relative; width: 92px; height: 92px; margin: 0 auto 12px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 8; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 264; stroke-dashoffset: 264; transition: stroke-dashoffset 0.4s ease;
}
.ring-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 700; }

/* Кастомный чекбокс вместо системного + зачёркивания */
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.checklist-item:last-child { border-bottom: none; }
.checkbox {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--text-muted);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer;
}
.checkbox.checked { background: var(--green); border-color: var(--green); }
.checkbox.checked::after { content: '✓'; color: #0c0c10; font-size: 0.9rem; font-weight: 900; }
.checklist-item span { font-size: 0.95rem; }

.streaks { display: flex; gap: 16px; }
.streak { flex: 1; text-align: center; }
.streak-num { display: block; font-family: "Bebas Neue", sans-serif; font-size: 1.9rem; color: var(--gold); }
.streak-label { font-size: 0.72rem; color: var(--text-muted); }

textarea, input[type="text"], input[type="number"] {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-family: inherit; font-size: 0.9rem; margin-bottom: 8px;
}
textarea { min-height: 60px; resize: none; }

.btn {
  display: block; width: 100%; padding: 12px; border-radius: 10px; border: none;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:active { background: var(--accent-dark); }

/* Фокус дня — статичный текст + маленький плюс */
.btn-plus {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-size: 1.1rem; cursor: pointer; flex-shrink: 0;
}
.static-text { font-size: 0.9rem; color: var(--text); white-space: pre-wrap; }
.hidden { display: none !important; }

/* Колёсный тайм-пикер */
.wheel-picker { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 10px 0; }
.wheel {
  height: 120px; width: 60px; overflow-y: scroll; scroll-snap-type: y mandatory;
  border-radius: 10px; background: var(--bg);
}
.wheel::-webkit-scrollbar { display: none; }
.wheel-item {
  height: 40px; display: flex; align-items: center; justify-content: center;
  scroll-snap-align: center; font-size: 1.1rem; color: var(--text-muted);
}
.wheel-item.center { color: var(--text); font-weight: 700; font-size: 1.3rem; }
.wheel-colon { font-size: 1.3rem; font-weight: 700; }

.reminder-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.reminder-item:last-child { border-bottom: none; }
.reminder-item .del-btn { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; }

/* Тренировки — раскрывающиеся блоки */
.section-block { margin-bottom: 12px; }
.block-header {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; cursor: pointer;
}
.chevron { transition: transform 0.2s ease; color: var(--text-muted); }
.block-body { max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
.block-body.open { max-height: 2000px; margin-top: 10px; }
.block-header.open .chevron { transform: rotate(90deg); }

.exercise-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.exercise-row:last-child { border-bottom: none; }
.exercise-row.done .exercise-name { color: var(--text-muted); }
.exercise-name { flex: 1; font-size: 0.9rem; }
.exercise-meta { font-size: 0.78rem; color: var(--text-muted); }

.timer { text-align: center; font-size: 2.4rem; font-weight: 700; margin-bottom: 14px; }

.strength-group { margin-bottom: 14px; }
.strength-group h4 { font-size: 0.85rem; color: var(--gold); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.strength-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.strength-row input { width: 70px; text-align: right; margin-bottom: 0; padding: 6px 8px; }

.food-totals { display: flex; justify-content: space-between; font-size: 0.85rem; }
.food-totals span b { display: block; font-family: "Bebas Neue", sans-serif; font-size: 1.3rem; color: var(--gold); }
.meal-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.meal-item:last-child { border-bottom: none; }
.food-result-item { padding: 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 0.85rem; }
.food-result-item:hover { background: var(--bg-elevated); }
.gram-prompt { display: flex; gap: 8px; margin-top: 8px; }
.gram-prompt input { margin-bottom: 0; }

.weight-chart { width: 100%; height: 120px; }
.weight-chart path { fill: none; stroke: var(--accent); stroke-width: 2; }
.weight-chart circle { fill: var(--accent); }
.weight-input-row { display: flex; gap: 8px; align-items: center; }
.weight-input-row input { margin-bottom: 0; }
.weight-input-row .btn { width: auto; padding: 10px 16px; }

/* Чат */
.chat-layout { position: relative; height: calc(100vh - 70px - env(safe-area-inset-bottom, 0px)); display: flex; }

.chat-list-toggle {
  position: absolute; top: 0; left: 0; z-index: 10;
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  font-size: 1rem; cursor: pointer;
}

.chat-sidebar {
  position: absolute; top: 0; left: 0; bottom: 0; z-index: 9;
  width: 200px; background: var(--bg-card); border-right: 1px solid var(--border);
  padding: 52px 10px 12px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto;
}
.chat-sidebar.hidden { display: none; }

.btn-new-chat { background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 10px 6px; font-size: 0.8rem; cursor: pointer; }
.chat-list { display: flex; flex-direction: column; gap: 6px; }
.chat-list-item {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; font-size: 0.78rem; cursor: pointer; display: flex; justify-content: space-between; gap: 6px;
}
.chat-list-item.active { border-color: var(--accent); }
.chat-list-item .title { flex: 1; word-break: break-word; }
.chat-list-item .chat-actions { display: flex; gap: 4px; flex-shrink: 0; }
.chat-list-item .chat-actions button { background: none; border: none; color: var(--text-muted); font-size: 0.85rem; cursor: pointer; padding: 0 2px; }

.chat-main { flex: 1; display: flex; flex-direction: column; padding: 52px 12px 12px; min-width: 0; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 0.88rem; line-height: 1.4; }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.chat-msg.assistant { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); }

.chat-input-row { display: flex; gap: 8px; align-items: stretch; flex-shrink: 0; }
.chat-input-row textarea { flex: 1; margin-bottom: 0; min-height: 44px; max-height: 44px; resize: none; }
.chat-input-row .btn { width: 44px; height: 44px; padding: 0; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

#bottomNav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 100;
}
.nav-btn { flex: 1; background: none; border: none; color: var(--text-muted); padding: 14px 0; font-size: 0.8rem; cursor: pointer; }
.nav-btn.active { color: var(--accent); font-weight: 600; }

.exercise-row .checkbox { flex-shrink: 0; }

/* Универсальный баннер вместо tg.showAlert — виден и в браузере, и в Telegram */
#notifyBanner {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 12px; right: 12px;
  z-index: 999;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.85rem;
  text-align: center;
  transform: translateY(-120%);
  transition: transform 0.25s ease;
  margin-top: 8px;
}
#notifyBanner.show { transform: translateY(0); }

.checklist-item .goal-del {
  margin-left: auto;
  display: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.85rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.checklist-item .goal-del:active { background: var(--accent); color: #fff; }
#checklistItems.edit-mode .goal-del { display: flex; }

.home-header-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}
#todayDate { color: var(--text); font-weight: 600; }
#todayWorkoutStatus { color: var(--gold); font-size: 0.8rem; }