:root {
  --sage: #7c9885;
  --sage-dark: #5f7a68;
  --bg-top: #eef2ec;
  --cream: #faf7f2;
  --card: #ffffff;
  --text: #2f3b34;
  --text-soft: #6b7570;
  --danger: #b5665b;
  --card-shadow: rgba(47, 59, 52, 0.08);
  --border: #d7ded9;
  --track-bg: #e7ece7;
  --control-hover-bg: #f2f5f1;
  --danger-border: #ecd7d3;
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --sage: #8fbfa0;
    --sage-dark: #bfe4cc;
    --bg-top: #171f1b;
    --cream: #10140f;
    --card: #1c2620;
    --text: #eaf0ec;
    --text-soft: #9fb0a6;
    --danger: #e5978a;
    --card-shadow: rgba(0, 0, 0, 0.45);
    --border: #34423b;
    --track-bg: #283329;
    --control-hover-bg: #24302a;
    --danger-border: #4a322d;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--cream) 100%);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.app {
  width: 100%;
  max-width: 480px;
}

.screen.hidden,
.hidden {
  display: none;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 10px 40px var(--card-shadow);
  text-align: center;
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 600;
  color: var(--sage-dark);
}

.tagline {
  margin: 0 0 28px;
  color: var(--text-soft);
  line-height: 1.5;
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.duration-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px 8px;
  border: none;
  border-radius: var(--radius);
  background: var(--sage);
  color: white;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.duration-btn:hover {
  background: var(--sage-dark);
  transform: translateY(-2px);
}

.duration-btn .big {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}

.duration-btn .small {
  font-size: 0.75rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.duration-btn.wide {
  width: 100%;
  flex-direction: row;
  gap: 8px;
  padding: 14px;
}

.music-row {
  margin-bottom: 20px;
  text-align: left;
}

.music-row label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.music-row select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
}

.note {
  font-size: 0.8rem;
  color: var(--text-soft);
  line-height: 1.4;
}

/* --- Workout screen --- */

.workout-card {
  padding-top: 20px;
}

.overall-progress {
  height: 6px;
  background: var(--track-bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
}

.overall-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--sage-dark);
  transition: width 0.6s linear;
}

.step-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-bottom: 10px;
}

.top-timer {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--sage-dark);
  font-variant-numeric: tabular-nums;
}

/* Portrait: figure and text simply stack (see landscape override below). */
.workout-body {
  display: block;
}

.workout-left {
  margin-bottom: 4px;
}

.figure-host {
  width: 160px;
  height: 200px;
  margin: 0 auto 8px;
  color: var(--sage-dark);
}

.figure-host svg {
  width: 100%;
  height: 100%;
}

.pose-figure {
  width: 100%;
  height: 100%;
  animation: breathe 4s ease-in-out infinite;
  transform-origin: 50% 60%;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

#pose-name {
  margin: 4px 0 0;
  font-size: 1.5rem;
  color: var(--sage-dark);
}

.sanskrit {
  margin: 2px 0 14px;
  font-style: italic;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.cue {
  min-height: 3.6em;
  line-height: 1.5;
  color: var(--text);
  font-size: 0.95rem;
  margin: 0 0 18px;
}

.pose-progress {
  height: 8px;
  background: var(--track-bg);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}

.pose-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--sage);
  transition: width 1s linear;
}

.time-left {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-bottom: 20px;
  font-variant-numeric: tabular-nums;
}

/* --- Countdown between poses --- */

.countdown-view {
  padding: 6px 0 10px;
}

.countdown-number {
  font-size: 3.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--sage-dark);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.countdown-label {
  margin: 0 0 2px;
  font-size: 0.78rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.countdown-next {
  margin: 0 0 20px;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--sage-dark);
}

.controls {
  display: flex;
  gap: 10px;
}

.control-btn {
  flex: 1;
  padding: 12px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.control-btn:hover {
  background: var(--control-hover-bg);
}

.control-btn-danger {
  color: var(--danger);
  border-color: var(--danger-border);
}

.control-btn.wide {
  width: 100%;
  margin-top: 10px;
}

.complete-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.app-footer a {
  color: var(--sage-dark);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 380px) {
  .card {
    padding: 24px 18px;
  }
}

/* --- Phone landscape ---
   Short, wide viewport: split the workout card into two columns instead
   of stacking everything vertically, so the practice fits without
   scrolling. The pose image stays on the left; the pose name, cue,
   countdown/timer, and controls move to the right. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  body {
    padding: 10px;
    align-items: flex-start;
  }

  .app {
    max-width: 760px;
  }

  .card {
    padding: 16px 22px;
  }

  .tagline {
    margin-bottom: 16px;
  }

  .duration-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .workout-card {
    padding-top: 12px;
  }

  .workout-body {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 24px;
    text-align: left;
  }

  .workout-left {
    flex: 0 0 32%;
    margin-bottom: 0;
  }

  .workout-right {
    flex: 1;
    min-width: 0;
  }

  .figure-host {
    width: 120px;
    height: 140px;
    margin: 0 auto;
  }

  #pose-name {
    font-size: 1.25rem;
  }

  .cue {
    min-height: 0;
    margin-bottom: 10px;
  }

  .time-left {
    margin-bottom: 10px;
  }

  .countdown-number {
    font-size: 2.6rem;
    margin-bottom: 4px;
  }

  .countdown-next {
    font-size: 1.1rem;
    margin-bottom: 10px;
  }

  .app-footer {
    margin-top: 10px;
  }
}
