:root {
  --green: #58CC02;
  --green-dark: #4CAD02;
  --green-light: #D7FFB8;
  --green-bg: #F0FFF0;
  --blue: #1CB0F6;
  --blue-dark: #1899D6;
  --blue-light: #DDF4FF;
  --red: #FF4B4B;
  --red-light: #FFE0E0;
  --orange: #FF9600;
  --orange-light: #FFF3E0;
  --purple: #CE82FF;
  --purple-dark: #A855F7;
  --purple-light: #F3E8FF;
  --yellow: #FFC800;
  --yellow-light: #FFF9DB;
  --gray-50: #F7F7F7;
  --gray-100: #E5E5E5;
  --gray-200: #D1D1D1;
  --gray-300: #AFAFAF;
  --gray-400: #8A8A8A;
  --gray-500: #6B6B6B;
  --gray-600: #4B4B4B;
  --gray-700: #3A3A3A;
  --white: #FFFFFF;
  --bg: #F7F7F7;
  --card: #FFFFFF;
  --text: #3C3C3C;
  --text-dim: #AFAFAF;
  --shadow: 0 2px 0 0;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  padding-bottom: 70px;
  overflow-x: hidden;
}

/* ===== TOP BAR ===== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 2px solid var(--gray-100);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 17px;
  color: var(--orange);
}

.streak-badge .flame { font-size: 22px; }

.weight-badge {
  font-weight: 800;
  font-size: 15px;
  color: var(--green);
  background: var(--green-light);
  padding: 4px 12px;
  border-radius: 20px;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--white);
  border-top: 2px solid var(--gray-100);
  display: flex;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: transform 0.15s;
  font-family: 'Nunito', sans-serif;
}

.nav-item:active { transform: scale(0.9); }

.nav-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 18px;
  transition: all 0.2s;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--gray-300);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}

.nav-item.active .nav-icon {
  background: var(--green);
  color: white;
  border-radius: 10px;
  transform: scale(1.1);
}

.nav-item.active .nav-label { color: var(--green); }

/* ===== PAGES ===== */
.page { display: none; padding: 16px; animation: pageIn 0.25s ease; }
.page.active { display: block; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== SECTION TITLE ===== */
.section-title {
  font-size: 22px;
  font-weight: 900;
  margin: 8px 0 16px;
  color: var(--text);
}

.section-subtitle {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 20px 0 10px;
}

/* ===== TRAINING DAY CARDS ===== */
.day-card {
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 12px;
  border: 2px solid var(--gray-100);
  overflow: hidden;
  transition: border-color 0.2s;
}

.day-card.today { border-color: var(--green); }

.day-header {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  user-select: none;
}

.day-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.day-badge.push { background: var(--blue); box-shadow: var(--shadow) var(--blue-dark); }
.day-badge.pull { background: var(--green); box-shadow: var(--shadow) var(--green-dark); }
.day-badge.legs { background: var(--orange); box-shadow: 0 2px 0 0 #d97f00; }
.day-badge.rest { background: var(--gray-200); box-shadow: 0 2px 0 0 var(--gray-300); }

.day-info { flex: 1; }
.day-name { font-weight: 800; font-size: 16px; }
.day-muscles { font-size: 12px; color: var(--text-dim); font-weight: 600; margin-top: 2px; }

.day-progress {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--gray-300);
  flex-shrink: 0;
  transition: all 0.3s;
}

.day-progress.done { border-color: var(--green); color: var(--green); background: var(--green-light); }

.day-arrow {
  font-size: 14px;
  color: var(--gray-300);
  transition: transform 0.3s;
  flex-shrink: 0;
}

.day-card.open .day-arrow { transform: rotate(180deg); }

.day-body {
  display: none;
  padding: 0 16px 16px;
}

.day-card.open .day-body { display: block; }

/* ===== EXERCISE ROWS ===== */
.exercise-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 2px solid transparent;
  transition: all 0.2s;
  cursor: pointer;
}

.exercise-row:active { transform: scale(0.98); }
.exercise-row.completed { border-color: var(--green); background: var(--green-light); }

.ex-check {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2.5px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 14px;
  color: transparent;
}

