/* MOTTO – Design Token System */
/* CSS custom properties for theming: dark/light mode + accent color */

:root {
  /* ── Accent (default: orange) ── */
  --accent: #E8440A;
  --accent-rgb: 232, 68, 10;
  --accent-light: rgba(232, 68, 10, 0.15);
  --accent-border: rgba(232, 68, 10, 0.4);

  /* ── Dark theme (default) ── */
  --bg: #0D0D0D;
  --bg-secondary: #111111;
  --surface: #1A1A1A;
  --surface-raised: #222222;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-muted: rgba(255, 255, 255, 0.35);
  --text-on-accent: #FFFFFF;
  --overlay: rgba(0, 0, 0, 0.5);

  /* ── Semantic colors ── */
  --success: #30D158;
  --success-bg: rgba(48, 209, 88, 0.12);
  --destructive: #FF453A;
  --warning: #FFD60A;

  /* ── Timing ── */
  --transition-fast: 150ms ease;
  --transition-med: 250ms ease;
}

/* Light theme override */
[data-theme="light"] {
  --bg: #F2F2F7;
  --bg-secondary: #E8E8ED;
  --surface: #FFFFFF;
  --surface-raised: #F9F9F9;
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.12);
  --text-primary: #000000;
  --text-secondary: rgba(0, 0, 0, 0.55);
  --text-muted: rgba(0, 0, 0, 0.35);
  --text-on-accent: #FFFFFF;
  --overlay: rgba(0, 0, 0, 0.3);
}

