/* ============================================================
   Tokens.  Light is the base; dark overrides only the colours.
   Theme resolution: [data-theme] wins, otherwise the OS setting.
   ============================================================ */
:root {
  --bg:        #F7F7F5;
  --surface:   #FFFFFF;
  --surface-2: #F0F0ED;
  --surface-3: #E4E4DF;
  --line:      #E2E2DC;
  --line-soft: #EDEDE8;
  --text:      #14161A;
  --text-2:    #5C6270;
  --text-3:    #8B909C;
  --accent:    #D94A16;
  --accent-2:  #B93C0F;
  --accent-bg: #FCEDE6;
  --body:      #2B2F38;
  --equip:     #B4BAC4;
  --equip-solid: #6E7684;
  --ok:        #1F8A4C;
  --shadow:    0 1px 2px rgba(20, 22, 26, .05), 0 8px 24px -12px rgba(20, 22, 26, .16);
  --shadow-lg: 0 2px 6px rgba(20, 22, 26, .06), 0 24px 48px -20px rgba(20, 22, 26, .28);

  --r-sm: 10px; --r: 16px; --r-lg: 22px; --r-xl: 28px;
  --pad: 18px;
  --tap: 44px;
  --maxw: 820px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0A0B0D;
    --surface:   #131519;
    --surface-2: #1A1D22;
    --surface-3: #23272E;
    --line:      #24282F;
    --line-soft: #1B1E24;
    --text:      #F3F5F7;
    --text-2:    #9BA3B0;
    --text-3:    #6B7280;
    --accent:    #FF7A45;
    --accent-2:  #FFA075;
    --accent-bg: #2A1710;
    --body:      #C9D0DA;
    --equip:     #454C58;
    --equip-solid: #7D8593;
    --ok:        #3DD68C;
    --shadow:    0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -12px rgba(0, 0, 0, .7);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .5), 0 24px 48px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg:        #0A0B0D;
  --surface:   #131519;
  --surface-2: #1A1D22;
  --surface-3: #23272E;
  --line:      #24282F;
  --line-soft: #1B1E24;
  --text:      #F3F5F7;
  --text-2:    #9BA3B0;
  --text-3:    #6B7280;
  --accent:    #FF7A45;
  --accent-2:  #FFA075;
  --accent-bg: #2A1710;
  --body:      #C9D0DA;
  --equip:     #454C58;
  --equip-solid: #7D8593;
  --ok:        #3DD68C;
  --shadow:    0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -12px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .5), 0 24px 48px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); }

/* ============================================================
   App bar
   ============================================================ */