.exercise-row.completed .ex-check {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.ex-info { flex: 1; min-width: 0; }
.ex-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-detail { font-size: 11px; color: var(--text-dim); font-weight: 600; margin-top: 1px; }

.ex-sets-reps { display: flex; gap: 6px; flex-shrink: 0; }

.ex-pill {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.ex-pill.sets { background: var(--blue-light); color: var(--blue-dark); }
.ex-pill.reps { background: var(--orange-light); color: var(--orange); }

.ex-edit-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}

.ex-edit-btn:active { background: var(--gray-100); }

.add-exercise-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-sm);
  background: none;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-300);
  cursor: pointer;
  transition: all 0.2s;
}

.add-exercise-btn:active { border-color: var(--green); color: var(--green); }

/* ===== MEAL CARDS ===== */
.meal-card {
  background: var(--card);
  border: 2px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
  cursor: pointer;
}

.meal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.meal-time-badge {
  background: var(--green);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 2px 0 0 var(--green-dark);
}

.meal-kcal { font-weight: 800; font-size: 14px; color: var(--orange); }
.meal-title { font-weight: 800; font-size: 16px; margin-bottom: 6px; }
.meal-desc { font-size: 13px; color: var(--gray-500); line-height: 1.6; font-weight: 600; }

.macro-pills { display: flex; gap: 8px; margin-top: 12px; }

.macro-pill {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
}

