:root {
  --bg: #0b0f0d;
  --surface: #121713;
  --surface-2: #1a201b;
  --border: #242c26;
  --text: #f2f5f1;
  --muted: #8a938c;
  --accent: #d6ff4f;
  --accent-dim: rgba(214, 255, 79, 0.12);
  --danger: #ff6b6b;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

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

html, body {
  height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overscroll-behavior-y: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 20px 20px calc(92px + env(safe-area-inset-bottom));
  position: relative;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  letter-spacing: -0.3px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(214, 255, 79, 0.7);
}

.topbar-date {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* ---------- Screens ---------- */
.screen {
  animation: fadeIn 0.25s ease;
}

.screen.hidden {
  display: none;
}

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

/* ---------- Hero ---------- */
.hero {
  padding: 6px 0 20px;
}

.hero.small {
  padding-bottom: 14px;
}

.hero-eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}

.hero-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.15;
}

.hero-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Week strip ---------- */
.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 11px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.week-day small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.day-badge {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
}

.week-day.training .day-badge {
  background: var(--accent);
  color: #0b0f0d;
}

.week-day.today {
  border-color: var(--accent);
}

.week-day.training.today .day-badge {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

.week-day:active {
  transform: scale(0.94);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.card-head h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.card-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}

/* ---------- Exercises ---------- */
.exercises {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.exercise {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 8px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.exercise:active {
  transform: scale(0.98);
}

.exercise-thumb {
  width: 64px;
  height: 46px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--surface);
}

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

.exercise-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exercise-meta {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.play-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11px;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  border-radius: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.2s;
}

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

.btn-primary {
  background: var(--accent);
  color: #0b0f0d;
}

.btn-primary:disabled {
  opacity: 0.4;
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 18px;
}

/* ---------- Progress ---------- */
.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* ---------- Library ---------- */
.workout-card-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.workout-card-item .day-tag {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-dim);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.workout-card-item h3 {
  font-size: 15px;
  font-weight: 700;
}

.workout-card-item p {
  font-size: 12px;
  color: var(--muted);
}

.workout-card-item .arrow {
  margin-left: auto;
  color: var(--muted);
}

/* ---------- Timer ---------- */
.timer-card {
  text-align: center;
  padding: 26px 18px;
}

.rounds-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.rounds-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.rounds-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.phase {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 4px;
}

.timer {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -3px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin: 6px 0 20px;
}

.timer.running-work {
  color: var(--accent);
}

.timer.running-rest {
  color: var(--muted);
}

.timer-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ---------- Settings ---------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
}

.setting-row:last-child {
  border-bottom: none;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stepper-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.stepper-btn:active {
  transform: scale(0.94);
}

.stepper-val {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(18, 23, 19, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  z-index: 50;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 8px;
  cursor: pointer;
  border-radius: 14px;
  transition: color 0.2s;
}

.tab.active {
  color: var(--accent);
}

.tab.active svg {
  filter: drop-shadow(0 0 8px rgba(214, 255, 79, 0.5));
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.credit {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 0 4px;
}

/* ---------- Detail screen ---------- */
.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0 18px;
}

.back-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: transform 0.12s;
}

.back-btn:active {
  transform: scale(0.94);
}

/* ---------- Video modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 7, 0.96);
  display: flex;
  flex-direction: column;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.modal-close:active {
  transform: scale(0.94);
}

.modal-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-width: 640px;
  margin: 0 auto;
}

.modal-video iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}