/* ── Reset & Variables ── */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0f0f1a;
  --card: #1a1a2e;
  --card2: #16213e;
  --accent: #e94560;
  --green: #2ecc71;
  --muted: #8892a4;
  --text: #ffffff;
  --text-secondary: rgba(255,255,255,0.7);
  --text-faint: rgba(255,255,255,0.2);
  --border: rgba(255,255,255,0.06);
  --border-med: rgba(255,255,255,0.12);
  --subtle-bg: rgba(255,255,255,0.06);
  --subtle-bg-hover: rgba(255,255,255,0.1);
  --chart-label: rgba(255,255,255,0.3);
  --chart-grid: rgba(255,255,255,0.07);
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ── */
.header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: calc(var(--safe-top) + 16px) 20px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.back-btn {
  background: var(--card); border: none; color: var(--accent);
  width: 38px; height: 38px; border-radius: 10px; font-size: 22px;
  cursor: pointer; display: none; align-items: center; justify-content: center; flex-shrink: 0;
}
.back-btn.visible { display: flex; }
.header-title { font-size: 1.4rem; font-weight: 700; flex: 1; }
.header-action {
  background: rgba(233,69,96,0.15); border: none; color: var(--accent);
  font-size: 1.15rem; font-weight: 600; cursor: pointer;
  font-family: inherit; padding: 7px 14px; display: none;
  border-radius: 10px;
}
.header-action.visible { display: block; }

/* ── Auth Screen Tabs ── */
.auth-tab {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 10px; border-radius: 10px; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.auth-tab-active {
  background: var(--card, #1a1a2e); color: var(--text, #fff);
}

/* ── Burger Menu Button ── */
.burger-btn {
  background: none; border: none; color: var(--text);
  font-size: 1.5rem; cursor: pointer; padding: 4px 2px;
  flex-shrink: 0; line-height: 1;
}
.cloud-sync-dot {
  display: none; width: 8px; height: 8px; border-radius: 50%;
  position: absolute; top: 14px; right: 10px;
}
.cloud-sync-dot.error {
  display: block; background: var(--accent);
}

/* ── Burger Overlay & Menu ── */
.burger-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 99; opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.burger-overlay.open { opacity: 1; pointer-events: auto; }

.burger-menu {
  position: fixed; top: 0; right: -280px; width: 270px;
  height: 100%; background: var(--card); z-index: 100;
  padding: calc(var(--safe-top) + 20px) 20px 20px;
  transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}
.burger-menu.open { right: 0; }

.burger-header {
  font-size: 1.2rem; font-weight: 700; margin-bottom: 24px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.burger-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; cursor: pointer;
}
.burger-item-icon { font-size: 1.3rem; }
.burger-item-label { flex: 1; font-size: 1rem; font-weight: 500; }
.theme-emoji { font-size: 1.3rem; }

/* ── Theme Toggle Switch ── */
.theme-toggle {
  width: 48px; height: 26px; border-radius: 13px;
  background: var(--subtle-bg-hover); position: relative;
  transition: background 0.2s; flex-shrink: 0;
}
.theme-toggle-knob {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; position: absolute; top: 2px; left: 2px;
  transition: left 0.2s;
}
.light .theme-toggle { background: var(--accent); }
.light .theme-toggle .theme-toggle-knob { left: 24px; }

/* ── Views ── */
.view { display: none; padding: 20px; padding-bottom: calc(var(--safe-bottom) + 90px); }
.view.active { display: block; }

/* ── Tab Bar ── */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: var(--safe-bottom);
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 12px 0 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.7rem; font-family: inherit; letter-spacing: 0.3px;
  transition: color 0.2s;
}
.tab-btn .tab-icon { font-size: 1.35rem; filter: grayscale(1) brightness(0.7); transition: filter 0.2s; }
.tab-btn.active .tab-icon { filter: none; }
.tab-btn.active { color: var(--accent); }

/* ── FAB ── */
.fab {
  position: fixed; right: 20px;
  bottom: calc(var(--safe-bottom) + 74px);
  width: 56px; height: 56px;
  background: var(--accent); border: none; border-radius: 50%;
  color: white; font-size: 2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(233,69,96,0.45); z-index: 15;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.9); }
.fab.hidden { display: none; }

/* ── Empty State ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 20px; text-align: center;
}
.empty-icon { font-size: 4rem; margin-bottom: 16px; }
.empty-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.empty-sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 32px; line-height: 1.5; }
.empty-cta {
  background: var(--accent); color: white; border: none;
  border-radius: 14px; padding: 14px 32px;
  font-size: 1rem; font-weight: 700; cursor: pointer; font-family: inherit;
}

/* ── Shared Section Label ── */
.section-label {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); margin-bottom: 10px;
}

/* ── Themed form elements (inline styles → classes) ── */
.themed-select {
  width: 100%; background: var(--card); color: var(--text);
  border: 1px solid var(--border-med); border-radius: 12px;
  padding: 12px 14px; font-size: 1rem; font-family: inherit;
  outline: none; appearance: none; -webkit-appearance: none;
}
.themed-textarea {
  width: 100%; box-sizing: border-box; background: var(--subtle-bg);
  color: var(--text); border: 1px solid var(--border-med);
  border-radius: 12px; padding: 12px; font-size: 0.92rem;
  font-family: inherit; resize: none; height: 70px; outline: none;
  margin-bottom: 16px;
}
.themed-textarea::placeholder { color: var(--muted); }

/* ══════════════════════════════════════
   Light Theme — override all variables
   ══════════════════════════════════════ */
.light {
  --bg: #f2f2f7;
  --card: #ffffff;
  --card2: #e8e8ef;
  --muted: #6b7280;
  --text: #1a1a2e;
  --text-secondary: rgba(0,0,0,0.6);
  --text-faint: rgba(0,0,0,0.25);
  --border: rgba(0,0,0,0.1);
  --border-med: rgba(0,0,0,0.15);
  --subtle-bg: rgba(0,0,0,0.04);
  --subtle-bg-hover: rgba(0,0,0,0.08);
  --chart-label: rgba(0,0,0,0.45);
  --chart-grid: rgba(0,0,0,0.1);
}
.light .back-btn { box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.light .burger-menu { box-shadow: -4px 0 24px rgba(0,0,0,0.12); }
.light .fab { box-shadow: 0 4px 20px rgba(233,69,96,0.3); }
.light .modal-handle { background: rgba(0,0,0,0.15); }
.light .modal-close { background: rgba(0,0,0,0.06); color: var(--text); }
.light .confirm-btn-cancel { background: rgba(0,0,0,0.06); color: var(--text); }
.light .muscle-icon-wrap { background: #e8e8ef; }
.light .theme-toggle { background: rgba(0,0,0,0.12); }
.light .bw-cal-day:active { background: rgba(0,0,0,0.06) !important; }
