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

:root {
  --bg: #1a1a2e;
  --bg-surface: #16213e;
  --bg-card: #1f2b47;
  --bg-card-hover: #253454;
  --bg-glass: rgba(255,255,255,0.05);
  --bg-glass-hover: rgba(255,255,255,0.1);
  --accent: #e94560;
  --accent-light: #ff6b81;
  --accent-dark: #c83b52;
  --accent-2: #0f3460;
  --accent-3: #533483;
  --gradient: linear-gradient(135deg, #e94560, #ff6b81);
  --gradient-dark: linear-gradient(135deg, #0f3460, #533483);
  --gradient-card: linear-gradient(145deg, #1f2b47, #16213e);
  --green: #00d2a0;
  --green-glow: rgba(0,210,160,0.25);
  --yellow: #ffd93d;
  --text: #edf2f7;
  --text-secondary: #8892a4;
  --text-muted: #5a6478;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', 'Inter', sans-serif;
}

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  padding-bottom: calc(72px + var(--safe-bottom));
}

/* ===== Animations ===== */
.fade-in { animation: fadeIn 0.3s ease; }
.slide-up { animation: slideUp 0.35s cubic-bezier(0.16,1,0.3,1); }
.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes countdown-ring {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 283; }
}
@keyframes breathe {
  0%,100% { box-shadow: 0 0 20px rgba(233,69,96,0.3); }
  50% { box-shadow: 0 0 40px rgba(233,69,96,0.6); }
}

/* ===== Typography ===== */
.heading-xl { font-family: var(--font-display); font-size: 2rem; font-weight: 900; line-height: 1.1; }
.heading-lg { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.heading-md { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.text-sm { font-size: 0.85rem; color: var(--text-secondary); }
.text-xs { font-size: 0.75rem; color: var(--text-muted); }
.text-accent { color: var(--accent); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px; border: none; border-radius: var(--radius);
  font-family: var(--font); font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: all 0.2s; text-decoration: none;
}
.btn-primary {
  background: var(--gradient); color: #fff;
  box-shadow: 0 4px 20px rgba(233,69,96,0.35);
}
.btn-primary:active { transform: scale(0.96); box-shadow: 0 2px 10px rgba(233,69,96,0.4); }
.btn-secondary {
  background: var(--bg-glass); color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
}
.btn-secondary:active { background: var(--bg-glass-hover); }
.btn-sm { padding: 10px 18px; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }
.btn-icon {
  width: 44px; height: 44px; border-radius: 50%; padding: 0;
  background: var(--bg-glass); border: none; color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-icon:active { background: var(--bg-glass-hover); transform: scale(0.92); }
.btn-icon svg { width: 22px; height: 22px; }

/* ===== Header ===== */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; padding-top: calc(16px + var(--safe-top));
  position: sticky; top: 0; z-index: 100;
  background: rgba(26,26,46,0.88); backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.header-back {
  display: flex; align-items: center; gap: 4px; color: var(--accent);
  font-weight: 600; background: none; border: none; cursor: pointer;
  font-size: 0.95rem; font-family: var(--font);
}
.header-back svg { width: 20px; height: 20px; }

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 16px; padding-bottom: calc(8px + var(--safe-bottom));
  background: rgba(22,33,62,0.94); backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.05);
  z-index: 200;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px; border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: 0.65rem; font-family: var(--font);
  font-weight: 500; transition: color 0.2s;
}
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 24px; height: 24px; }

/* ===== Page ===== */
.page { padding: 0 20px 20px; }

/* ===== Home ===== */
.home-hero {
  padding: 24px 0 8px;
}
.home-hero h1 { font-family: var(--font-display); font-size: 1.7rem; font-weight: 900; }
.home-hero p { color: var(--text-secondary); margin-top: 6px; font-size: 0.95rem; }
.home-hero .accent-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }

.home-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 20px 0;
}
.stat-card {
  background: var(--gradient-card); border-radius: var(--radius-sm);
  padding: 16px 12px; text-align: center;
  border: 1px solid rgba(255,255,255,0.04);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 60px; height: 60px; border-radius: 50%;
  background: rgba(233,69,96,0.08);
}
.stat-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 900; color: var(--accent); position: relative; z-index: 1; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; position: relative; z-index: 1; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 28px 0 14px;
}
.section-header h2 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 800; }

