:root {
  --bg: #0b0f17;
  --bg-glow: #131a29;
  --card: rgba(255, 255, 255, 0.055);
  --card-border: rgba(255, 255, 255, 0.09);
  --accent: #22d3ee;
  --accent-glow: rgba(34, 211, 238, 0.45);
  --success: #34d399;
  --danger: #fb7185;
  --muted: #8b93a7;
  --text: #e6eaf2;
  --track: rgba(255, 255, 255, 0.08);
  --nav-h: 64px;
  --radius: 18px;
}

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

html, body { height: 100%; }

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 800px at 50% -10%, var(--bg-glow), var(--bg) 70%) fixed;
  color: var(--text);
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

#app-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

/* ---------- Header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(11, 15, 23, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
}

.logo-area { display: flex; align-items: center; gap: 10px; min-width: 0; }

.logo-icon {
  font-size: 22px;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  box-shadow: 0 0 18px var(--accent-glow);
  flex-shrink: 0;
}

.logo-area h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.day-label { font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; }

/* ---------- Layout / views ---------- */

.app-content { flex: 1; padding: 16px 16px 24px; width: 100%; }

.app-view { display: none; }
.app-view.active { display: block; animation: fadeIn 0.22s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Bottom nav ---------- */

.app-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 20;
}

.nav-item {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  transition: color 0.18s ease;
}

.nav-item.active { color: var(--accent); text-shadow: 0 0 14px var(--accent-glow); }
.nav-item:active { transform: scale(0.97); }

/* ---------- Timer ---------- */

.timer-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.timer-circle {
  width: 210px; height: 210px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background:
    radial-gradient(circle at center, var(--bg) 58%, transparent 60%),
    conic-gradient(var(--accent) 0deg, var(--track) 0deg);
  position: relative;
}

#timer-time { font-size: 46px; font-weight: 800; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
#timer-exercise-name { font-size: 14px; color: var(--text); font-weight: 600; max-width: 160px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#timer-phase { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; }

.timer-controls { display: flex; gap: 12px; width: 100%; }

/* ---------- Progress ---------- */

.progress-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.progress-card > span { font-size: 13px; color: var(--muted); font-weight: 600; }

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #6366f1);
  box-shadow: 0 0 12px var(--accent-glow);
  transition: width 0.35s ease;
}

/* ---------- Today menu / exercises ---------- */

.circuit-block { margin-top: 22px; }
.circuit-block h3 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.circuit-block h3::after { content: ''; flex: 1; height: 1px; background: var(--card-border); }

.exercise-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.2s ease, background 0.2s ease;
  min-width: 0;
}

.exercise-card.done { border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.06); }

.exercise-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.exercise-name { font-size: 15px; font-weight: 600; }
.exercise-card.done .exercise-name { color: var(--success); }

.exercise-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }

/* Checkbox */
.check-wrap {
  position: relative;
  flex-shrink: 0;
  width: 26px; height: 26px;
  cursor: pointer;
}

.check-wrap input {
  position: absolute;
  opacity: 0;
  width: 100%; height: 100%;
  margin: 0;
  cursor: pointer;
}

.checkmark {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 2px solid var(--muted);
  background: transparent;
  transition: all 0.18s ease;
  pointer-events: none;
}

.check-wrap input:checked ~ .checkmark {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.45);
}

.checkmark::after {
  content: '';
  position: absolute;
  left: 8px; top: 3px;
  width: 6px; height: 12px;
  border: solid #04120c;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s ease;
}

.check-wrap input:checked ~ .checkmark::after { transform: rotate(45deg) scale(1); }

/* Video link */
.video-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.08);
  white-space: nowrap;
  flex-shrink: 0;
}

.video-link:active { transform: scale(0.96); }

.video-link.video-missing {
  color: var(--muted);
  border-color: var(--card-border);
  background: transparent;
  font-weight: 500;
}

/* ---------- Complete banner ---------- */

.complete-banner {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.18), rgba(34, 211, 238, 0.12));
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: var(--success);
  font-weight: 700;
  text-align: center;
  box-shadow: 0 0 24px rgba(52, 211, 153, 0.15);
  animation: fadeIn 0.3s ease;
}

/* ---------- View headers / filters ---------- */

.view-header { padding: 6px 2px 14px; }
.view-header h2 { font-size: 22px; font-weight: 800; }

.section-header { margin: 22px 0 10px; }
.section-header h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

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

.filter-row select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
}

/* ---------- History ---------- */

.history-stack { display: flex; flex-direction: column; gap: 10px; }

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-width: 0;
}

.history-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.history-row.complete { border-color: rgba(52, 211, 153, 0.35); }
.history-row.complete span:last-child { color: var(--success); font-weight: 700; }

/* ---------- Stats ---------- */

.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.stat-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.stat-value { font-size: 34px; font-weight: 800; color: var(--accent); text-shadow: 0 0 18px var(--accent-glow); }

.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }

.badges-stack { display: flex; flex-wrap: wrap; gap: 10px; }

.badge {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(99, 102, 241, 0.12));
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.1);
}

/* ---------- Empty / buttons ---------- */

.empty-state {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 32px 16px;
  background: var(--card);
  border: 1px dashed var(--card-border);
  border-radius: 14px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #04121b;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
}