.macro-pill.protein { background: var(--red-light); color: var(--red); }
.macro-pill.carbs { background: var(--yellow-light); color: #B8860B; }
.macro-pill.fat { background: var(--blue-light); color: var(--blue-dark); }

.daily-total {
  background: linear-gradient(135deg, var(--green), #45B800);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: white;
  margin: 16px 0;
  box-shadow: 0 4px 0 0 #3A9600;
}

.daily-total .big-num { font-size: 48px; font-weight: 900; line-height: 1; }
.daily-total .big-label { font-size: 13px; font-weight: 700; opacity: 0.85; margin-top: 4px; }

.daily-total-macros { display: flex; justify-content: center; gap: 20px; margin-top: 14px; }
.dtm { text-align: center; }
.dtm .dtm-val { font-size: 24px; font-weight: 900; }
.dtm .dtm-label { font-size: 10px; font-weight: 700; opacity: 0.75; text-transform: uppercase; }

/* ===== CALENDAR ===== */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-month { font-size: 20px; font-weight: 900; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.cal-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 4px 0;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  position: relative;
}

.cal-day.empty { cursor: default; }
.cal-day.today { border-color: var(--tg-theme-button-color, var(--green)); }
.cal-day.gym { background: var(--tg-theme-button-color, var(--green)); color: white; opacity: 0.9; }
.cal-day.rest { background: var(--gray-100); color: var(--gray-400); }
.cal-day.activity { background: var(--blue-light); color: var(--blue-dark); }
.cal-day.future { color: var(--gray-200); }
.cal-day:active:not(.empty):not(.future) { transform: scale(0.9); }

/* Calendar legend */
.cal-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
}
.cal-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.cal-legend-dot.gym { background: var(--tg-theme-button-color, var(--green)); }
.cal-legend-dot.activity { background: var(--blue); }
.cal-legend-dot.rest { background: var(--gray-200); }
.cal-legend-dot.photo { background: var(--purple); }

/* Recent day cards (checkin page) */
.recent-day-card {
  padding: 12px;
  border-radius: 10px;
  background: var(--gray-50);
  margin-bottom: 8px;
}
.recent-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.recent-day-date {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.recent-day-weight {
  font-weight: 800;
  font-size: 14px;
  color: var(--green);
}
.recent-day-details {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 600;
}
.recent-day-notes {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
  font-weight: 600;
}

/* Streak card */
.streak-card {
  background: linear-gradient(135deg, var(--orange), #E68500);
  border-radius: var(--radius);
  padding: 20px;
  color: white;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: 0 4px 0 0 #CC7600;
}

.streak-flame { font-size: 40px; margin-bottom: 8px; }
.streak-num { font-size: 48px; font-weight: 900; line-height: 1; }
.streak-label { font-size: 14px; font-weight: 700; opacity: 0.85; margin-top: 4px; }

/* Quote card */
.quote-card {
  background: linear-gradient(135deg, var(--purple), #A855F7);
  border-radius: var(--radius);
  padding: 24px 20px;
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 4px 0 0 #8B3DD4;
  position: relative;
  overflow: hidden;
}

.quote-card::before {
  content: '\201C';
  position: absolute;
  top: -10px;
  left: 10px;
  font-size: 80px;
  opacity: 0.15;
  font-weight: 900;
}

.quote-text { font-size: 16px; font-weight: 700; line-height: 1.5; position: relative; z-index: 1; }
.quote-source { font-size: 12px; font-weight: 600; opacity: 0.8; margin-top: 10px; }

/* Day status buttons */
.day-status-btns { display: flex; gap: 8px; margin: 16px 0; }

.status-btn {
  flex: 1;
  padding: 14px 8px;
  border: 2.5px solid var(--gray-100);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  text-align: center;
  font-family: 'Nunito', sans-serif;
  transition: all 0.2s;
}

.status-btn:active { transform: scale(0.95); }
.status-btn .status-icon { font-size: 24px; margin-bottom: 4px; }
.status-btn .status-text { font-size: 11px; font-weight: 800; color: var(--gray-400); }

.status-btn.active-gym { border-color: var(--green); background: var(--green-light); }
.status-btn.active-gym .status-text { color: var(--green-dark); }
.status-btn.active-no { border-color: var(--red); background: var(--red-light); }
.status-btn.active-no .status-text { color: var(--red); }
.status-btn.active-act { border-color: var(--blue); background: var(--blue-light); }
.status-btn.active-act .status-text { color: var(--blue-dark); }

/* ===== CHECK-IN ===== */
.checkin-card {
  background: var(--card);
  border: 2px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

.checkin-title { font-weight: 800; font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.checkin-input-row { display: flex; gap: 10px; margin-bottom: 10px; }
.checkin-input { flex: 1; position: relative; }

.checkin-input label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.checkin-input input, .checkin-input select {
  width: 100%;
  padding: 12px;
  border: 2.5px solid var(--gray-100);
  border-radius: var(--radius-xs);
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 700;
  background: var(--gray-50);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.checkin-input input:focus, .checkin-input select:focus { border-color: var(--green); }

.checkin-input .unit {
  position: absolute;
  right: 14px;
  bottom: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  pointer-events: none;
}

.save-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--green);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 0 var(--green-dark);
  transition: all 0.1s;
  margin-top: 8px;
}

.save-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 0 var(--green-dark); }
.save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== WEIGHT CHART ===== */
.chart-container {
  background: var(--card);
  border: 2px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.chart-title { font-weight: 800; font-size: 15px; margin-bottom: 12px; }

.mini-chart { height: 120px; display: flex; align-items: flex-end; gap: 4px; padding: 0 4px; }

.chart-bar {
  flex: 1;
  border-radius: 6px 6px 0 0;
  min-height: 8px;
  transition: height 0.3s;
  position: relative;
}

.chart-bar .bar-val {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 800;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ===== STATS CARDS ===== */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }

.stat-card {
  background: var(--card);
  border: 2px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-val { font-size: 28px; font-weight: 900; line-height: 1; }
.stat-label { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; margin-top: 4px; }

/* ===== AI CHAT ===== */
.ai-fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.ai-fab:active { transform: scale(0.9); }

.ai-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70vh;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}

.ai-panel.open { transform: translateY(0); }

.ai-panel-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--gray-100);
  flex-shrink: 0;
}

.ai-panel-title { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }

.ai-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.ai-msg { max-width: 85%; padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.5; font-weight: 600; }
.ai-msg.bot { align-self: flex-start; background: var(--gray-50); border: 2px solid var(--gray-100); border-bottom-left-radius: 4px; }
.ai-msg.user { align-self: flex-end; background: var(--green); color: white; border-bottom-right-radius: 4px; }

.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 2px solid var(--gray-100);
  flex-shrink: 0;
}

.ai-input {
  flex: 1;
  padding: 12px 16px;
  border: 2.5px solid var(--gray-100);
  border-radius: 24px;
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  background: var(--gray-50);
}

.ai-input:focus { border-color: var(--green); }

.ai-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: white;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 0 0 var(--green-dark);
  flex-shrink: 0;
}

.ai-send:active { transform: translateY(1px); box-shadow: 0 1px 0 0 var(--green-dark); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 24px 20px 40px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-title { font-weight: 900; font-size: 18px; margin-bottom: 20px; text-align: center; }

.modal-row { margin-bottom: 14px; }

.modal-row label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.modal-row input, .modal-row select {
  width: 100%;
  padding: 12px;
  border: 2.5px solid var(--gray-100);
  border-radius: var(--radius-xs);
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 700;
  outline: none;
  background: var(--gray-50);
}

.modal-row input:focus, .modal-row select:focus { border-color: var(--green); }

.modal-btns { display: flex; gap: 10px; margin-top: 20px; }

.modal-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.modal-btn.cancel { background: var(--gray-100); color: var(--gray-500); }
.modal-btn.confirm { background: var(--green); color: white; box-shadow: 0 3px 0 0 var(--green-dark); }
.modal-btn.delete { background: var(--red); color: white; box-shadow: 0 3px 0 0 #cc3333; flex: 0; padding: 14px 18px; }

/* ===== ANIMATIONS ===== */
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.pop { animation: pop 0.3s ease; }

@keyframes confetti {
  0% { opacity: 1; transform: translateY(0) rotate(0); }
  100% { opacity: 0; transform: translateY(-60px) rotate(720deg); }
}

.confetti-particle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 999;
  animation: confetti 0.8s ease forwards;
}

/* ===== LOADING ===== */
.loading-spinner { display: flex; justify-content: center; padding: 40px; }
.loading-spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-100);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--gray-700);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 0; }