/* ===== Workout Cards ===== */
.workout-cards { display: flex; flex-direction: column; gap: 12px; }
.workout-card {
  display: flex; align-items: center; gap: 16px;
  padding: 16px; background: var(--bg-card);
  border-radius: var(--radius); cursor: pointer;
  transition: all 0.2s; border: 1px solid rgba(255,255,255,0.04);
  position: relative; overflow: hidden;
}
.workout-card:active { transform: scale(0.98); background: var(--bg-card-hover); }
.workout-card.premium::after {
  content: 'PRO'; position: absolute; top: 10px; right: 12px;
  background: linear-gradient(135deg, #ffd93d, #ff9800);
  color: #1a1a2e; font-size: 0.6rem; font-weight: 800;
  padding: 3px 8px; border-radius: 4px; letter-spacing: 0.5px;
}
.workout-icon {
  width: 52px; height: 52px; border-radius: var(--radius-sm);
  background: var(--gradient-dark); display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.workout-card-info { flex: 1; min-width: 0; }
.workout-card-name { font-weight: 700; font-size: 1rem; }
.workout-card-meta { font-size: 0.8rem; color: var(--text-secondary); margin-top: 3px; }

/* ===== Workout Detail ===== */
.workout-detail-hero {
  padding: 20px 0 12px;
  text-align: center;
}
.workout-detail-hero h1 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 900; }
.workout-detail-hero .workout-meta {
  display: flex; justify-content: center; gap: 24px; margin-top: 12px;
}
.workout-meta-item { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-secondary); }
.workout-meta-item svg { width: 18px; height: 18px; color: var(--accent); }

.exercise-list { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.exercise-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer; transition: background 0.15s;
}
.exercise-item:active { background: var(--bg-glass); }
.exercise-thumb {
  width: 56px; height: 56px; border-radius: var(--radius-xs);
  overflow: hidden; background: var(--bg-glass); flex-shrink: 0;
}
.exercise-thumb img { width: 100%; height: 100%; object-fit: cover; }
.exercise-info { flex: 1; min-width: 0; }
.exercise-name { font-weight: 600; font-size: 0.95rem; }
.exercise-meta { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.exercise-meta span { color: var(--accent); font-weight: 600; }
.rest-item {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-muted); font-size: 0.85rem;
}
.rest-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); margin-left: 24px; }

/* ===== Active Workout Screen ===== */
.workout-screen {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg); display: flex; flex-direction: column;
}
.workout-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; padding-top: calc(16px + var(--safe-top));
}
.progress-bar {
  height: 4px; background: rgba(255,255,255,0.06);
  border-radius: 2px; margin: 0 20px;
}
.progress-fill {
  height: 100%; background: var(--gradient); border-radius: 2px;
  transition: width 0.4s ease;
}

.workout-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 16px 20px; text-align: center; overflow-y: auto;
}
.exercise-video-container {
  width: 260px; height: 260px; border-radius: 50%;
  overflow: hidden; margin: 0 auto 20px;
  border: 3px solid rgba(233,69,96,0.3);
  background: var(--bg-surface);
  display: flex; align-items: center; justify-content: center;
}
.exercise-video-container video {
  width: 100%; height: 100%; object-fit: cover;
}
.exercise-video-container img {
  width: 100%; height: 100%; object-fit: cover;
}
.exercise-title-active { font-family: var(--font-display); font-size: 1.5rem; font-weight: 900; margin-bottom: 8px; }

/* Timer Circle */
.timer-container { position: relative; width: 140px; height: 140px; margin: 16px auto; }
.timer-svg {
  transform: rotate(-90deg);
  width: 140px; height: 140px;
}
.timer-bg { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 5; }
.timer-fg {
  fill: none; stroke: url(#timerGrad); stroke-width: 5;
  stroke-linecap: round; transition: stroke-dashoffset 0.3s linear;
}
.timer-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.timer-value { font-family: var(--font-display); font-size: 2.8rem; font-weight: 900; }
.timer-label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; }

