/* ── Telegram theme variables with dev fallbacks ─────────────────────── */
:root {
  --bg:           var(--tg-theme-bg-color,           #ffffff);
  --text:         var(--tg-theme-text-color,         #000000);
  --hint:         var(--tg-theme-hint-color,         #8e8e93);
  --link:         var(--tg-theme-link-color,         #2481cc);
  --accent:       var(--tg-theme-button-color,       #2481cc);
  --accent-text:  var(--tg-theme-button-text-color,  #ffffff);
  --card-bg:      var(--tg-theme-secondary-bg-color, #f2f2f7);
  --divider:      rgba(0, 0, 0, 0.08);
  --radius:       12px;
}

/* ── Reset + Base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* ── Dev banner ──────────────────────────────────────────────────────── */
.dev-banner {
  background: #f0a500;
  color: #000;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 5px 12px;
  letter-spacing: 0.02em;
}

/* ── App header ──────────────────────────────────────────────────────── */
.app-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--card-bg);
}

.app-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Tab bar ─────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--card-bg);
}

.tab-btn {
  flex: 1;
  padding: 11px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--hint);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── Content area ────────────────────────────────────────────────────── */
.content {
  padding: 10px 12px 24px;
}

/* ── State screens (loading / error / no-plan) ───────────────────────── */
.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 55vh;
  text-align: center;
  padding: 24px;
  color: var(--hint);
  font-size: 14px;
}

.state-icon { font-size: 44px; line-height: 1; }

.state-screen p { max-width: 260px; line-height: 1.5; }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--card-bg);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.retry-btn {
  margin-top: 4px;
  padding: 10px 22px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Raw fallback (plan text couldn't be parsed) ─────────────────────── */
.raw-text {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

/* ── Day cards ───────────────────────────────────────────────────────── */
.day-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.day-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 14px;
  cursor: pointer;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.day-card-left { flex: 1; min-width: 0; }

.day-weekday {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--hint);
  margin-bottom: 3px;
}

.day-desc {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.day-meta {
  font-size: 12px;
  color: var(--hint);
  white-space: nowrap;
}

.chevron {
  font-size: 17px;
  color: var(--hint);
  line-height: 1;
  transition: transform 0.2s ease;
  font-weight: 300;
}

.day-card.open .chevron {
  transform: rotate(90deg);
}

.day-card-body {
  display: none;
  padding: 0 14px 12px;
}

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

/* ── Exercise list ───────────────────────────────────────────────────── */
.exercise-item {
  border-top: 1px solid var(--divider);
  padding: 10px 0 8px;
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.exercise-text { flex: 1; }

.exercise-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.exercise-sets {
  font-size: 13px;
  color: var(--accent);
  margin-top: 3px;
  font-weight: 500;
}

.info-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--divider);
  color: var(--hint);
  font-size: 12px;
  font-weight: 700;
  font-style: normal;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.exercise-item.open .info-icon {
  background: var(--accent);
  color: var(--accent-text);
}

.exercise-desc {
  display: none;
  font-size: 13px;
  color: var(--hint);
  margin-top: 8px;
  line-height: 1.55;
  padding-left: 2px;
}

.exercise-item.open .exercise-desc {
  display: block;
}

/* ── Meal list ───────────────────────────────────────────────────────── */
.meal-item {
  border-top: 1px solid var(--divider);
  padding: 9px 0 7px;
}

.meal-time {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.meal-desc {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.45;
}

.day-totals {
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  margin-top: 6px;
  padding-top: 8px;
  font-size: 12px;
  color: var(--hint);
  font-weight: 500;
}