/* Accent color overrides */
[data-accent="blue"]   { --accent: #4A9EFF; --accent-rgb: 74, 158, 255; --accent-light: rgba(74,158,255,0.15); --accent-border: rgba(74,158,255,0.4); }
[data-accent="green"]  { --accent: #30D158; --accent-rgb: 48, 209, 88;  --accent-light: rgba(48,209,88,0.15);  --accent-border: rgba(48,209,88,0.4); }
[data-accent="purple"] { --accent: #BF5AF2; --accent-rgb: 191, 90, 242; --accent-light: rgba(191,90,242,0.15); --accent-border: rgba(191,90,242,0.4); }
[data-accent="yellow"] { --accent: #FFD60A; --accent-rgb: 255, 214, 10; --accent-light: rgba(255,214,10,0.15); --accent-border: rgba(255,214,10,0.4); }
[data-accent="pink"]   { --accent: #FF375F; --accent-rgb: 255, 55, 95;  --accent-light: rgba(255,55,95,0.15);  --accent-border: rgba(255,55,95,0.4); }

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

html, body {
  height: 100%;
  font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-med), color var(--transition-med);
}

/* ─── App shell ────────────────────────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  padding-top: env(safe-area-inset-top);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  overflow: hidden
}

/* ─── Nav bar ───────────────────────────────────────── */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 10px 0 max(16px, env(safe-area-inset-bottom));
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 16px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  transition: color var(--transition-fast);
}
.nav-btn.active { color: var(--accent); }
.nav-btn svg { transition: stroke var(--transition-fast); }

/* ─── Tabs / content panels ─────────────────────────── */
.tab-panel { display: none; flex-direction: column; padding-bottom: 90px; }
.tab-panel.active { display: flex; }

/* ─── Workout screen ─────────────────────────────────── */
.workout-header { padding: 20px 20px 12px; }
.workout-day-label {
  font-size: 12px; font-weight: 600; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 4px;
}
.workout-title { font-size: 26px; font-weight: 800; letter-spacing: -0.4px; color: var(--text-primary); }

/* Exercise card */
.exercise-card {
  background: var(--surface); border-radius: 18px; margin: 0 16px 12px;
  overflow: hidden; border: 1px solid var(--border); transition: border-color var(--transition-fast);
}
.exercise-card:focus-within { border-color: var(--accent-border); }
.exercise-name {
  padding: 14px 16px 10px; font-size: 15px; font-weight: 700;
  color: var(--text-primary); border-bottom: 1px solid var(--border);
}

/* Set row */
.set-row {
  display: grid; grid-template-columns: 32px 1fr 1fr 44px;
  align-items: center; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); transition: background var(--transition-fast);
}
.set-row:last-of-type { border-bottom: none; }
.set-row.completed { background: var(--success-bg); }
.set-row.completing { animation: setFlash 0.4s ease forwards; }

@keyframes setFlash {
  0%   { background: rgba(var(--accent-rgb), 0.3); }
  60%  { background: rgba(48, 209, 88, 0.2); }
  100% { background: var(--success-bg); }
}

.set-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-align: center; }
.set-row.completed .set-label { color: var(--success); }

.set-input {
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 8px;
  color: var(--text-primary); font-size: 15px; font-weight: 600; text-align: center;
  padding: 7px 4px; width: 100%; transition: border-color var(--transition-fast), opacity var(--transition-fast);
  -moz-appearance: textfield;
}
.set-input::-webkit-outer-spin-button, .set-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.set-input:focus { outline: none; border-color: var(--accent); }
.set-input::placeholder { color: var(--text-muted); font-size: 13px; }
.set-row.completed .set-input { opacity: 0.4; pointer-events: none; }

/* Checkmark / log button */
.log-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border-strong);
  background: transparent; cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: background var(--transition-fast), border-color var(--transition-fast), transform 0.15s ease;
  color: var(--text-muted);
}
.log-btn:hover { border-color: var(--accent); color: var(--accent); }
.log-btn:active { transform: scale(0.9); }
.set-row.completed .log-btn { background: var(--success); border-color: var(--success); color: #fff; }

/* Auto-fill hint */
.autofill-hint {
  font-size: 11px; color: var(--text-muted); padding: 0 16px 10px;
  display: flex; align-items: center; gap: 4px;
}

/* ─── Rest Timer pill ────────────────────────────────── */
#rest-timer {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%) translateY(120%);
  background: var(--surface-raised); border: 1px solid var(--accent-border);
  border-radius: 100px; padding: 10px 20px; display: flex; align-items: center;
  gap: 12px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); white-space: nowrap;
}
#rest-timer.visible { transform: translateX(-50%) translateY(0); }
.rest-timer-label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.5px; text-transform: uppercase; }
.rest-timer-countdown { font-size: 20px; font-weight: 800; color: var(--accent); min-width: 48px; text-align: center; letter-spacing: -0.5px; }
.rest-timer-skip {
  background: var(--accent-light); border: 1px solid var(--accent-border); border-radius: 20px;
  color: var(--accent); font-size: 12px; font-weight: 700; padding: 4px 12px; cursor: pointer;
  transition: background var(--transition-fast);
}
.rest-timer-skip:hover { background: var(--accent); color: #fff; }

/* ─── Settings modal ─────────────────────────────────── */
#settings-modal { display: none; position: fixed; inset: 0; z-index: 500; align-items: flex-end; }
#settings-modal.open { display: flex; }
.settings-backdrop { position: absolute; inset: 0; background: var(--overlay); animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.settings-sheet {
  position: relative; width: 100%; max-width: 480px; margin: 0 auto;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 20px 20px max(24px, env(safe-area-inset-bottom));
  animation: slideUp 0.3s cubic-bezier(0.34, 1.26, 0.64, 1); max-height: 85vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.settings-handle { width: 36px; height: 4px; background: var(--border-strong); border-radius: 2px; margin: 0 auto 20px; }
.settings-title { font-size: 20px; font-weight: 800; color: var(--text-primary); margin-bottom: 20px; }
.settings-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--text-muted); margin: 0 4px 8px;
}
.settings-card { background: var(--bg); border-radius: 14px; overflow: hidden; margin-bottom: 20px; border: 1px solid var(--border); }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 14px; font-weight: 500; color: var(--text-primary); }