.workout-controls {
  display: flex; align-items: center; justify-content: center; gap: 24px;
  padding: 20px; padding-bottom: calc(24px + var(--safe-bottom));
}
.ctrl-main {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--gradient); border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
  box-shadow: 0 4px 24px rgba(233,69,96,0.4);
}
.ctrl-main:active { transform: scale(0.92); }
.ctrl-main svg { width: 32px; height: 32px; fill: #fff; }
.ctrl-side {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-glass); border: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary); transition: all 0.2s;
}
.ctrl-side:active { background: var(--bg-glass-hover); }

/* ===== Rest Screen ===== */
.rest-overlay {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 20px;
}
.rest-label { font-family: var(--font-display); font-size: 1.2rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 3px; margin-bottom: 16px; }
.rest-timer-big { font-family: var(--font-display); font-size: 5rem; font-weight: 900; color: var(--green); line-height: 1; }
.rest-next { margin-top: 28px; color: var(--text-secondary); font-size: 0.9rem; }
.rest-next strong { color: var(--text); display: block; margin-top: 6px; font-size: 1.05rem; }

/* ===== Complete Screen ===== */
.complete-screen {
  position: fixed; inset: 0; z-index: 600;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px;
}
.complete-icon { font-size: 5rem; margin-bottom: 16px; animation: pulse 2s infinite; }
.complete-title { font-family: var(--font-display); font-size: 2rem; font-weight: 900; margin-bottom: 8px; }
.complete-subtitle { color: var(--text-secondary); margin-bottom: 32px; }
.complete-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  width: 100%; max-width: 340px; margin-bottom: 40px;
}
.complete-stat-val { font-family: var(--font-display); font-size: 1.8rem; font-weight: 900; color: var(--accent); }
.complete-stat-lbl { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }

/* ===== Exercise Detail Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-content {
  background: var(--bg-card); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 480px; max-height: 85vh;
  padding: 20px; padding-bottom: calc(24px + var(--safe-bottom));
  overflow-y: auto; animation: slideUp 0.3s ease;
}
.modal-handle {
  width: 36px; height: 4px; background: rgba(255,255,255,0.2);
  border-radius: 2px; margin: 0 auto 16px;
}
.modal-video {
  width: 100%; aspect-ratio: 16/10; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg-surface); margin-bottom: 16px;
}
.modal-video video { width: 100%; height: 100%; object-fit: cover; }

/* ===== History ===== */
.history-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; background: var(--bg-card); border-radius: var(--radius-sm);
  margin-bottom: 8px; border: 1px solid rgba(255,255,255,0.04);
}
.history-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gradient); flex-shrink: 0; }
.history-details { flex: 1; }
.history-title { font-weight: 600; font-size: 0.95rem; }
.history-meta { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* Calendar */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 16px 0; }
.cal-day {
  aspect-ratio: 1; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; color: var(--text-muted);
}
.cal-day.worked { background: rgba(233,69,96,0.2); color: var(--accent); font-weight: 700; }
.cal-day.today { border: 1px solid var(--accent); color: var(--text); }
.cal-weekday { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }

/* ===== Settings ===== */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.setting-label { font-weight: 500; }
.setting-desc { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.setting-value { color: var(--accent); font-weight: 600; }
.toggle {
  width: 48px; height: 28px; border-radius: 14px;
  background: rgba(255,255,255,0.12); position: relative;
  cursor: pointer; transition: background 0.2s;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: ''; position: absolute; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; top: 3px; left: 3px;
  transition: transform 0.2s;
}
.toggle.on::after { transform: translateX(20px); }

/* ===== Circuits Dialog ===== */
.circuits-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--bg-glass); border: 1px solid rgba(255,255,255,0.08);
  font-size: 0.85rem; font-weight: 600; color: var(--text-secondary);
  cursor: pointer;
}
.circuits-badge:active { background: var(--bg-glass-hover); }

/* ===== Responsive ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

@media (min-width: 481px) {
  #app { border-left: 1px solid rgba(255,255,255,0.04); border-right: 1px solid rgba(255,255,255,0.04); }
}
