:root {
  --bg: #0a0a0f;
  --card: rgba(255, 255, 255, 0.045);
  --card-2: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f4f7;
  --muted: #8c8c9c;
  --red: #ff2d55;
  --red-2: #ff6b35;
  --green: #30d158;
  --yellow: #ffd60a;
  --muscle: #2a2a36;
  --neutral: #1c1c25;
  --grad: linear-gradient(135deg, #ff2d55 0%, #ff6b35 100%);
  --radius: 20px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 15px; line-height: 1.5; min-height: 100vh;
  padding-bottom: 96px; overflow-x: hidden;
}
.bg-glow {
  position: fixed; top: -20vh; left: 0; right: 0; height: 70vh; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 45, 85, 0.22), transparent 70%);
  filter: blur(20px);
}
h1, h2, h3, .display { font-family: "Space Grotesk", Inter, sans-serif; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 34px; line-height: 1.05; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: var(--text); }

/* env(safe-area-inset-*) keeps content clear of the iPhone status bar / Dynamic Island when opened from the home screen */
#app { max-width: 520px; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 20px calc(16px + env(safe-area-inset-left)); animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.gap { height: 16px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--red); }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.back {
  width: 40px; height: 40px; border-radius: 14px; background: var(--card-2);
  display: grid; place-items: center; font-size: 18px; border: 1px solid var(--line); flex: none;
}
.logo { font-family: "Space Grotesk"; font-weight: 700; font-size: 20px; letter-spacing: .04em; display: flex; align-items: center; gap: 10px; }
.logo .grad-text { margin-left: -4px; }
.logo-ic { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 6px 18px -6px rgba(255,45,85,.8); }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; backdrop-filter: blur(10px);
}
.card.hero {
  background: linear-gradient(160deg, rgba(255,45,85,.22), rgba(255,107,53,.08) 60%, rgba(255,255,255,.03));
  border-color: rgba(255, 45, 85, .35); position: relative; overflow: hidden;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--card-2); border: 1px solid var(--line);
}
.pill.red { background: rgba(255,45,85,.15); border-color: rgba(255,45,85,.4); color: #ff8aa1; }
.pill.green { background: rgba(48,209,88,.12); border-color: rgba(48,209,88,.4); color: #7ee59b; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px; border-radius: 16px; font-weight: 700; background: var(--card-2);
  border: 1px solid var(--line); transition: transform .1s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); border: 0; box-shadow: 0 8px 30px -8px rgba(255,45,85,.7); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; border-radius: 12px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff6b81; }

/* ---------- parts grid ---------- */
.parts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.part {
  position: relative; border-radius: var(--radius); padding: 16px; min-height: 128px;
  background: var(--card); border: 1px solid var(--line); overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; transition: transform .15s;
}
.part:active { transform: scale(.97); }
.part::after {
  content: ""; position: absolute; width: 120px; height: 120px; right: -40px; top: -40px;
  background: radial-gradient(closest-side, var(--c), transparent); opacity: .45;
}
.part .emoji { font-size: 28px; }
.part .name { font-family: "Space Grotesk"; font-weight: 700; font-size: 18px; }
.part.full { grid-column: span 2; min-height: 150px; border-color: rgba(255,45,85,.4);
  background: linear-gradient(135deg, rgba(255,45,85,.25), rgba(255,107,53,.1)); }

