:root {
  --bg: #0f1420;
  --panel: #1a2233;
  --panel-2: #212b40;
  --text: #e8ecf4;
  --muted: #93a0b8;
  --accent: #ff5a3c;
  --accent-soft: rgba(255, 90, 60, 0.35);
  --body-fill: #26324a;
  --muscle-fill: #546b91;
  --radius: 14px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 28px 16px 12px;
}
header h1 { font-size: 1.9rem; letter-spacing: 0.5px; }
.tagline { color: var(--muted); margin: 6px 0 16px; }

#search {
  width: min(420px, 90%);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid #33415e;
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
#search:focus { border-color: var(--accent); }

main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(320px, 560px);
  justify-content: center;
  gap: 24px;
  padding: 16px;
  width: 100%;
}

/* ---------- body panel ---------- */
#body-panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.view-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.view-toggle button {
  padding: 8px 22px;
  border-radius: 999px;
  border: 1px solid #33415e;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
}
.view-toggle button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.body-svg {
  width: 100%;
  max-width: 340px;
  height: auto;
  user-select: none;
}
.body-svg.hidden { display: none; }

.silhouette path, .silhouette ellipse {
  fill: var(--body-fill);
}

.muscle {
  cursor: pointer;
}
.muscle path, .muscle use {
  fill: var(--muscle-fill);
  stroke: #0f1420;
  stroke-width: 0.6;
  transition: fill 0.15s ease;
}
.muscle:hover path, .muscle:hover use { fill: #ff8a70; }
.muscle.selected path, .muscle.selected use { fill: var(--accent); }

.ab-line {
  stroke: #0f1420 !important;
  stroke-width: 1;
  fill: none !important;
  pointer-events: none;
}

#hover-label {
  margin-top: 10px;
  min-height: 1.4em;
  color: var(--accent);
  font-weight: 600;
  text-transform: capitalize;
}

/* ---------- list panel ---------- */
#list-panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  overflow-y: auto;
  max-height: 82vh;
}

#welcome { color: var(--muted); padding: 30px 10px; line-height: 1.6; }

#list-header h2 {
  text-transform: capitalize;
  margin-bottom: 12px;
  font-size: 1.4rem;
}
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #33415e;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.9rem;
}

#exercise-list { list-style: none; }
#exercise-list li {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  transition: transform 0.1s ease, background 0.15s ease;
}
#exercise-list li:hover {
  background: #2a3651;
  transform: translateX(3px);
}
#exercise-list .ex-name { font-weight: 600; }
#exercise-list .ex-meta { color: var(--muted); font-size: 0.82rem; margin-top: 3px; }

.badge {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: capitalize;
}
.badge.beginner { background: #14532d; color: #86efac; }
.badge.intermediate { background: #713f12; color: #fde047; }
.badge.expert { background: #7f1d1d; color: #fca5a5; }

.hidden { display: none !important; }

/* ---------- modal ---------- */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
#modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
#modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--panel-2);
  border: none;
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}
#modal-title { margin-bottom: 8px; padding-right: 40px; }
#modal-tags { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
#modal-tags .badge { background: var(--panel-2); color: var(--muted); }
#modal-tags .badge.beginner { background: #14532d; color: #86efac; }
#modal-tags .badge.intermediate { background: #713f12; color: #fde047; }
#modal-tags .badge.expert { background: #7f1d1d; color: #fca5a5; }

#anim-box {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  min-height: 200px;
}
#anim-img { width: 100%; display: block; }
#anim-dots {
  position: absolute;
  bottom: 8px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px;
}
#anim-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(0,0,0,0.25);
}
#anim-dots span.on { background: var(--accent); }

#modal-card h3 { margin: 18px 0 8px; font-size: 1.05rem; }
#modal-steps { padding-left: 20px; line-height: 1.65; color: #cdd6e4; }
#modal-steps li { margin-bottom: 8px; }
#modal-muscles { margin-top: 14px; color: var(--muted); font-size: 0.88rem; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 20px;
  line-height: 1.6;
}
footer a { color: var(--accent); }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  main { grid-template-columns: 1fr; }
  #list-panel { max-height: none; }
  .body-svg { max-width: 280px; }
}