/* Theme picker grid */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 16px; }
.theme-option { border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; transition: border-color var(--transition-fast); }
.theme-option.active { border-color: var(--accent); }
.theme-option-preview { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.theme-option-bar { height: 5px; border-radius: 3px; }
.theme-label { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: 12px; font-weight: 600; }

/* Accent swatches */
.accent-row { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 16px; }
.accent-swatch {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; border: 3px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease; position: relative;
}
.accent-swatch:hover { transform: scale(1.1); }
.accent-swatch.active { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px currentColor; }

/* iOS toggle */
.ios-toggle { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.ios-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.ios-toggle-track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 13px; cursor: pointer; transition: background var(--transition-fast); }
.ios-toggle input:checked + .ios-toggle-track { background: var(--accent); }
.ios-toggle-track::after {
  content: ''; position: absolute; width: 20px; height: 20px; background: #fff;
  border-radius: 50%; top: 3px; left: 3px; transition: transform var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.ios-toggle input:checked + .ios-toggle-track::after { transform: translateX(18px); }

/* ─── Macros / Nutrition tab ─────────────────────────── */
.macros-header { padding: 20px 20px 12px; }
.macros-title { font-size: 26px; font-weight: 800; letter-spacing: -0.4px; margin-bottom: 4px; }
.macros-date { font-size: 13px; color: var(--text-muted); }

.calorie-card {
  margin: 0 16px 12px; background: var(--surface); border-radius: 18px;
  padding: 20px; display: flex; align-items: center; gap: 20px; border: 1px solid var(--border);
}
.calorie-ring-wrap { position: relative; flex-shrink: 0; }
.calorie-ring-wrap svg { display: block; }
.calorie-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.calorie-ring-num { font-size: 22px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.calorie-ring-label { font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.5px; text-transform: uppercase; }
.calorie-info { flex: 1; min-width: 0; }
.calorie-remaining { font-size: 24px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
.calorie-remaining-label { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.calorie-breakdown { display: flex; flex-direction: column; gap: 4px; }
.calorie-row { display: flex; justify-content: space-between; font-size: 12px; }
.calorie-row-label { color: var(--text-muted); }
.calorie-row-val { font-weight: 600; color: var(--text-secondary); }

.macro-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 0 16px 12px; }
.macro-card {
  background: var(--surface); border-radius: 14px; padding: 14px 10px;
  border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.macro-bar-wrap { width: 100%; height: 4px; background: var(--border-strong); border-radius: 2px; overflow: hidden; }
.macro-bar { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.macro-name { font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted); }
.macro-current { font-size: 18px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.macro-target { font-size: 11px; color: var(--text-muted); }

.meal-section-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 20px 8px; }
.meal-section-title { font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-muted); }
.add-meal-btn {
  background: var(--accent-light); border: 1px solid var(--accent-border); border-radius: 20px;
  color: var(--accent); font-size: 12px; font-weight: 700; padding: 5px 12px; cursor: pointer;
  transition: background var(--transition-fast);
}
.add-meal-btn:hover { background: var(--accent); color: #fff; }

.meal-list { margin: 0 16px; background: var(--surface); border-radius: 14px; overflow: hidden; border: 1px solid var(--border); }
.meal-item { display: flex; align-items: center; padding: 13px 16px; gap: 12px; border-bottom: 1px solid var(--border); }
.meal-item:last-child { border-bottom: none; }
.meal-emoji { font-size: 22px; }
.meal-info { flex: 1; min-width: 0; }
.meal-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.meal-macros { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.meal-cals { font-size: 15px; font-weight: 700; color: var(--accent); }

.tdee-btn {
  margin: 10px 16px 0; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text-secondary); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast); width: calc(100% - 32px);
}
.tdee-btn:hover { border-color: var(--accent-border); color: var(--accent); }

/* ─── Home ─────────────────────────── */
.home-header { padding: 20px 20px 8px; display: flex; align-items: center; justify-content: space-between; }
.home-greeting { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.profile-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), rgba(var(--accent-rgb), 0.6));
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.profile-btn:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.4); }
.profile-btn:active { transform: scale(0.95); }

.streak-card { margin: 8px 16px; background: var(--surface); border-radius: 18px; padding: 18px; border: 1px solid var(--border); }
.streak-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.streak-num { font-size: 36px; font-weight: 900; color: var(--accent); letter-spacing: -1px; }
.streak-label { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-top: 2px; }
.streak-flame { font-size: 28px; }
.week-dots { display: flex; gap: 6px; }
.week-dot { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.week-dot-day { font-size: 10px; font-weight: 600; color: var(--text-muted); }
.week-dot-circle {
  width: 28px; height: 28px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.week-dot-circle.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.week-dot-circle.today { border-color: var(--accent); }

.hero-card {
  margin: 8px 16px; background: var(--surface); border-radius: 20px; padding: 20px;
  border: 1.5px solid var(--accent-border); position: relative; overflow: hidden; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hero-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.2); }
.hero-card:active { transform: translateY(0); }
.hero-glow {
  position: absolute; bottom: -40px; left: -40px; width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.18) 0%, transparent 70%); pointer-events: none;
}
.hero-tag { font-size: 11px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.hero-title { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 14px; }
.hero-meta { display: flex; gap: 14px; }
.hero-meta-item { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

.start-btn {
  margin: 8px 16px; width: calc(100% - 32px); height: 52px; background: var(--accent);
  border: none; border-radius: 14px; color: var(--text-on-accent); font-size: 16px; font-weight: 800;
  cursor: pointer; letter-spacing: 0.3px; transition: opacity var(--transition-fast), transform 0.15s ease;
  box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.4);
}
.start-btn:hover { opacity: 0.9; }
.start-btn:active { transform: scale(0.98); }

/* Rest day */
.rest-day { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 32px; text-align: center; gap: 12px; }
.rest-day-emoji { font-size: 60px; }
.rest-day-title { font-size: 26px; font-weight: 800; letter-spacing: -0.4px; }
.rest-day-sub { font-size: 15px; color: var(--text-muted); line-height: 1.5; }

/* Utility */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
