:root {
  --bg: #0F1113;
  --surface: #1A1D21;
  --surface-2: #24282D;
  --line: #2C3036;
  --line-soft: #22262B;
  --text: #F2F3F5;
  --muted: #A3A9B2;
  --accent: #C8F25C;
  --accent-ink: #0F1113;
  --accent-soft: #1E2414;
  --accent-line: #4A5A1F;
  --done: #17201A;
  --warn-soft: #2A2416;
  --warn-line: #5C4A1F;
  --warn: #F2C65C;
  --danger: #FF8A8A;
  --radius: 18px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Barlow Condensed', 'Inter', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
body.lock { overflow: hidden; }
a { color: var(--accent); }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 14px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.sm { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.spacer { width: 44px; }
.pad { padding: 12px 4px; }
.error { color: var(--danger); font-size: 14px; }
.splash { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); }

.display { font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1.05; letter-spacing: 0.2px; }
.display.md { font-size: 24px; }
.display.lg { font-size: 34px; }
.display.xl { font-size: 48px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }

/* ---------- estrutura ---------- */
.page {
  max-width: 560px; margin: 0 auto;
  padding: 16px 16px 32px;
  display: flex; flex-direction: column; gap: 16px;
}
body.has-nav .page { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 72px); }
.workout-page { padding-bottom: calc(150px + var(--safe-b)); }

.pagehead {
  max-width: 560px; margin: 0 auto;
  padding: calc(var(--safe-t) + 20px) 16px 4px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
}
.pagehead .display { font-size: 34px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(15, 17, 19, 0.92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: calc(var(--safe-t) + 8px) 12px 8px;
  display: flex; align-items: center; gap: 8px;
}
.topbar .title { flex: 1; font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workout-bar .clock { font-size: 28px; }
.workout-bar p.muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.section-title { font-size: 15px; font-weight: 600; margin-top: 4px; }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 600; }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.card h3 { font-size: 17px; font-weight: 600; }
.card h3 a { color: inherit; text-decoration: none; }
.hero { gap: 12px; padding: 20px; border-color: var(--line); }
.empty { color: var(--muted); text-align: center; padding: 28px 16px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { gap: 2px; padding: 12px; text-decoration: none; color: inherit; }

.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; }
.plain-list li:last-child { border-bottom: 0; }
.plain-list li > span:last-child { text-align: right; flex-shrink: 0; }

/* ---------- botões ---------- */
.btn {
  min-height: 48px; padding: 0 18px;
  border-radius: 14px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 16px; font-weight: 600; text-decoration: none;
  background: var(--surface-2); color: var(--text);
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; }
.btn.sm { min-height: 44px; padding: 0 12px; font-size: 14px; border-radius: 12px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--surface-2); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.dashed { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-weight: 500; }
.btn.danger-ghost { background: transparent; color: var(--danger); font-weight: 500; }

.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; border: 0; background: transparent; color: var(--text);
}
.icon-btn.sm { width: 40px; height: 40px; color: var(--muted); }
.icon-btn:disabled { opacity: .3; }
.icon-btn:active { background: var(--surface-2); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.tight { gap: 4px; }
.chip {
  min-height: 36px; padding: 0 14px; border-radius: 999px; flex-shrink: 0;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 14px; font-weight: 500;
}
.chip.sm { min-height: 32px; padding: 0 10px; font-size: 12px; }
.chip.on { background: var(--surface-2); color: var(--text); border-color: var(--muted); }
.hero .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); flex-shrink: 0; }

/* ---------- formulários ---------- */
.lbl { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.field {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 16px;
}
textarea.field { resize: vertical; }
.field:focus, .num:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.select-lg { font-family: var(--display); font-size: 22px; font-weight: 700; }
.check-line { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); min-height: 44px; }
.check-line input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- semana ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.week-day .dot {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 500;
}
.week-day .dot svg { width: 18px; height: 18px; }
.week-day.done .dot { background: var(--accent); color: var(--accent-ink); }
.week-day.today .dot { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

/* ---------- programas ---------- */
.prog-card { position: relative; flex-direction: row; align-items: center; gap: 12px; }
.prog-card > svg { color: var(--muted); flex-shrink: 0; }
.stretched::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius); }
.above { position: relative; z-index: 1; }