.bar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
  padding-top: env(safe-area-inset-top);
}
.bar.is-stuck { border-bottom-color: var(--line); }
.bar-in {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 6px;
  height: 56px; padding: 0 calc(var(--pad) - 8px);
}
.bar-title { font-size: 17px; font-weight: 640; letter-spacing: -.01em; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: none;
  display: grid; place-items: center; border-radius: 12px;
  color: var(--text-2); transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================
   Screens & transitions
   ============================================================ */
main { padding: 8px 0 168px; }
.screen { animation: rise .34s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.hero { padding: 10px 0 22px; }
.eyebrow { font-size: 12px; font-weight: 640; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.hero h1 { font-size: clamp(30px, 8vw, 40px); line-height: 1.06; letter-spacing: -.03em; font-weight: 700; margin-top: 8px; }
.hero p { color: var(--text-2); margin-top: 10px; font-size: 15px; max-width: 46ch; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-head h2 { font-size: 13px; font-weight: 660; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.section-head .count { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 52px; padding: 0 22px; width: 100%;
  border-radius: var(--r); font-size: 16px; font-weight: 620; letter-spacing: -.01em;
  background: var(--accent); color: #fff;
  transition: transform .14s var(--ease), filter .16s, box-shadow .16s;
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.985); }
.btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-ghost {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-row { display: flex; gap: 10px; }
.btn-sm { min-height: 40px; font-size: 14px; padding: 0 14px; width: auto; border-radius: 12px; }

/* ============================================================
   Search
   ============================================================ */
.search { position: relative; }
.search > svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 19px; height: 19px; fill: none; stroke: var(--text-3); stroke-width: 2;
  stroke-linecap: round; pointer-events: none; }
.search input {
  width: 100%; height: 50px; padding: 0 50px 0 44px; border-radius: 999px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  font: inherit; font-size: 16px; /* 16px or iOS zooms the page on focus */
  -webkit-appearance: none; appearance: none; transition: border-color .16s;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { outline: none; border-color: var(--accent); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: var(--tap); height: var(--tap); border-radius: 999px;
  display: grid; place-items: center; color: var(--text-2);
}
.search-clear:hover { background: var(--surface-2); color: var(--text); }
.search-clear svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ============================================================
   Filter chips
   ============================================================ */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 4px calc(var(--pad)) 4px; margin: 0 calc(var(--pad) * -1); scroll-padding: var(--pad); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 15px; border-radius: 999px;
  font-size: 14px; font-weight: 560; white-space: nowrap;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--line);
  transition: all .16s var(--ease);
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip:active { transform: scale(.96); }

/* ============================================================
   Exercise cards
   ============================================================ */
.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid { grid-template-columns: 1fr 1fr; } }

.card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 12px;
  transition: transform .18s var(--ease), border-color .18s, box-shadow .18s;
}
.card:hover { border-color: var(--surface-3); box-shadow: var(--shadow); }
.card:active { transform: scale(.985); }
.card-body { flex: 1; min-width: 0; }
.card-name { font-size: 16px; font-weight: 620; letter-spacing: -.012em; line-height: 1.25; }
.card-meta { display: flex; align-items: center; gap: 7px; margin-top: 7px; flex-wrap: wrap; }
.card-sub { font-size: 13px; color: var(--text-3); margin-top: 5px; }
.card-go { color: var(--text-3); flex: none; }
.card-go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.thumb {
  flex: none; width: 104px; height: 104px; border-radius: 15px;
  background: var(--surface-2); overflow: hidden; position: relative;
}
.thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot-num {
  position: absolute; left: 5px; top: 5px; z-index: 2;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700;
  background: var(--accent); color: #fff;
}
/* The bodyweight finisher: an extra movement on top of the chosen length, so
   it is marked as a bonus rather than numbered into the sequence. */
.slot.is-bonus { border-style: dashed; }
.slot.is-bonus .slot-num { background: var(--equip-solid); }

/* Chips that label the target muscle and the kit you need */
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 23px; padding: 0 9px;
  border-radius: 7px; font-size: 12px; font-weight: 600; letter-spacing: .005em;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.tag-muscle { background: var(--accent-bg); color: var(--accent); }
.tag-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
/* Compound vs isolation. Outlined rather than filled, so it reads as a
   property of the movement and not as another chip like the equipment tag. */
.tag-pattern {
  background: transparent; border: 1px solid var(--line); color: var(--text-2);
  /* A secondary attribute, and it shares a narrow column with the muscle tag
     and the rep line on a phone — so it is deliberately the smallest chip. */
  height: 21px; padding: 0 7px; font-size: 11px;
}

/* ============================================================
   Muscle-group tiles (home)
   ============================================================ */
.tiles { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.tile {
  position: relative; text-align: left; padding: 16px; min-height: 116px;
  border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .18s var(--ease), border-color .18s, box-shadow .18s;
}
.tile:hover { box-shadow: var(--shadow); }
.tile:active { transform: scale(.98); }
.tile-name { font-size: 19px; font-weight: 680; letter-spacing: -.02em; }
.tile-sub { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.tile.is-soon { opacity: .5; }
.tile-art { position: absolute; right: 10px; top: 10px; width: 52px; height: 60px; opacity: .9; }
.tile.is-live { border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); }

/* ============================================================
   Detail screen
   ============================================================ */
.stage {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 8px; margin-top: 4px;
  display: grid; gap: 8px; grid-template-columns: 1fr;
}
@media (min-width: 620px) { .stage { grid-template-columns: 1.35fr .95fr; } }
.stage-fig { background: var(--surface-2); border-radius: var(--r-lg); position: relative; overflow: hidden; }
.stage-fig.photo { aspect-ratio: 3 / 2; cursor: pointer; }
.stage-anat {
  background: var(--surface-2); border-radius: var(--r-lg); padding: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.stage-anat .anatomy { width: 100%; max-width: 150px; height: auto; }
.anat-label { text-align: center; }
.anat-label .n { font-size: 15px; font-weight: 640; letter-spacing: -.01em; color: var(--accent); }
.anat-label .b { font-size: 12.5px; color: var(--text-3); margin-top: 3px; line-height: 1.42; }
.demo-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .55s var(--ease);
}
.demo-img.is-active { opacity: 1; }
.pose-label {
  position: absolute; left: 12px; top: 12px; z-index: 2; pointer-events: none;
  font-size: 12px; font-weight: 640; letter-spacing: .04em; text-transform: uppercase;
  color: #fff; background: rgba(10, 11, 13, .55);
  backdrop-filter: blur(6px);
  padding: 4px 10px; border-radius: 999px;
}

.play-toggle {
  position: absolute; right: 10px; bottom: 10px; z-index: 2; width: 38px; height: 38px;
  border-radius: 50%; display: grid; place-items: center;
  background: rgba(10, 11, 13, .55); backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .18); color: #fff;
}
.play-toggle svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; margin-top: 12px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 12px; min-width: 0; }
.fact dt { font-size: 10.5px; font-weight: 640; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; }
.fact dd { margin: 5px 0 0; font-size: 13.5px; font-weight: 600; letter-spacing: -.012em; line-height: 1.3; overflow-wrap: anywhere; }

.steps { counter-reset: s; display: grid; gap: 12px; margin-top: 12px; }
.step { display: flex; gap: 13px; align-items: flex-start; }
.step::before {
  counter-increment: s; content: counter(s);
  flex: none; width: 25px; height: 25px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-2);
  font-size: 12.5px; font-weight: 680; display: grid; place-items: center; margin-top: 1px;
}
.step p { font-size: 15px; line-height: 1.5; color: var(--text); }

