:root {
  --bg: #0e1014;
  --bg2: #14171d;
  --card: #1a1e26;
  --card2: #222733;
  --line: #2a303c;
  --text: #eef1f6;
  --muted: #8d95a6;
  --accent: #d4ff4f;
  --accent-ink: #11140a;
  --me: #d4ff4f;
  --partner: #ff8a9b;
  --danger: #ff5d5d;
  --ok: #57e39b;
  --warn: #ffc65c;
  --fig: #eef1f6;
  --radius: 16px;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 15px; line-height: 1.45; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: .2px; margin: 0; line-height: 1.1; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + var(--safe-b)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 12px; position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 75%, transparent); }
.topbar .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 17px; color: var(--accent-ink); background: var(--me); flex: none; }
.avatar.partner { background: var(--partner); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(14, 16, 20, .94); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.nav-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.nav button { background: none; border: 0; padding: 9px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 11px; cursor: pointer; }
.nav button svg { width: 23px; height: 23px; }
.nav button.on { color: var(--accent); }

/* ---------- Cards / layout ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.tight { padding: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 10px; }
.section-title h2 { font-size: 20px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

.hero { background: radial-gradient(120% 140% at 100% 0%, rgba(212, 255, 79, .16), transparent 55%), var(--card); border: 1px solid rgba(212, 255, 79, .18); }
.hero .big { font-family: var(--display); font-size: 40px; font-weight: 700; line-height: 1; }
.stat { background: var(--card2); border-radius: 12px; padding: 10px 12px; }
.stat .v { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1.05; }
.stat .l { font-size: 11.5px; color: var(--muted); }

/* ---------- Buttons / inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--card2); color: var(--text); font-weight: 600; cursor: pointer; min-height: 46px; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn svg, .chk svg, .list-item > svg { width: 20px; height: 20px; flex: none; }
.btn.sm svg { width: 17px; height: 17px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: rgba(255, 93, 93, .12); color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 13.5px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--card2); color: var(--text); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.plain { background: transparent; }

label.field { display: block; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 46px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 80px; resize: vertical; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 8px 6px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--text); font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: 11.5px; background: var(--card2); color: var(--muted); }
.badge.accent { background: rgba(212, 255, 79, .14); color: var(--accent); }
.badge.partner { background: rgba(255, 138, 155, .14); color: var(--partner); }
.badge.warn { background: rgba(255, 198, 92, .14); color: var(--warn); }

/* ---------- Lists ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--card); border-radius: 14px; margin-bottom: 8px; cursor: pointer; border: 0; width: 100%; text-align: left; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code { width: 44px; height: 44px; border-radius: 12px; background: var(--card2); display: grid; place-items: center; font-family: var(--display); font-size: 24px; font-weight: 700; color: var(--accent); flex: none; }
.thumb { width: 64px; height: 60px; border-radius: 10px; background: var(--bg2); flex: none; overflow: hidden; }
.thumb svg { width: 100%; height: 100%; }

/* ---------- Biblioteca ---------- */
.ex-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ex-card { background: var(--card); border-radius: 14px; padding: 8px 8px 10px; border: 0; text-align: left; cursor: pointer; }
.ex-card .figwrap { background: var(--bg2); border-radius: 10px; aspect-ratio: 200 / 170; overflow: hidden; }
.ex-card .figwrap svg { width: 100%; height: 100%; }
.ex-card .n { font-weight: 600; font-size: 13.5px; margin-top: 8px; line-height: 1.25; }
.ex-card .g { font-size: 11.5px; color: var(--muted); }

/* ---------- Figura ---------- */
svg.fig { display: block; width: 100%; height: auto; }
.fig .ground { stroke: #2c3240; stroke-width: 2; }
.fig .limb, .fig .torso { fill: none; stroke: var(--fig); stroke-linecap: round; stroke-linejoin: round; }
.fig .limb { stroke-width: 7; }
.fig .limb.arm { stroke-width: 6; }
.fig .limb.far { stroke: #6b7385; }
.fig .torso { stroke-width: 12; }
.fig .torso-f { fill: var(--fig); stroke: var(--fig); stroke-width: 6; stroke-linejoin: round; }
.fig .head { fill: var(--fig); }
.fig .pr-eq { fill: #2d3340; }
.fig .pr-eqline { stroke: #384052; stroke-linecap: round; }
.fig .pr-cable { stroke: #9aa3b5; stroke-width: 1.3; stroke-dasharray: 3 2; }
.fig .pr-bar { stroke: var(--accent); stroke-linecap: round; }
.fig .pr-w { fill: var(--accent); }
.fig .pr-plate { fill: rgba(212, 255, 79, .12); stroke: var(--accent); stroke-width: 3; }
.fig .pr-pad { fill: #4a5366; }
.fig .pr-ring { fill: none; stroke: #384052; stroke-width: 4; }
.fig .pr-text { fill: var(--muted); font-size: 10px; font-family: var(--body); }

/* ---------- Sheet / modal ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet { background: var(--bg2); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + var(--safe-b)); animation: up .22s cubic-bezier(.2, .8, .2, 1); }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: -8px; background: var(--bg2); padding: 6px 0 10px; z-index: 2; }
.ex-detail .figbig { background: var(--card); border-radius: 16px; padding: 6px; }
.ex-detail ol, .ex-detail ul { padding-left: 20px; margin: 6px 0; }
.ex-detail li { margin: 4px 0; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Sessão ---------- */
.session-ex { background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.session-ex.done { opacity: .62; }
.session-ex .head { display: flex; gap: 12px; align-items: center; }
.set-row { display: grid; grid-template-columns: 30px 1fr 1fr 46px; gap: 8px; align-items: center; margin-top: 8px; }
.set-row .idx { font-family: var(--display); font-size: 18px; color: var(--muted); text-align: center; }
.set-row input { text-align: center; padding: 8px 4px; min-height: 42px; }
.set-row .chk { width: 46px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.set-row .chk.on { background: var(--ok); border-color: var(--ok); color: #06210f; }
.set-head { display: grid; grid-template-columns: 30px 1fr 1fr 46px; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 10px; text-align: center; }
.hint { font-size: 12.5px; padding: 8px 10px; border-radius: 10px; background: var(--bg2); margin-top: 8px; }
.hint.up { background: rgba(87, 227, 155, .1); color: var(--ok); }
.rest { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + var(--safe-b)); z-index: 30; width: calc(100% - 32px); max-width: 528px; background: var(--accent); color: var(--accent-ink); border-radius: 16px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.rest .t { font-family: var(--display); font-size: 34px; font-weight: 700; min-width: 74px; }
.rest .bar { flex: 1; height: 6px; background: rgba(0, 0, 0, .15); border-radius: 6px; overflow: hidden; }
.rest .bar i { display: block; height: 100%; background: var(--accent-ink); }
.rest button { background: rgba(0, 0, 0, .12); border: 0; border-radius: 10px; padding: 8px 10px; font-weight: 700; color: var(--accent-ink); cursor: pointer; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--body); }
.chart .ln { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .12; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.weekbar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekbar div { text-align: center; font-size: 11px; color: var(--muted); }
.weekbar b { display: block; height: 34px; border-radius: 8px; background: var(--card2); margin-bottom: 4px; }
.weekbar b.me { background: var(--me); }
.weekbar b.both { background: linear-gradient(135deg, var(--me) 50%, var(--partner) 50%); }
.weekbar b.partner { background: var(--partner); }
.weekbar .today { color: var(--text); font-weight: 700; }

table.hist { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.hist td, table.hist th { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.hist th { color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }
.login .brand { font-family: var(--display); font-size: 46px; font-weight: 800; line-height: .95; text-transform: uppercase; }
.login .brand em { color: var(--accent); font-style: normal; }

.toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: fade .2s; max-width: calc(100% - 32px); }
.toast.err { border-color: var(--danger); color: #ffd2d2; }
.empty { text-align: center; padding: 26px 12px; color: var(--muted); }
.loading { display: grid; place-items: center; min-height: 60dvh; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sortbtns { display: flex; flex-direction: column; gap: 2px; }
.sortbtns button { width: 28px; height: 20px; border: 0; border-radius: 6px; background: var(--card2); color: var(--muted); cursor: pointer; font-size: 11px; line-height: 1; }

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