.day-card { gap: 12px; }
.day-head { display: flex; gap: 8px; align-items: center; }
.day-name { font-weight: 600; }
.ed-ex { border-top: 1px solid var(--line-soft); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ed-ex-top { display: flex; align-items: center; gap: 2px; }
.ed-ex-name {
  flex: 1; min-width: 0; min-height: 44px; text-align: left;
  background: transparent; border: 0; padding: 0;
  display: flex; flex-direction: column; justify-content: center; font-weight: 600; font-size: 15px;
}
.ed-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mini { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.mini .field { min-height: 44px; padding: 8px; text-align: center; }
.danger-zone { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }

/* ---------- treino ---------- */
.ex-card { gap: 12px; padding: 14px; }
.ex-head { display: flex; align-items: flex-start; gap: 4px; }
.ex-name { font-family: var(--display); font-size: 24px; font-weight: 700; line-height: 1.1; }
.ex-head .btn.sm { color: var(--muted); padding: 0 8px; }

.hint {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.4;
  background: var(--surface-2); border: 1px solid var(--line); color: #C9CED6;
}
.hint svg { flex-shrink: 0; margin-top: 1px; width: 20px; height: 20px; }
.hint.up { background: var(--accent-soft); border-color: var(--accent-line); color: #E6F5C4; }
.hint.up svg { color: var(--accent); }
.hint.hold { background: var(--warn-soft); border-color: var(--warn-line); }
.hint.hold svg { color: var(--warn); }

.sets { display: flex; flex-direction: column; gap: 6px; }
.set-row {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) 70px 58px 44px;
  gap: 8px; align-items: center; padding: 4px; border-radius: 12px;
}
.set-row.head { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding-bottom: 0; }
.set-row.done { background: var(--done); }
.set-n { text-align: center; font-weight: 600; }
.prev { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num {
  width: 100%; height: 44px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  text-align: center; font-size: 16px; font-weight: 600; padding: 0 4px;
}
.num::placeholder { color: #6B717A; font-weight: 500; }
.set-row.done .num { border-color: transparent; }
.check {
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: #6B717A;
  display: flex; align-items: center; justify-content: center;
}
.check svg { width: 20px; height: 20px; }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.add-set { align-self: flex-start; color: var(--muted); }
.shake { animation: shake .35s; border-color: var(--danger) !important; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- descanso ---------- */
#rest {
  position: fixed; left: 12px; right: 12px; z-index: 30;
  bottom: calc(12px + var(--safe-b));
  max-width: 536px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
body.has-nav #rest { bottom: calc(var(--nav-h) + var(--safe-b) + 12px); }
.rest-inner { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.rest-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rest-time { font-size: 30px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
#rest-bar { height: 100%; width: 0; background: var(--accent); transition: width .5s linear; }
#rest.finished { border-color: var(--accent); }
#rest.finished .rest-time { color: var(--accent); }

/* ---------- navegação ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + var(--safe-b)); padding: 6px 8px var(--safe-b);
  background: rgba(21, 23, 26, 0.96);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500; color: var(--muted); text-decoration: none;
}
.tabbar a.on { color: var(--accent); }
.resume-pill {
  position: fixed; z-index: 19; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 10px);
  max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.resume-pill span { overflow: hidden; text-overflow: ellipsis; }

/* ---------- painel de exercícios ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .6); }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto; max-height: 88dvh;
  background: var(--bg); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 12px 16px calc(16px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px;
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h3 { font-size: 17px; font-weight: 600; }
.sheet-list { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px 8px; }
.list-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 12px 0 6px; }
.ex-item {
  width: 100%; min-height: 52px; padding: 8px 12px; text-align: left;
  border: 0; border-radius: 12px; background: transparent;
  display: flex; flex-direction: column; justify-content: center; gap: 2px; font-size: 15px;
}
.ex-item:active, .ex-item:hover { background: var(--surface); }
details.group { border-top: 1px solid var(--line-soft); }
details.group summary { min-height: 48px; display: flex; align-items: center; font-weight: 500; cursor: pointer; list-style: none; padding: 0 4px; }
details.group summary::-webkit-details-marker { display: none; }
details.group summary::after { content: '+'; margin-left: auto; color: var(--muted); font-size: 20px; }
details.group[open] summary::after { content: '–'; }
.create-form { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }

/* ---------- progresso / histórico ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--accent); }
.chart .pt.last { stroke: var(--surface); stroke-width: 3; }
.list-card { padding: 4px 16px; gap: 0; }
.hist-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  min-height: 48px; padding: 8px 0; border-bottom: 1px solid var(--line-soft);
  color: var(--text); text-decoration: none; font-size: 15px;
}
.hist-row:last-child { border-bottom: 0; }
.hist-row span:last-child { text-align: right; font-size: 14px; }
.hist-card { flex-direction: row; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.hist-card > svg { color: var(--muted); flex-shrink: 0; }

/* ---------- login ---------- */
.login {
  max-width: 420px; margin: 0 auto; min-height: 100dvh;
  padding: calc(var(--safe-t) + 48px) 20px 32px;
  display: flex; flex-direction: column; gap: 16px; justify-content: center;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 12px; text-align: center; }

/* ---------- aviso rápido ---------- */
#toast {
  position: fixed; z-index: 60; left: 50%; top: calc(var(--safe-t) + 12px);
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 999px; max-width: calc(100% - 32px);
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 360px) {
  .set-row { grid-template-columns: 24px minmax(0, 1fr) 62px 52px 44px; gap: 6px; }
  .grid-3 .display.md { font-size: 20px; }
}

/* ---------- demonstração dos exercícios ---------- */
/* Todas as fotos têm 3:2 (480×320); o quadro também, então o enquadramento é sempre igual. */
.demo {
  position: relative; display: block; flex-shrink: 0;
  aspect-ratio: 3 / 2; overflow: hidden;
  border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
}
.demo .demo-icon { position: absolute; inset: 0; margin: auto; width: 46%; height: 70%; color: var(--accent); opacity: .9; }
.demo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.demo .f1 { animation: demo-swap 2.4s ease-in-out infinite; }
.demo.none img { display: none; }
@keyframes demo-swap { 0%, 40% { opacity: 0; } 50%, 90% { opacity: 1; } 100% { opacity: 0; } }
.demo.thumb { width: 64px; border-radius: 10px; }
@media (max-width: 400px) { .ex-head .btn.sm span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
.demo.mini { width: 60px; border-radius: 8px; }
.demo.big { width: 100%; border-radius: 14px; }
.demo-btn { padding: 0; border: 0; background: transparent; border-radius: 10px; flex-shrink: 0; }
.demo-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ex-head { gap: 10px; }
.ex-head .grow { align-self: center; }
.ex-item { flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; }
.ex-item-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sheet-current { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; background: var(--surface); }

/* ---------- montar meu programa ---------- */
.gen fieldset.q { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.gen legend { font-size: 15px; font-weight: 600; padding: 0; margin-bottom: 10px; }
.gen .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.gen .chip:disabled { opacity: .35; cursor: default; }
.hint .why { margin: 6px 0 8px; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
