@font-face { font-family: 'Montserrat'; src: url('fonts/Montserrat-Bold.ttf') format('truetype'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: 'Montserrat'; src: url('fonts/Montserrat-ExtraBold.ttf') format('truetype'); font-weight: 800 900; font-display: swap; }

:root {
  --bg: #0b0c0f;
  --card: #15171c;
  --card2: #1c1f26;
  --line: #262a32;
  --text: #f2f3f5;
  --muted: #8b909a;
  --dim: #5c616b;
  --accent: #8dbbff;
  --accent-ink: #0b1a2e;
  --ok: #4fd18b;
  --gold: #f5c451;
  --danger: #ff6b6b;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tab-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 500 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea {
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .08em; }

#app { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-t) + 18px) 16px calc(var(--tab-h) + var(--safe-b) + 28px); }
body.in-workout #app { padding-bottom: calc(var(--safe-b) + 120px); }

/* ---------- tipografia da marca ---------- */
.brand { font-family: 'Montserrat', sans-serif; font-weight: 800; letter-spacing: .28em; text-transform: uppercase; }
h1, h2, h3 { font-family: 'Montserrat', sans-serif; margin: 0; letter-spacing: .02em; }
h1 { font-size: 26px; font-weight: 800; line-height: 1.15; }
h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); margin: 26px 0 12px; }
h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo img { width: 34px; height: 34px; border-radius: 9px; }
.logo .brand { font-size: 12px; line-height: 1.2; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.hero {
  background: linear-gradient(145deg, #1d2028 0%, #121419 60%), var(--card);
  border-color: #2c313b; padding: 20px; position: relative; overflow: hidden;
}
.card.hero::after {
  content: 'H'; position: absolute; right: -10px; bottom: -48px; font: 900 170px/1 'Montserrat', sans-serif;
  color: rgba(255,255,255,.035); pointer-events: none;
}
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 8px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { display: block; font: 800 22px/1.1 'Montserrat', sans-serif; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 18px; border-radius: 12px;
  font-weight: 700; background: var(--card2); border: 1px solid var(--line); transition: transform .08s, opacity .15s; color: var(--text); text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--text); color: #0b0c0f; border-color: var(--text); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.link { color: var(--accent); font-weight: 600; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 13px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.chip.on { background: var(--text); color: #0b0c0f; border-color: var(--text); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--card2); color: var(--muted); font-size: 11px; font-weight: 600; margin: 2px 4px 2px 0; }
.tag.primary { background: rgba(141,187,255,.14); color: var(--accent); }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 0;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(11,12,15,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
body.in-workout #tabbar { display: none; }
#tabbar button { flex: 1; max-width: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--dim); font-size: 10.5px; font-weight: 600; letter-spacing: .03em; }
#tabbar button.on { color: var(--text); }
#tabbar svg { width: 22px; height: 22px; }

/* ---------- lista ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.list-item:last-child { border-bottom: 0; }
.num { width: 26px; height: 26px; border-radius: 8px; background: var(--card2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; }
.chev { color: var(--dim); }

/* ---------- treino ativo ---------- */
.wk-head {
  position: sticky; top: 0; z-index: 10; margin: calc(-18px - var(--safe-t)) -16px 14px; padding: calc(var(--safe-t) + 12px) 16px 12px;
  background: rgba(11,12,15,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.clock { font: 800 15px 'Montserrat', sans-serif; font-variant-numeric: tabular-nums; color: var(--accent); }
.progress { height: 4px; background: var(--card2); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.ex-card .ex-title { font-weight: 700; font-size: 16px; text-align: left; }
.presc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.coach-note { margin-top: 10px; padding: 9px 11px; border-radius: 10px; background: rgba(141,187,255,.08); border-left: 3px solid var(--accent); font-size: 13px; color: #c9dcff; }
.sets { width: 100%; border-collapse: collapse; margin-top: 12px; }
.sets th { font-size: 10.5px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; text-align: center; padding: 0 2px 6px; }
.sets td { padding: 4px 3px; text-align: center; }
.sets td.n { font-weight: 800; color: var(--muted); width: 28px; }
.sets td.prev { font-size: 12.5px; color: var(--dim); white-space: nowrap; }
.sets input { text-align: center; padding: 9px 4px; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.sets input::placeholder { color: var(--dim); font-weight: 600; }
.sets tr.done td { background: rgba(79,209,139,.07); }
.sets tr.done td:first-child { border-radius: 10px 0 0 10px; }
.sets tr.done td:last-child { border-radius: 0 10px 10px 0; }
.sets tr.done input { border-color: transparent; background: transparent; }
.check { width: 40px; height: 40px; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto; color: var(--dim); }
.check.on { background: var(--ok); border-color: var(--ok); color: #062814; }
.pr-badge { color: var(--gold); font-size: 11px; font-weight: 800; }
.ex-actions { display: flex; gap: 8px; margin-top: 8px; }

/* barra de descanso */
#restbar {
  position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 12px); max-width: 536px; margin: 0 auto;
  background: #f2f3f5; color: #0b0c0f; border-radius: 18px; padding: 12px 14px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
  display: flex; align-items: center; gap: 10px;
}
#restbar[hidden] { display: none; }
#restbar .t { font: 800 28px/1 'Montserrat', sans-serif; font-variant-numeric: tabular-nums; min-width: 78px; }
#restbar .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #555; }
#restbar .bar { height: 4px; background: #d6d8dc; border-radius: 4px; overflow: hidden; margin-top: 6px; }
#restbar .bar i { display: block; height: 100%; background: #0b0c0f; }
#restbar button { padding: 9px 11px; border-radius: 10px; background: #e1e3e7; font-weight: 700; font-size: 13px; }
#restbar button.go { background: #0b0c0f; color: #fff; }
#restbar.over { background: var(--ok); }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
#modal[hidden] { display: none; }
.sheet {
  background: var(--card); width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(var(--safe-b) + 22px); border: 1px solid var(--line); border-bottom: 0; animation: up .2s ease-out;
}
.sheet .grab { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(40px); opacity: .5 } }
@keyframes fade { from { opacity: 0 } }

#toast {
  position: fixed; z-index: 60; left: 50%; top: calc(var(--safe-t) + 14px); transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--line); padding: 11px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 92vw; animation: fade .2s;
}
#toast.gold { background: var(--gold); color: #2a1d00; border-color: var(--gold); }
#toast[hidden] { display: none; }

/* ---------- mapa muscular ---------- */
.mmap { width: 100%; max-width: 360px; display: block; margin: 0 auto; }
.mmap .sil { fill: #191b21; stroke: #2a2e36; stroke-width: .6; }
.mmap .mu { stroke: #0b0c0f; stroke-width: .7; transition: fill .3s; }
.mmap text { fill: var(--dim); font-size: 6px; font-weight: 700; letter-spacing: .15em; text-anchor: middle; font-family: 'Montserrat', sans-serif; }
.legend { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 11px; color: var(--muted); margin-top: 8px; }
.legend i { width: 18px; height: 8px; border-radius: 3px; display: inline-block; }
.mlist { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin-top: 12px; font-size: 13px; }
.mlist div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 3px 0; }

/* ---------- gráficos ---------- */
.chart { width: 100%; height: 170px; display: block; }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln2 { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .ar { fill: url(#grad); }
.chart .dt { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.chart text { fill: var(--dim); font-size: 10px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; margin-top: 8px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bars b { width: 100%; background: var(--card2); border-radius: 6px 6px 3px 3px; min-height: 3px; }
.bars b.on { background: var(--accent); }
.bars span { font-size: 10px; color: var(--dim); }
.bars em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--muted); }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* onboarding */
.welcome { text-align: center; padding: 40px 6px 10px; }
.welcome img { width: 76px; height: 76px; border-radius: 20px; }
.welcome .brand { font-size: 22px; margin: 18px 0 4px; letter-spacing: .32em; }
.welcome p { color: var(--muted); }

/* coach builder */
.day-block { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; background: var(--card); }
.bex { display: grid; grid-template-columns: 1fr 58px 70px 62px 30px; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bex input { padding: 8px 6px; font-size: 14px; text-align: center; }
.bex .nm { font-size: 13.5px; font-weight: 600; }
.bex .note { grid-column: 1 / -1; text-align: left; }
.x { color: var(--dim); font-size: 18px; }
.search-results { max-height: 46dvh; overflow-y: auto; }
.share-box { word-break: break-all; font-size: 12px; background: var(--card2); border-radius: 10px; padding: 10px; color: var(--muted); max-height: 90px; overflow: auto; }

hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- dieta ---------- */
.pchip { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; margin: 2px 4px 2px 0;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.meal.ok { opacity: .55; }
.meal.ok b { text-decoration: line-through; text-decoration-color: var(--dim); }
.foods { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.foods div { background: var(--card2); border-radius: 10px; padding: 8px 10px; font-size: 13px; color: var(--muted); line-height: 1.3; }
.foods b { color: var(--text); }
.bmeal { display: grid; grid-template-columns: repeat(4, 1fr) 26px; gap: 5px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bmeal input { padding: 8px 4px; font-size: 14px; text-align: center; }
.bmeal .note { grid-column: 1 / -1; }

/* ---------- check-in ---------- */
.mgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mgrid input { padding: 8px; text-align: center; }
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pgrid.two { grid-template-columns: 1fr 1fr; }
.pslot { margin: 0; aspect-ratio: 3 / 4; border-radius: 12px; border: 1px dashed var(--line); background: var(--card2); display: grid; place-items: center;
  overflow: hidden; color: var(--muted); font-size: 12px; text-align: center; text-transform: none; letter-spacing: 0; cursor: pointer; }
.pslot img { width: 100%; height: 100%; object-fit: cover; }
.score { display: flex; gap: 6px; }
.score button { flex: 1; padding: 10px 0; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); font-weight: 700; }
.score button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
textarea.fb { margin-top: 10px; min-height: 0; font-size: 13.5px; padding: 9px 11px; }
.pin { display: flex; align-items: center; gap: 4px; }
.pin span { font-size: 12px; font-weight: 800; }
