/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #242736;
  --border:     #2e3247;
  --accent:     #6c63ff;
  --accent2:    #ff6584;
  --green:      #43d98c;
  --text:       #e8eaf0;
  --muted:      #8b8fa8;
  --radius:     14px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ===== PWA INSTALL BANNER ===== */
.install-banner {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 200;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.install-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}
.install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.install-text strong { font-size: 0.88rem; color: var(--text); }
.install-text span   { font-size: 0.75rem; color: var(--muted); }
.install-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.install-btn:hover { opacity: 0.85; }
.install-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  line-height: 1;
}
.install-dismiss:hover { color: var(--text); }

/* ===== HEADER ===== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 700px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
nav { display: flex; gap: 8px; }
.nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.nav-btn.active, .nav-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== SCREENS ===== */
.screen { display: none; flex: 1; }
.screen.active { display: block; }

/* ===== HOME SCREEN ===== */
.hero {
  background: linear-gradient(145deg, #1a1d27 0%, #12142a 100%);
  border-bottom: 1px solid var(--border);
  padding: 40px 20px;
}
.hero-content {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}
.hero-subtitle {
  font-size: 0.9rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-bottom: 8px;
}
.hero-focus {
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 28px;
}
.program-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 32px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.btn-start {
  background: linear-gradient(135deg, var(--accent), #8a63ff);
  color: #fff;
  border: none;
  padding: 16px 48px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(108,99,255,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(108,99,255,0.55);
}
.btn-start:active { transform: translateY(0); }

/* ===== STRETCH LIST (home preview) ===== */
.preview-section {
  max-width: 700px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
.preview-section h2 {
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}
.stretch-list { display: flex; flex-direction: column; gap: 10px; }
.stretch-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stretch-item-emoji { font-size: 1.4rem; flex-shrink: 0; }
.stretch-item-info { flex: 1; }
.stretch-item-name { font-weight: 600; font-size: 0.95rem; }
.stretch-item-meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.stretch-item-duration {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}

/* ===== WORKOUT SCREEN ===== */
.workout-header {
  max-width: 700px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-exit {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.btn-exit:hover { border-color: var(--accent2); color: var(--accent2); }
.workout-progress-text { font-size: 0.9rem; color: var(--muted); }

.progress-bar-wrap {
  height: 4px;
  background: var(--surface2);
  width: 100%;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.6s ease;
  width: 0%;
}

.workout-body {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stretch-anim {
  width: 200px;
  height: 155px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.stretch-targets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 10px;
}
.target-tag {
  font-size: 0.72rem;
  background: rgba(108,99,255,0.15);
  color: var(--accent);
  border: 1px solid rgba(108,99,255,0.3);
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: capitalize;
}

.stretch-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
}

/* ===== TIMER RING ===== */
.timer-ring-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin-bottom: 24px;
}
.timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface2); stroke-width: 8; }
.ring-fg {
  fill: none;
  stroke: url(#grad);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.timer-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#timer-display {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text);
}

/* ===== WORKOUT CONTROLS ===== */
.workout-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}
.btn-control {
  padding: 10px 28px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}
.btn-pause {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-pause:hover { background: var(--surface); }
.btn-skip {
  background: none;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-skip:hover { color: var(--text); border-color: var(--text); }

/* ===== INSTRUCTIONS ===== */
.instructions-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  width: 100%;
  margin-bottom: 16px;
  text-align: left;
}
.instructions-list {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.instructions-list li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}
.instructions-list li::before {
  content: counter(step);
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.tip-box {
  background: rgba(67,217,140,0.08);
  border: 1px solid rgba(67,217,140,0.2);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.85rem;
  color: var(--green);
  width: 100%;
  text-align: left;
  line-height: 1.5;
}
.tip-box::before {
  content: "💡 Tip: ";
  font-weight: 700;
}

/* ===== REST SCREEN ===== */
#screen-rest {
  display: none;
  align-items: center;
  justify-content: center;
}
#screen-rest.active { display: flex; }
.rest-body {
  max-width: 480px;
  margin: 0 auto;
  padding: 60px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.rest-check {
  font-size: 3rem;
  color: var(--green);
  width: 80px;
  height: 80px;
  background: rgba(67,217,140,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.rest-body h2 { font-size: 1.4rem; }
.rest-up-next { font-size: 0.85rem; color: var(--muted); margin-top: 16px; }
.rest-body h3 { font-size: 1.2rem; color: var(--accent); }
.rest-timer-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 16px 0;
}
#rest-timer {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text);
}
.rest-label { font-size: 1rem; color: var(--muted); }
.btn-next {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 32px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-next:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ===== COMPLETE SCREEN ===== */
#screen-complete {
  display: none;
  align-items: center;
  justify-content: center;
}
#screen-complete.active { display: flex; }
.complete-body {
  max-width: 480px;
  margin: 0 auto;
  padding: 60px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.complete-icon { font-size: 4rem; margin-bottom: 8px; }
.complete-body h2 { font-size: 1.8rem; font-weight: 800; }
.complete-sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 16px; }
.complete-stats {
  display: flex;
  gap: 48px;
  margin: 20px 0 32px;
}

/* ===== HISTORY SCREEN ===== */
.history-body {
  max-width: 700px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
.history-body h2 {
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 20px;
}
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.history-item-date { font-weight: 600; font-size: 0.95rem; }
.history-item-sub { font-size: 0.8rem; color: var(--muted); margin-top: 3px; }
.history-item-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
}
.badge-complete {
  background: rgba(67,217,140,0.15);
  color: var(--green);
  border: 1px solid rgba(67,217,140,0.3);
}
.badge-partial {
  background: rgba(255,165,0,0.1);
  color: orange;
  border: 1px solid rgba(255,165,0,0.3);
}
.history-empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
  font-size: 0.95rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .program-stats { gap: 20px; }
  .stat-num { font-size: 1.6rem; }
  .stretch-name { font-size: 1.2rem; }
  #timer-display { font-size: 2rem; }
  .timer-ring-wrap { width: 130px; height: 130px; }
}