.cues { display: grid; gap: 8px; margin-top: 12px; }
.cue {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--accent-bg); border-radius: var(--r); padding: 11px 13px;
  font-size: 14px; line-height: 1.45; color: var(--text);
}
.cue svg { width: 16px; height: 16px; flex: none; margin-top: 2px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================
   Workout screen
   ============================================================ */
.progress {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 14px;
}
.ring { width: 46px; height: 46px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }  /* cap is set per-element, so 0% shows nothing */
.ring .trk { stroke: var(--surface-3); }
.ring .val { stroke: var(--accent); transition: stroke-dasharray .45s var(--ease); }
.progress-txt { flex: 1; min-width: 0; }
.progress-txt .t { font-size: 15px; font-weight: 640; letter-spacing: -.01em; }
.progress-txt .s { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.slot {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 10px; gap: 8px; transition: opacity .25s, border-color .2s;
}
.slot.is-done { opacity: .48; }
.slot.is-done .slot-name { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.slot-open { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; }
.slot .thumb { width: 72px; height: 72px; border-radius: 13px; }
.slot-name { font-size: 15.5px; font-weight: 620; letter-spacing: -.012em; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slot-body { flex: 1; min-width: 0; }
.slot-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; min-width: 0; flex-wrap: wrap; }
.slot-meta .tag { flex: none; }
.slot-reps { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-open { gap: 11px; }
.tick {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center;
  color: transparent; transition: all .18s var(--ease);
}
.tick svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.slot.is-done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.tick:active { transform: scale(.88); }
.slot-swap { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); }
.slot-swap:hover { background: var(--surface-2); color: var(--text); }
.slot-swap svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.stack { display: grid; gap: 10px; }

.empty { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty .e-t { font-size: 16px; font-weight: 600; color: var(--text-2); }
.empty .e-s { font-size: 14px; margin-top: 6px; }

/* Sticky action bar at the bottom of the group screen */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 26px var(--pad) calc(12px + env(safe-area-inset-bottom));
  /* Tall enough to cover the length selector as well as the button, so list
     content does not show through between them. */
  background: linear-gradient(to top,
    var(--bg) 0%, var(--bg) 62%,
    color-mix(in srgb, var(--bg) 86%, transparent) 82%,
    transparent 100%);
  pointer-events: none;
}
.dock > * { max-width: var(--maxw); margin: 0 auto; pointer-events: auto; }
.dock-in { display: flex; flex-direction: column; gap: 9px; }

.seg { display: flex; align-items: center; gap: 6px; align-self: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 4px 4px 13px; box-shadow: var(--shadow); }
.seg-label { font-size: 12.5px; font-weight: 560; color: var(--text-3); margin-right: 2px; }
.seg-btn { width: 32px; height: 32px; border-radius: 50%; font-size: 14px; font-weight: 640;
  color: var(--text-2); transition: background .16s, color .16s; }
.seg-btn[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.seg-btn:active { transform: scale(.92); }

/* ============================================================
   Anatomy map
   ============================================================ */
.anatomy .an-body { fill: color-mix(in srgb, var(--text-3) 26%, var(--surface-2)); }
.anatomy .an-limb { opacity: .55; }
.anatomy .an-edge { fill: none; stroke: var(--text-3); stroke-width: 1.6; opacity: .5; }
.anatomy .an-spine { stroke: var(--text-3); stroke-width: 1.2; opacity: .3; stroke-dasharray: 2 5; }
.anatomy .an-muscle { fill: var(--text-2); opacity: .22; transition: opacity .3s, fill .3s; }
.anatomy .an-muscle.is-secondary { fill: var(--accent); opacity: .3; }
.anatomy .an-muscle.is-primary { fill: var(--accent); opacity: .95; animation: throb 2.6s var(--ease) infinite; }
@keyframes throb { 0%, 100% { opacity: .78; } 50% { opacity: 1; } }

/* Small inline anatomy badge used in section headers */
.anat-mini { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; }
.anat-mini svg { width: 100%; height: 100%; display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