/* ===== MIGRATION MODAL ===== */
.migration-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.migration-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 360px;
  text-align: center;
}

.migration-card h2 { font-size: 20px; font-weight: 900; margin-bottom: 12px; }
.migration-card p { font-size: 14px; color: var(--gray-500); font-weight: 600; line-height: 1.6; margin-bottom: 20px; }

/* ===== FEED ===== */
.feed-post {
  background: var(--card);
  border: 2px solid var(--gray-100);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.feed-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}

.feed-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.feed-user-info { flex: 1; }
.feed-username { font-weight: 800; font-size: 14px; }
.feed-time { font-size: 11px; color: var(--text-dim); font-weight: 600; }

.feed-image-wrap {
  position: relative;
  width: 100%;
  background: var(--gray-50);
  cursor: pointer;
}

.feed-image {
  width: 100%;
  display: block;
  min-height: 200px;
  object-fit: cover;
}

.feed-heart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  pointer-events: none;
}

.feed-actions {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
}

.feed-like-btn, .feed-comment-btn {
  border: none;
  background: none;
  font-size: 16px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
}

.feed-like-btn.liked { color: var(--red); }
.feed-like-btn:active, .feed-comment-btn:active { transform: scale(0.9); }

.feed-caption {
  padding: 0 16px 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

/* ===== TOGGLE SWITCH (iOS-style) ===== */
/* ===== AI TYPING INDICATOR ===== */
.ai-typing span {
  display: inline-block;
  font-size: 20px;
  color: var(--gray-300);
  animation: aiBounce 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--gray-200);
  border-radius: 28px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--green);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ===== ONBOARDING ===== */

.onboarding-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--tg-theme-bg-color, #1a1a2e);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.onboarding-card {
  background: var(--tg-theme-secondary-bg-color, #16213e);
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 20px;
}

.onboarding-progress {
  height: 4px;
  background: var(--tg-theme-hint-color, #444);
  border-radius: 2px;
  margin-bottom: 16px;
}

.onboarding-progress-bar {
  height: 100%;
  background: var(--tg-theme-button-color, #3390ec);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.onboarding-step-indicator {
  text-align: center;
  font-size: 13px;
  color: var(--tg-theme-hint-color, #888);
  margin-bottom: 20px;
}

.onboarding-emoji {
  text-align: center;
  font-size: 48px;
  margin-bottom: 12px;
}

.onboarding-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--tg-theme-text-color, #fff);
  margin: 0 0 6px;
}

.onboarding-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--tg-theme-hint-color, #888);
  margin: 0 0 24px;
}

.ob-field {
  margin-bottom: 16px;
}

.ob-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-theme-hint-color, #888);
  margin-bottom: 6px;
}

