:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --card: #1c2333;
  --card-hover: #242d42;
  --border: #2d3648;
  --text: #e6edf3;
  --text-dim: #8b98ad;
  --accent: #ff6b35;
  --accent-2: #f7c948;
  --green: #3fb950;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1a2337 0%, var(--bg) 55%) fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}

.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.35rem; margin-right: auto; }
.logo-icon { font-size: 1.5rem; }
.logo-text span { color: var(--accent); }

.stats { display: flex; gap: 14px; }
.stat {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 14px 6px 10px;
}
.stat-icon { font-size: 1.2rem; }
.stat-body { display: flex; flex-direction: column; line-height: 1.1; }
.stat-value { font-weight: 800; font-size: 1.05rem; }
.stat-label { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }

.badge-btn {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1205;
  border: none;
  font-weight: 700;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.badge-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(255, 107, 53, 0.35); }
.badge-pill {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.8rem;
}

/* ---------- Layout ---------- */
.container { max-width: 980px; margin: 0 auto; padding: 32px 20px 60px; }

.hero { text-align: center; margin-bottom: 28px; }
.hero h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.02em; }
.gradient-text {
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sub { color: var(--text-dim); font-size: 1.05rem; margin-top: 6px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.card-title:nth-of-type(1)::before { content: ''; }

/* ---------- Equipment ---------- */
.equipment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}
.equip-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--bg-soft);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 16px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  position: relative;
}
.equip-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.equip-card.selected {
  border-color: var(--accent);
  background: linear-gradient(160deg, rgba(255, 107, 53, 0.14), rgba(247, 201, 72, 0.08));
  box-shadow: 0 4px 16px rgba(255, 107, 53, 0.18);
}
.equip-card .equip-icon { font-size: 2rem; }
.equip-card .equip-name { font-weight: 600; font-size: 0.92rem; text-align: center; }
.equip-card .equip-tag {
  font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em;
}
.equip-card .check {
  position: absolute; top: 8px; right: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: none; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800;
}
.equip-card.selected .check { display: flex; }

/* ---------- Time slider ---------- */
.time-row { display: flex; align-items: center; gap: 18px; margin-bottom: 6px; }
input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 27%), var(--border) var(--fill, 27%));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--accent);
  cursor: pointer;
}
.time-display {
  font-size: 1.5rem; font-weight: 800;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 18px;
  min-width: 96px;
  text-align: center;
}
.time-display span { color: var(--accent); }
.time-scale { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 0.72rem; padding: 4px 2px 0; margin-bottom: 22px; }

/* ---------- Difficulty ---------- */
.difficulty-row { margin-bottom: 20px; }
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.seg {
  flex: 1;
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.seg:hover { border-color: var(--blue); color: var(--text); }
.seg.active {
  border-color: var(--purple);
  color: #fff;
  background: linear-gradient(160deg, rgba(188, 140, 255, 0.2), rgba(88, 166, 255, 0.12));
  box-shadow: 0 4px 14px rgba(188, 140, 255, 0.15);
}

/* ---------- Generate ---------- */
.generate-btn {
  width: 100%;
  padding: 16px;
  font-size: 1.15rem;
  font-weight: 800;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #e8503a);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 20px rgba(232, 80, 58, 0.3);
}
.generate-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(232, 80, 58, 0.4); }
.generate-btn:active { transform: translateY(0); }
.hint { color: var(--text-dim); font-size: 0.82rem; text-align: center; margin-top: 12px; }

/* ---------- Workout result ---------- */
.workout-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.workout-meta { color: var(--text-dim); font-size: 0.9rem; margin-top: 4px; }
.workout-summary { text-align: right; }
.sum-stat { font-size: 0.85rem; color: var(--text-dim); }
.sum-stat b { color: var(--text); font-size: 1.3rem; display: block; }

.exercise-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.exercise-item {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  transition: border-color 0.15s ease;
}
.exercise-item:hover { border-color: var(--blue); }
.exercise-item.done { opacity: 0.75; }
.exercise-item.done .ex-info h3 { text-decoration: line-through; color: var(--text-dim); }

.ex-illustration {
  flex-shrink: 0;
  width: 92px; height: 92px;
  background: linear-gradient(160deg, #232b3d, #1a2130);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.ex-illustration svg { width: 84px; height: 84px; }

.ex-info { flex: 1; min-width: 0; }
.ex-info h3 { font-size: 1.05rem; font-weight: 700; }
.ex-tags { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.tag {
  font-size: 0.7rem; font-weight: 600;
  padding: 2px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tag.muscle { background: rgba(88, 166, 255, 0.15); color: var(--blue); }
.tag.diff-beginner { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.tag.diff-intermediate { background: rgba(247, 201, 72, 0.15); color: var(--accent-2); }
.tag.diff-advanced { background: rgba(255, 107, 53, 0.2); color: var(--accent); }
.tag.duration { background: rgba(188, 140, 255, 0.15); color: var(--purple); }

.ex-desc { color: var(--text-dim); font-size: 0.88rem; }
.ex-set { color: var(--accent-2); font-weight: 700; font-size: 0.85rem; margin-top: 6px; }

.complete-btn {
  width: 100%;
  padding: 15px;
  font-size: 1.05rem;
  font-weight: 800;
  font-family: inherit;
  color: #0a1f0d;
  background: linear-gradient(135deg, #4ade80, #3fb950);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 20px rgba(63, 185, 80, 0.3);
}
.complete-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(63, 185, 80, 0.4); }
.complete-btn:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

/* ---------- Badge modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%; max-width: 620px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h2 { font-size: 1.3rem; }
.modal-close {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  width: 32px; height: 32px; border-radius: 10px;
  font-size: 1.2rem; cursor: pointer; font-family: inherit;
}
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  opacity: 0.4;
  filter: grayscale(1);
  transition: all 0.2s ease;
}
.badge-item.unlocked { opacity: 1; filter: none; border-color: rgba(247, 201, 72, 0.5); box-shadow: 0 4px 14px rgba(247, 201, 72, 0.12); }
.badge-item .b-icon { font-size: 1.8rem; }
.badge-item .b-name { font-weight: 700; font-size: 0.85rem; margin-top: 4px; }
.badge-item .b-desc { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }
.badge-item.locked .b-desc::after { content: ' — locked'; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card);
  border: 1px solid var(--accent-2);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  font-weight: 600;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { text-align: center; color: var(--text-dim); font-size: 0.82rem; margin-top: 30px; }

.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.6rem; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .stats { order: 3; width: 100%; justify-content: space-between; }
  .workout-summary { text-align: left; }
  .ex-illustration { width: 76px; height: 76px; }
  .ex-illustration svg { width: 70px; height: 70px; }
}
