:root {
  --bg: #0d1015; --card: #151920; --card2: #1c212a; --line: #272d38;
  --tx: #e9ecf1; --mu: #8b93a1; --ac: #ff8a3d; --ac-tx: #1a0d03;
  --ok: #3ecf8e; --bad: #ff5d5d; --gold: #ffcc4d; --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
html, body { background: var(--bg); color: var(--tx); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
#app { max-width: 1100px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 14px 28px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
a { color: inherit; text-decoration: none; }
h2 { font-size: 22px; } h3 { font-size: 16px; font-weight: 650; }
.muted { color: var(--mu); } .small { font-size: 13px; }
.up { color: var(--ok); } .down { color: var(--bad); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 4px; flex-wrap: nowrap; } .row.end { justify-content: flex-end; }
.empty { text-align: center; padding: 48px 12px; display: grid; gap: 14px; justify-items: center; }

/* Cabeçalho */
.top { display: flex; align-items: center; gap: 10px; padding: 8px 0 12px; }
.top h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { font-size: 32px; line-height: 1; padding: 0 6px 4px 0; color: var(--ac); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--mu); border: 0; padding: 0; flex: none; }
.dot.inline { display: inline-block; vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.syncing { background: var(--ac); animation: pulse 1s infinite; }
.dot.error { background: var(--bad); } .dot.offline { background: #5b6270; }
.dot.nologin { background: transparent; box-shadow: inset 0 0 0 2px var(--mu); }
@keyframes pulse { 50% { opacity: .3; } }

/* Botões */
.btn { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; font-weight: 600; }
.btn.primary { background: var(--ac); border-color: var(--ac); color: var(--ac-tx); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; } .btn.sm { padding: 6px 12px; font-size: 14px; }
.icon { background: transparent; border: 0; padding: 6px 10px; font-size: 18px; color: var(--mu); border-radius: 8px; }
.icon:hover { background: var(--card2); }

/* Abas de treino */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { padding: 8px 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); white-space: nowrap; font-weight: 600; }
.chip.on { background: var(--ac); border-color: var(--ac); color: var(--ac-tx); }
.whead { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; margin: 16px 0 12px; }
.pill { background: var(--card2); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; }

/* Cartões */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; align-content: start; margin-bottom: 12px; }
.cards .card { margin: 0; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.card-head h3 { font-size: 17px; }
.note { font-size: 13px; background: var(--card2); border-left: 3px solid var(--ac); padding: 6px 10px; border-radius: 6px; }
.footer-actions { margin-top: 16px; }

/* Séries */
.sets { display: grid; gap: 6px; }
.set-h, .set { display: grid; grid-template-columns: 22px 1fr 1fr 44px; gap: 6px; align-items: center; }
.set-h { font-size: 11px; color: var(--mu); text-transform: uppercase; letter-spacing: .04em; text-align: center; }
.set .n { text-align: center; color: var(--mu); font-size: 14px; font-weight: 600; }
.stp { display: flex; align-items: center; background: var(--card2); border-radius: 10px; border: 1px solid var(--line); overflow: hidden; min-width: 0; }
.stp .s { background: transparent; border: 0; width: 34px; height: 40px; font-size: 20px; color: var(--mu); flex: none; }
.stp .s:active { background: var(--line); }
.num { width: 100%; min-width: 0; background: transparent; border: 0; text-align: center; font-size: 17px; font-weight: 650; padding: 0; outline: none; }
.chk { height: 40px; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); font-size: 18px; color: var(--mu); }
.set.done .stp { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.chk.on { background: var(--ok); border-color: var(--ok); color: #04170e; font-weight: 800; }
.chk.pr { background: var(--gold); border-color: var(--gold); }

/* Evolução */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 2px; min-width: 0; }
.stat strong { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec { margin: 18px 0 8px; color: var(--mu); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.search { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.list { display: grid; gap: 1px; background: var(--line); border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.card .list { border-radius: 10px; }
.li { background: var(--card); padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
a.li:active { background: var(--card2); }
.li[hidden] { display: none; }
.li .val { font-weight: 700; color: var(--ac); white-space: nowrap; }
.li.hist { align-items: start; flex-direction: column; gap: 6px; }
.chips-sm { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; font-size: 14px; }
.tag.pr { border-color: var(--gold); }
.tabs { display: flex; gap: 4px; background: var(--card2); padding: 3px; border-radius: 10px; }
.tab { flex: 1; background: transparent; border: 0; padding: 7px; border-radius: 8px; font-size: 14px; color: var(--mu); font-weight: 600; }
.tab.on { background: var(--card); color: var(--tx); }
.chart-wrap { width: 100%; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--mu); font-size: 10px; }
.chart .line { fill: none; stroke: var(--ac); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--ac); opacity: .12; }
.chart .pt { fill: var(--bg); stroke: var(--ac); stroke-width: 2; }
.chart .pt.last { fill: var(--ac); }
.chart .lbl { fill: var(--tx); font-size: 12px; font-weight: 700; }
.chart .bar { fill: var(--card2); } .chart .bar.last { fill: var(--ac); }
.empty-chart { padding: 24px 0; text-align: center; }

/* Peso */
.weigh { grid-template-columns: auto 1fr auto; align-items: center; }
.weigh input[type=date] { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.kg { display: flex; align-items: baseline; gap: 6px; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; }
.kg input { width: 100%; min-width: 0; background: transparent; border: 0; font-size: 22px; font-weight: 700; outline: none; }

/* Formulários */
.field { display: grid; gap: 4px; font-size: 14px; color: var(--mu); }
.field input, .card form input, .card > .row > input { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--tx); font-size: 16px; }
.field.inline { grid-template-columns: 1fr 110px; align-items: center; }
.field.inline input { text-align: center; }
.card > .row > input { flex: 1; min-width: 160px; }

/* Folhas modais */
.overlay { position: fixed; inset: 0; background: #000a; display: flex; align-items: end; justify-content: center; z-index: 50; animation: fade .15s; }
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); width: 100%; max-width: 520px; display: grid; gap: 12px; animation: up .18s ease-out; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.act { background: var(--card2); border: 0; border-radius: 10px; padding: 13px; text-align: left; font-size: 16px; }
.act.danger { color: var(--bad); } .act.muted { text-align: center; }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(30px); opacity: 0; } }

/* Timer de descanso */
.rest { position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); background: var(--card2); border-top: 1px solid var(--line); z-index: 20; }
.rt-bar { height: 3px; background: var(--ac); transition: width .25s linear; }
.rt-row { max-width: 1100px; margin: 0 auto; padding: 8px 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rt-time { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rest:not([hidden]) ~ .nav { box-shadow: none; }

/* Aviso */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(130px + env(safe-area-inset-bottom)); background: var(--tx); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 60; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 6px 24px #0008; }

/* Navegação inferior */
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: #0d1015f2; backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 30; }
.nav a { flex: 1; max-width: 160px; display: grid; justify-items: center; gap: 2px; padding: 8px 0 7px; font-size: 12px; color: var(--mu); font-weight: 600; }
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav a.on { color: var(--ac); }

@media (max-width: 380px) {
  .stp .s { width: 28px; }
  .stats { grid-template-columns: 1fr 1fr; }
}