/* ---------- equipment tabs ---------- */
.seg { display: flex; gap: 6px; padding: 5px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.seg button {
  flex: 1; padding: 10px 6px; border-radius: 14px; font-weight: 600; font-size: 13px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.seg button span { font-size: 18px; }
.seg button.on { background: var(--grad); color: #fff; box-shadow: 0 6px 20px -8px rgba(255,45,85,.8); }

/* ---------- exercise list ---------- */
.ex-item { display: flex; gap: 12px; align-items: center; padding: 12px; }
.ex-item .thumb { width: 74px; flex: none; }
.ex-item .info { flex: 1; min-width: 0; }
.ex-item .name { font-weight: 700; font-size: 16px; }
.ex-item .chev { color: var(--muted); font-size: 20px; }
.ex-item.done { border-color: rgba(48,209,88,.4); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ---------- body diagram ---------- */
.body { display: flex; justify-content: center; gap: 4px; }
.body .fig { width: 50%; max-width: 180px; height: auto; overflow: visible; }
.body.small { gap: 0; }
.body.small .fig { width: 50%; }
.fig .neutral { fill: var(--neutral); }
.fig .m { fill: var(--muscle); transition: fill .3s, opacity .3s; }
.fig .m path { stroke: var(--bg); stroke-width: 1.2; stroke-linejoin: round; }
.fig .m.p { fill: var(--red); filter: var(--glow); }
.fig .m.s { fill: #ff6b81; opacity: .5; }
.fig .detail path { stroke: var(--bg); stroke-width: 1.3; fill: none; opacity: .8; }
.fig .figlabel { fill: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .2em; text-anchor: middle; font-family: Inter; }
.body-card { padding: 18px 12px 10px; background: radial-gradient(ellipse at 50% 40%, rgba(255,45,85,.10), transparent 70%), var(--card); }
.legend { display: flex; justify-content: center; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- accordion (details) ---------- */
details.acc { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
details.acc + details.acc { margin-top: 10px; }
details.acc summary {
  list-style: none; padding: 16px; display: flex; align-items: center; gap: 12px; font-weight: 700; cursor: pointer;
}
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary .ic {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--card-2); flex: none;
}
details.acc summary::after { content: "＋"; margin-left: auto; color: var(--muted); transition: transform .25s; font-size: 18px; }
details.acc[open] summary::after { transform: rotate(45deg); color: var(--red); }
details.acc[open] { border-color: rgba(255,45,85,.35); }
details.acc .acc-body { padding: 0 16px 16px; color: #d4d4dc; animation: fade .25s ease; }
details.acc.tip summary .ic { background: rgba(255,214,10,.15); }
details.acc.tip[open] { border-color: rgba(255,214,10,.4); }
ol.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: s; }
ol.steps li { counter-increment: s; position: relative; padding-left: 36px; margin: 10px 0; }
ol.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 8px;
  background: rgba(255,45,85,.15); color: #ff8aa1; font-weight: 700; font-size: 12px; display: grid; place-items: center;
}

/* ---------- settings gear ---------- */
.gear {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted); transition: color .2s, transform .3s;
}
.gear:active { transform: rotate(60deg); color: var(--text); }

/* ---------- warm-up / cool-down cards ---------- */
details.acc.warm { border-color: rgba(255,107,53,.35); background: linear-gradient(135deg, rgba(255,107,53,.12), rgba(255,255,255,.03)); }
details.acc.warm summary .ic { background: rgba(255,107,53,.18); }
details.acc.cool { border-color: rgba(100,210,255,.3); background: linear-gradient(135deg, rgba(100,210,255,.08), rgba(255,255,255,.03)); }
details.acc.cool summary .ic { background: rgba(100,210,255,.14); }
details.acc.cool[open] { border-color: rgba(100,210,255,.5); }
.cool-card { border-color: rgba(100,210,255,.25); }

/* ---------- personal notes ---------- */
.you-note {
  display: flex; gap: 12px; margin-top: 10px; padding: 14px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,214,10,.10), rgba(255,45,85,.06)); border: 1px solid rgba(255,214,10,.3);
  font-size: 14px; color: #e8e8ee;
}
.you-note > span { font-size: 20px; }
.you-note b { display: block; color: #ffd60a; margin-bottom: 2px; }
.pill.star { background: rgba(255,214,10,.12); border-color: rgba(255,214,10,.4); color: #ffe066; }
.part.boost { min-height: 110px; border-color: rgba(255,159,10,.35); background: linear-gradient(135deg, rgba(255,159,10,.16), rgba(255,255,255,.03)); }

/* ---------- exercise animation ---------- */
.move-wrap {
  margin: 2px 0 6px; padding: 8px 8px 6px; border-radius: 16px; border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 70%, rgba(255,45,85,.12), transparent 70%), rgba(0,0,0,.25);
}
.move-wrap svg.move { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto; }
.move-cap { text-align: center; font-size: 11px; color: var(--muted); letter-spacing: .04em; margin-top: 2px; }

/* ---------- stretch card ---------- */
.stretch { display: flex; gap: 12px; align-items: flex-start; }
.stretch + .stretch { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.stretch .timer-btn { flex: none; min-width: 76px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.section-title h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.section-title .line { flex: 1; height: 1px; background: var(--line); }

/* ---------- logger ---------- */
.target { display: flex; gap: 8px; }
.target .stat { flex: 1; text-align: center; padding: 10px 6px; border-radius: 14px; background: var(--card-2); }
.target .stat b { display: block; font-family: "Space Grotesk"; font-size: 20px; }
.target .stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.field { min-width: 0; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.stepper { display: flex; align-items: center; background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.stepper button { width: 40px; height: 50px; font-size: 20px; color: var(--muted); }
.stepper button:active { background: rgba(255,255,255,.08); }
.stepper input {
  flex: 1; min-width: 0; width: 100%; text-align: center; background: transparent; border: 0; outline: 0;
  font-family: "Space Grotesk"; font-size: 22px; font-weight: 700; height: 50px;
}
.feel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.feel button {
  padding: 10px 4px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; font-size: 12px; font-weight: 600; gap: 2px;
}
.feel button span { font-size: 22px; }
.feel button.on { border-color: var(--red); background: rgba(255,45,85,.15); }
.sets { margin-top: 4px; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .n { width: 28px; height: 28px; border-radius: 9px; background: var(--card-2); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.set-row .v { flex: 1; font-family: "Space Grotesk"; font-weight: 600; font-size: 17px; }
.set-row .x { color: var(--muted); padding: 4px 8px; }
.advice {
  display: flex; gap: 12px; padding: 14px; border-radius: 16px; margin-top: 12px;
  background: rgba(255,214,10,.08); border: 1px solid rgba(255,214,10,.3); animation: fade .3s ease;
}
.advice.good { background: rgba(48,209,88,.08); border-color: rgba(48,209,88,.3); }
.advice.bad { background: rgba(255,45,85,.1); border-color: rgba(255,45,85,.35); }
.advice .ai { font-size: 22px; }
.advice b { display: block; margin-bottom: 2px; }

/* ---------- energy check / modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center; animation: fadein .2s ease;
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 520px; background: #14141c; border: 1px solid var(--line); border-bottom: 0;
  border-radius: 28px 28px 0 0; padding: 22px 18px calc(24px + env(safe-area-inset-bottom));
  animation: up .3s cubic-bezier(.2,.9,.3,1); max-height: 90vh; overflow-y: auto;
}
@keyframes up { from { transform: translateY(100%); } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: -8px auto 16px; }
.energy { display: grid; gap: 8px; }
.energy button {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line); text-align: left;
}
.energy button span { font-size: 26px; }
.energy button:active { border-color: var(--red); }

/* ---------- rest timer ---------- */
.rest {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 999px;
  background: #1a1a24; border: 1px solid rgba(255,45,85,.4); box-shadow: 0 10px 40px -10px rgba(255,45,85,.6);
  font-weight: 700; animation: fade .25s ease;
}
.rest .t { font-family: "Space Grotesk"; font-size: 22px; min-width: 56px; }
.rest .bar { width: 90px; height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.rest .bar i { display: block; height: 100%; background: var(--grad); transition: width 1s linear; }
.hidden { display: none !important; }

.toast {
  position: fixed; top: calc(16px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60;
  background: #1f1f2a; border: 1px solid var(--line); padding: 10px 16px; border-radius: 14px; font-weight: 600;
  animation: fade .2s ease; max-width: 90vw;
}

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10,10,15,.82); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0; border-radius: 12px;
}
.tabbar a span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabbar a.on { color: var(--text); }
.tabbar a.on span { filter: none; opacity: 1; }

/* ---------- stats / history ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats .card { text-align: center; padding: 14px 8px; }
.stats b { display: block; font-family: "Space Grotesk"; font-size: 24px; }
.stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.hist-ex { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.week-dots { display: flex; gap: 6px; }
.week-dots i { flex: 1; height: 30px; border-radius: 8px; background: var(--card-2); }
.week-dots i.on { background: var(--grad); box-shadow: 0 4px 14px -4px rgba(255,45,85,.8); }

.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { padding: 8px 12px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.chips button.on { background: var(--grad); border-color: transparent; }

/* ---------- login gate ---------- */
body.auth-pending #app, body.auth-pending .tabbar, body.auth-pending #ptr { display: none; }
#gate {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 0%, rgba(255,45,85,.25), transparent 60%), var(--bg);
  overflow-y: auto;
}
.gate-card { width: 100%; max-width: 380px; text-align: center; animation: fade .3s ease; }
.gate-card h2 { font-size: 30px; margin: 8px 0 4px; }
.gate-card p { margin: 0 0 22px; }
.gate-logo {
  width: 84px; height: 84px; margin: 0 auto; border-radius: 24px; display: block;
  box-shadow: 0 12px 40px -10px rgba(255,45,85,.8);
}
.lg-field { display: block; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.lg-field input {
  display: block; width: 100%; margin-top: 6px; padding: 14px 16px; border-radius: 14px; font-size: 16px;
  background: var(--card-2); border: 1px solid var(--line); outline: none;
}
.lg-field input:focus { border-color: var(--red); }
.lg-err { min-height: 20px; margin: 4px 0 10px; font-size: 13px; color: #ff8aa1; }
.lg-lock { display: flex; gap: 10px; align-items: center; text-align: left; padding: 12px 14px; margin-bottom: 10px;
  border-radius: 14px; background: rgba(255,45,85,.1); border: 1px solid rgba(255,45,85,.35); font-size: 13px; }
.lg-lock[hidden] { display: none; }
.lg-left { margin: 12px 0 4px; }
.lg-left.warn { color: #ffd60a; }
.cloud { margin-top: 4px; }
.cloud.ok { color: #7ee59b; }
.cloud.wait { color: var(--muted); }
.cloud.err { color: #ff8aa1; }

/* ---------- pull to refresh ---------- */
body { overscroll-behavior-y: contain; }
.ptr {
  position: fixed; top: env(safe-area-inset-top); left: 50%; z-index: 70; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; background: #1a1a24; border: 1px solid rgba(255,45,85,.4);
  font-size: 13px; font-weight: 700; color: var(--muted); pointer-events: none;
  transform: translate(-50%, -60px); opacity: 0;
}
.ptr .ptr-ic { color: var(--red); font-size: 16px; display: inline-block; transition: transform .2s; }
.ptr.ready { color: var(--text); }
.ptr.ready .ptr-ic { transform: rotate(180deg); }
.ptr.spin .ptr-ic { animation: spin .7s linear infinite; }
.ptr.back { transition: transform .25s ease, opacity .25s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

.next-card { display: flex; align-items: center; gap: 12px; }
.empty { text-align: center; padding: 40px 20px; }
.empty .big { font-size: 48px; }
