:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #EEF0F3;
  --text: #15181D;
  --text-2: #5B6470;
  --muted: #8A93A0;
  --border: #E1E4E9;
  --accent: #E8590C;
  --accent-ink: #FFFFFF;
  --accent-soft: #FDEBDF;
  --good: #16A34A;
  --danger: #DC2626;
  --grid: #E6E8EC;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.05);
  --tab-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1115; --surface: #181B21; --surface-2: #22262E; --text: #F2F4F7; --text-2: #A6AFBB;
    --muted: #7C8693; --border: #2A2F38; --accent: #FF7A33; --accent-ink: #1A0E05; --accent-soft: #3A2215;
    --good: #22C55E; --danger: #F87171; --grid: #262A32; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1115; --surface: #181B21; --surface-2: #22262E; --text: #F2F4F7; --text-2: #A6AFBB;
  --muted: #7C8693; --border: #2A2F38; --accent: #FF7A33; --accent-ink: #1A0E05; --accent-soft: #3A2215;
  --good: #22C55E; --danger: #F87171; --grid: #262A32; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 800; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.icon-btn { background: none; border: 0; padding: 6px; margin-left: -6px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }

main { max-width: 720px; margin: 0 auto; padding: 16px; outline: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
.tabbar a.active { color: var(--accent); }
.tabbar.hide { display: none; }

h2 { font-size: 18px; margin: 24px 0 10px; }
h2:first-child { margin-top: 4px; }
h3 { font-size: 16px; margin: 0 0 4px; }
p { margin: 0 0 8px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 10px; }
.card.link { display: block; text-decoration: none; color: inherit; cursor: pointer; }
.card.hero { background: var(--accent); color: var(--accent-ink); border: 0; }
.card.hero .muted { color: inherit; opacity: .85; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.hero-btn { background: var(--accent-ink); color: var(--accent); border: 0; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn { flex: 1; }

.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
a.chip { color: var(--text); text-decoration: none; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 10px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=search], input[type=url], input[type=tel], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { min-height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 14px; cursor: pointer; padding: 0 6px; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.ex-item .icon-btn { margin-left: 0; padding: 4px; }
.ex-item { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-top: 1px solid var(--border); }
.ex-item:first-child { border-top: 0; }
.ex-num { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 14px; }
.ex-meta { font-size: 13px; color: var(--text-2); }

.block-head { margin: 16px 0 6px; padding: 8px 12px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.block-head b { display: block; font-size: 14px; }
.block-head span { display: block; font-size: 12px; color: var(--text-2); margin-top: 2px; }
.block-head.in-card { margin: 12px 0 2px; }
.stack > .block-head + .card { margin-top: 6px; }
.group-icon { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); font-weight: 800; font-size: 13px; }

/* sessão */
.set-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.set-table th { font-size: 12px; color: var(--muted); font-weight: 700; text-align: left; padding: 4px; }
.set-table td { padding: 4px; }
.set-table input { min-height: 42px; text-align: center; padding: 6px; }
.set-table td:first-child { width: 36px; font-weight: 800; color: var(--text-2); text-align: center; }
.set-table td:last-child { width: 52px; }
.check { width: 44px; height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.check.done { background: var(--good); border-color: var(--good); color: #fff; }
tr.done input { color: var(--text-2); }
.ex-card.complete { border-color: var(--good); }

.rest-bar {
  position: fixed; left: 12px; right: 12px; z-index: 30; bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom));
  max-width: 696px; margin: 0 auto; background: var(--text); color: var(--bg); border-radius: 16px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.rest-bar .chip { background: transparent; color: inherit; border-color: currentColor; opacity: .9; }
.rest-row { display: flex; align-items: center; gap: 10px; }
.rest-row strong { font-size: 26px; font-variant-numeric: tabular-nums; flex: 1; }
.rest-label { font-size: 13px; font-weight: 700; opacity: .75; }
.rest-progress { height: 4px; border-radius: 2px; background: rgba(127,127,127,.35); overflow: hidden; margin-bottom: 8px; }
.rest-progress span { display: block; height: 100%; background: var(--accent); width: 0; }
body.in-session .tabbar { display: none; }
body.in-session { padding-bottom: 110px; }
body.in-session .rest-bar { bottom: calc(16px + env(safe-area-inset-bottom)); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.stat strong { display: block; font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--text-2); font-weight: 600; }

/* gráfico */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart text { stroke: none; }
.chart .axis text { fill: var(--muted); font-size: 11px; stroke: none; font-family: inherit; }
.chart .line { stroke: var(--accent); stroke-width: 2; fill: none; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--accent); stroke: none; }
.chart .hit { fill: transparent; stroke: none; cursor: pointer; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.tooltip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 6px 8px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); }
.tooltip b { font-size: 14px; }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10,12,16,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 12px; }
.sheet h2 { margin-top: 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px); transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; transition: .2s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; padding: 28px 12px; color: var(--text-2); }
.empty svg { width: 40px; height: 40px; color: var(--muted); }
ol.how { padding-left: 20px; margin: 8px 0; }
ol.how li { margin-bottom: 6px; }
.note { font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.video-wrap { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; background: #000; margin: 10px 0; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.day-tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
