:root {
  --bg: #0f1512;
  --surface: #172019;
  --surface-2: #1f2a22;
  --line: #2a372d;
  --text: #eef4ef;
  --muted: #95a699;
  --accent: #b6f23c;
  --accent-ink: #11200a;
  --accent-soft: rgba(182, 242, 60, 0.12);
  --warn: #ffb547;
  --danger: #ff6b6b;
  --info: #6cc4ff;
  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
p { margin: 0; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }

/* ---------- Topbar / nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; display: flex; align-items: center; gap: 6px; }
.brand b { color: var(--accent); }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 16px; }
.points-chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: 14px; font-weight: 600; }

main { padding: 4px 16px calc(var(--nav-h) + var(--safe-b) + 24px); outline: none; }
body.no-nav main { padding-bottom: 32px; }
body.no-nav .bottomnav { display: none; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  max-width: 560px; margin: 0 auto;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.bottomnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav a.active { color: var(--accent); }

/* ---------- Building blocks ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.center { text-align: center; }
.mt { margin-top: 8px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.accent { background: linear-gradient(145deg, #25361c, #172019 70%); border-color: #3b5424; }
.card.warn { background: linear-gradient(145deg, #3a2c14, #1f1a12 80%); border-color: #5c4418; }
.card h2 { font-size: 20px; }
.card h3 { font-size: 16px; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); font-weight: 600; font-size: 16px; transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn:disabled { opacity: .4; pointer-events: none; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; color: var(--muted); border: 1px solid var(--line); }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.stat b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- Home ---------- */
.hero { padding: 26px 20px; text-align: center; }
.hero .big-emoji { font-size: 56px; line-height: 1; margin-bottom: 12px; }
.hero h1 { font-size: 26px; margin-bottom: 8px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week .d { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.week .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; background: var(--surface-2); border: 1.5px solid transparent; }
.week .scheduled .dot { border-color: var(--line); border-style: dashed; }
.week .checked .dot { background: var(--accent); color: var(--accent-ink); border: none; font-weight: 700; }
.week .missed .dot { background: rgba(255,107,107,.12); color: var(--danger); }
.week .today { color: var(--text); font-weight: 700; }
.week .today .dot { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

.muscles { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Quiz ---------- */
.quiz-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.quiz-head .progress { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); font-size: 18px; }
.quiz-q { font-size: 24px; margin-bottom: 6px; }
.quiz-sub { color: var(--muted); margin-bottom: 20px; }
.options { display: grid; gap: 10px; }
.options.cols-2 { grid-template-columns: 1fr 1fr; }
.options.cols-4 { grid-template-columns: repeat(4, 1fr); }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  min-height: 58px; padding: 12px 16px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.opt .ic { font-size: 24px; width: 30px; text-align: center; flex-shrink: 0; }
.opt .tx { display: flex; flex-direction: column; }
.opt .tx small { color: var(--muted); font-size: 13px; }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.compact { justify-content: center; text-align: center; padding: 10px 6px; min-height: 50px; font-weight: 600; }
.opt.tall { flex-direction: column; justify-content: center; text-align: center; min-height: 120px; }
.opt.tall .ic { font-size: 36px; width: auto; }

.number-picker { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 20px 0; }
.number-picker .value { font-size: 64px; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.number-picker .value small { font-size: 22px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.number-picker .ctrls { display: flex; align-items: center; gap: 18px; width: 100%; }
.number-picker .step { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 26px; flex-shrink: 0; }
input[type=range] { flex: 1; accent-color: var(--accent); height: 28px; }
.bmi { font-size: 14px; color: var(--muted); }

.field { width: 100%; padding: 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }
.field:focus { outline: none; border-color: var(--accent); }
textarea.field { min-height: 80px; resize: vertical; }

.quiz-foot { position: sticky; bottom: 0; padding: 16px 0 calc(12px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 30%); margin-top: 22px; }

.review { display: grid; gap: 2px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.review button { display: flex; justify-content: space-between; gap: 12px; text-align: left; padding: 13px 16px; background: var(--surface); border: 0; }
.review button span:first-child { color: var(--muted); font-size: 14px; flex-shrink: 0; }
.review button span:last-child { font-weight: 600; text-align: right; font-size: 14px; }

/* ---------- Generating ---------- */
.gen { min-height: 70dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; padding: 20px; }
.pulse { width: 96px; height: 96px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-size: 44px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(182,242,60,.45); } 50% { transform: scale(1.05); box-shadow: 0 0 0 22px rgba(182,242,60,0); } }
.gen-tip { min-height: 48px; color: var(--muted); max-width: 340px; }

/* ---------- Plan ---------- */
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 6px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex-shrink: 0; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); text-align: left; }
.tab b { display: block; font-size: 14px; }
.tab small { color: var(--muted); font-size: 12px; }
.tab.active { border-color: var(--accent); background: var(--accent-soft); }

.ex { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ex summary { list-style: none; padding: 16px; display: flex; gap: 14px; align-items: flex-start; cursor: pointer; }
.ex summary::-webkit-details-marker { display: none; }
.ex .num { width: 32px; height: 32px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.ex h4 { font-size: 16px; margin-bottom: 6px; }
.ex .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.ex .body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; font-size: 14.5px; }
.ex .body h5 { margin: 0 0 3px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ex[open] .chev { transform: rotate(180deg); }
.chev { margin-left: auto; color: var(--muted); transition: transform .2s; flex-shrink: 0; }

.info-block h3 { margin-bottom: 8px; }
.info-block ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- Progress ---------- */
.tier { display: flex; align-items: center; gap: 16px; }
.tier .medal { font-size: 48px; }
.heat, .heat-labels { width: 100%; max-width: 230px; margin: 0 auto; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat i { aspect-ratio: 1; border-radius: 5px; background: var(--surface-2); }
.heat i.s { outline: 1px dashed var(--line); outline-offset: -1px; }
.heat i.c { background: var(--accent); }
.heat i.f { opacity: .25; }
.heat-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; font-size: 11px; color: var(--muted); text-align: center; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 8px; text-align: center; }
.badge .ic { font-size: 30px; }
.badge b { display: block; font-size: 13px; margin-top: 4px; }
.badge small { color: var(--muted); font-size: 11.5px; line-height: 1.3; display: block; margin-top: 2px; }
.badge.locked { opacity: .35; filter: grayscale(1); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bars .bar { display: grid; grid-template-columns: 80px 1fr 30px; gap: 10px; align-items: center; font-size: 14px; }

/* ---------- Legal ---------- */
.legal p + p { margin-top: 12px; }
.legal strong { color: var(--text); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; margin-top: 1px; }

/* ---------- Modal / toast / confetti ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.modal { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 24px 24px 0 0; padding: 22px 18px calc(22px + var(--safe-b)); border-top: 1px solid var(--line); animation: up .25s ease-out; }
.modal h2 { font-size: 22px; margin-bottom: 6px; }
.modal .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: -8px auto 16px; }
@media (min-width: 600px) { .modal-back { align-items: center; } .modal { border-radius: 24px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%) translateY(20px); z-index: 60; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

.spinner { width: 20px; height: 20px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Anatomia ---------- */

.anatomy svg { width: 100%; max-width: 300px; display: block; margin: 0 auto; }
.anatomy .b { fill: #2e3b32; }
.anatomy .m { fill: #3a4a3e; }
.anatomy .s { fill: #6d8f2a; }
.anatomy .p { fill: var(--accent); }
.anatomy g > * { stroke: var(--bg); stroke-width: .6; }
.anatomy text { fill: var(--muted); font-size: 7px; font-family: inherit; stroke: none; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.lg::before { content: ''; width: 10px; height: 10px; border-radius: 3px; }
.lg.p::before { background: var(--accent); }
.lg.s::before { background: #6d8f2a; }
.lg.p { color: var(--text); font-weight: 600; }


/* ---------- Seções recolhíveis (links) ---------- */
.folds { display: flex; flex-direction: column; }
.card.folds { padding: 4px 18px; }
.fold + .fold { border-top: 1px solid var(--line); }
.fold summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; color: var(--accent); font-weight: 600; font-size: 14px; letter-spacing: .02em; }
.fold summary::-webkit-details-marker { display: none; }
.fold-chev { color: var(--muted); transition: transform .2s; }
.fold[open] .fold-chev { transform: rotate(180deg); }
.fold-body { padding: 2px 0 12px; font-size: 14.5px; }
.fold-body ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