.ob-field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--tg-theme-hint-color, #444);
  background: var(--tg-theme-bg-color, #1a1a2e);
  color: var(--tg-theme-text-color, #fff);
  font-size: 16px;
  box-sizing: border-box;
  -webkit-appearance: none;
}

.ob-field input:focus {
  outline: none;
  border-color: var(--tg-theme-button-color, #3390ec);
}

.ob-gender-row {
  display: flex;
  gap: 10px;
}

.ob-gender-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--tg-theme-hint-color, #444);
  background: var(--tg-theme-bg-color, #1a1a2e);
  color: var(--tg-theme-text-color, #fff);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.ob-gender-btn.active {
  border-color: var(--tg-theme-button-color, #3390ec);
  background: var(--tg-theme-button-color, #3390ec);
  color: var(--tg-theme-button-text-color, #fff);
}

.ob-diff-badge {
  text-align: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
}

.ob-diff-badge.gain {
  background: rgba(76, 175, 80, 0.15);
  color: #4CAF50;
}

.ob-diff-badge.cut {
  background: rgba(255, 82, 82, 0.15);
  color: #FF5252;
}

.ob-diff-badge.maintain {
  background: rgba(255, 193, 7, 0.15);
  color: #FFC107;
}

.ob-template-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ob-template-card {
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid var(--tg-theme-hint-color, #444);
  background: var(--tg-theme-bg-color, #1a1a2e);
  cursor: pointer;
  transition: all 0.2s;
}

.ob-template-card.selected {
  border-color: var(--tg-theme-button-color, #3390ec);
  background: rgba(51, 144, 236, 0.1);
}

.ob-template-emoji {
  font-size: 28px;
  margin-bottom: 6px;
}

.ob-template-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--tg-theme-text-color, #fff);
  margin-bottom: 2px;
}

.ob-template-desc {
  font-size: 13px;
  color: var(--tg-theme-hint-color, #888);
  margin-bottom: 4px;
}

.ob-template-days {
  font-size: 12px;
  color: var(--tg-theme-link-color, #3390ec);
  font-weight: 600;
}

.onboarding-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  gap: 12px;
}

.onboarding-btn {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s;
}

.onboarding-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.onboarding-btn.primary {
  background: var(--tg-theme-button-color, #3390ec);
  color: var(--tg-theme-button-text-color, #fff);
  flex: 1;
}

.onboarding-btn.secondary {
  background: transparent;
  color: var(--tg-theme-hint-color, #888);
}

.onboarding-btn.finish {
  font-size: 17px;
  padding: 14px 20px;
}

/* ===== ADMIN TAB ===== */

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.admin-stat {
  background: var(--tg-theme-secondary-bg-color, var(--white));
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}

.admin-stat-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--tg-theme-button-color, var(--blue));
}

.admin-stat-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--tg-theme-hint-color, var(--text-dim));
  margin-top: 2px;
}

.admin-search {
  margin-bottom: 12px;
}

.admin-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid var(--tg-theme-hint-color, var(--gray-100));
  background: var(--tg-theme-bg-color, var(--gray-50));
  color: var(--tg-theme-text-color, var(--text));
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  box-sizing: border-box;
}

.admin-search input:focus {
  border-color: var(--tg-theme-button-color, var(--blue));
}

.admin-user-card {
  background: var(--tg-theme-secondary-bg-color, var(--white));
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.admin-user-card:active {
  opacity: 0.7;
}

.admin-user-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tg-theme-button-color, var(--blue));
  color: var(--tg-theme-button-text-color, white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}

.admin-user-info {
  flex: 1;
  min-width: 0;
}

.admin-user-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--tg-theme-text-color, var(--text));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-badge-pro {
  font-size: 11px;
  font-weight: 800;
  color: var(--orange, #ff9800);
}

.admin-user-meta {
  font-size: 12px;
  color: var(--tg-theme-hint-color, var(--text-dim));
  font-weight: 600;
}

.admin-user-tmpl {
  font-size: 11px;
  font-weight: 700;
  color: var(--tg-theme-link-color, var(--blue));
  white-space: nowrap;
}

.admin-user-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--tg-theme-hint-color, var(--gray-100));
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.admin-detail-item {
  background: var(--tg-theme-bg-color, var(--gray-50));
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}

.admin-detail-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--tg-theme-hint-color, var(--text-dim));
  text-transform: uppercase;
}

.admin-detail-section {
  font-size: 12px;
  font-weight: 800;
  color: var(--tg-theme-hint-color, var(--text-dim));
  margin: 12px 0 6px;
  text-transform: uppercase;
}

.admin-detail-row {
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-theme-text-color, var(--text));
  padding: 4px 0;
}

.admin-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-bottom: 20px;
}

.admin-pag-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: var(--tg-theme-button-color, var(--blue));
  color: var(--tg-theme-button-text-color, white);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.admin-pag-info {
  font-size: 13px;
  font-weight: 700;
  color: var(--tg-theme-hint-color, var(--text-dim));
}
