/* Jabu · design system v2 — "quadro de treino atlético-editorial".
   Dark-first (celular na academia), display condensado Big Shoulders 800,
   Inter no corpo, JetBrains Mono nos dados. Jabuticaba (roxo profundo) + folha.
   Fontes self-host; ZH cai pra system-ui local. */

@font-face { font-family: 'Big Shoulders'; src: url('/fonts/big-shoulders-display-800-latin.woff2') format('woff2'); font-weight: 800; font-display: swap; unicode-range: U+0000-00FF, U+2013-2014; }
@font-face { font-family: 'Big Shoulders'; src: url('/fonts/big-shoulders-display-800-latin-ext.woff2') format('woff2'); font-weight: 800; font-display: swap; unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin.woff2') format('woff2'); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2013-2014, U+2018-201A, U+201C-201E, U+2026; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin-ext.woff2') format('woff2'); font-weight: 100 900; font-display: swap; unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

:root {
  --bg: #14101b;
  --bg-glow: radial-gradient(1100px 520px at 85% -10%, rgba(122, 62, 172, 0.28), transparent 60%),
             radial-gradient(700px 420px at -20% 30%, rgba(46, 125, 79, 0.12), transparent 55%);
  --surface: #1d1726;
  --surface2: #251d31;
  --ink: #f4efe7;
  --muted: #9d93ab;
  --line: #342a44;
  --fruit: #b98af0;         /* jabuticaba madura */
  --fruit-deep: #7a3eac;
  --fruit-ink: #16101d;
  --leaf: #57c78b;
  --amber: #e8b25c;
  --bad: #ef7683;
  --chip: #2b2138;
  --r: 18px;
  --pad: 18px;
  --display: 'Big Shoulders', 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 17px;
}
:root[data-theme='light'] {
  --bg: #f6f1e8;
  --bg-glow: radial-gradient(1100px 520px at 85% -10%, rgba(122, 62, 172, 0.10), transparent 60%),
             radial-gradient(700px 420px at -20% 30%, rgba(46, 125, 79, 0.08), transparent 55%);
  --surface: #fffdf9; --surface2: #f2ebdf; --ink: #221a2e; --muted: #6f6580;
  --line: #e2d8c8; --fruit: #6d2f9e; --fruit-deep: #5b2a86; --fruit-ink: #fffdf9;
  --leaf: #1d7a4f; --amber: #a05a00; --bad: #b3363f; --chip: #ece2f5;
}
:root[data-theme='dracula'] {
  --bg: #282a36; --bg-glow: none; --surface: #313342; --surface2: #3b3d52;
  --ink: #f8f8f2; --muted: #9ba0b8; --line: #44475a; --fruit: #bd93f9;
  --fruit-deep: #9a6ee8; --fruit-ink: #282a36; --leaf: #50fa7b; --amber: #f1fa8c;
  --bad: #ff5555; --chip: #3b3d52;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); background-image: var(--bg-glow); background-attachment: fixed;
  color: var(--ink);
  font-family: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  line-height: 1.5; -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 560px; margin: 0 auto; padding: 0 var(--pad) 110px; }

/* ── header ─────────────────────────────────────────────── */
header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px var(--pad) 6px; max-width: 560px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand svg { width: 30px; height: 30px; }
.wordmark {
  font-family: var(--display); font-weight: 800; font-size: 1.7rem;
  letter-spacing: 0.04em; text-transform: uppercase; line-height: 1;
}
.badge-beta {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fruit); border: 1.5px solid var(--fruit); border-radius: 999px;
  padding: 3px 8px; transform: translateY(-6px);
}
.spacer { flex: 1; }
header select, header button.icon {
  min-height: 42px; min-width: 42px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 0.82rem; padding: 0 8px;
}

/* demo strip */
.demo-strip {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  background: var(--amber); color: #1d1408; font-weight: 800; font-size: 0.76rem;
  letter-spacing: 0.1em; padding: 8px 12px; text-transform: uppercase;
}
.demo-strip button { background: rgba(0,0,0,0.18); color: inherit; border: 0; border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 0.72rem; min-height: 32px; font-weight: 800; }

/* ── tipografia ─────────────────────────────────────────── */
h1 {
  font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: 2.6rem; line-height: 0.95; letter-spacing: 0.015em; margin: 26px 0 10px;
}
h1 .thin { color: var(--muted); }
h2 {
  font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: 1.15rem; letter-spacing: 0.1em; color: var(--muted); margin: 30px 0 12px;
  display: flex; align-items: center; gap: 10px;
}
h2::after { content: ''; height: 1px; background: var(--line); flex: 1; }
p.lead { color: var(--muted); margin: 0 0 20px; font-size: 0.98rem; }

/* ── stagger de entrada (uma orquestração, não confete) ── */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
main > * { animation: rise 0.42s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
main > *:nth-child(2) { animation-delay: 0.05s; }
main > *:nth-child(3) { animation-delay: 0.1s; }
main > *:nth-child(4) { animation-delay: 0.15s; }
main > *:nth-child(5) { animation-delay: 0.2s; }
main > *:nth-child(n+6) { animation-delay: 0.25s; }

/* ── cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: var(--pad); margin: 12px 0;
}
.card.tap { cursor: pointer; transition: transform 0.07s ease, border-color 0.15s ease; }
.card.tap:active { transform: scale(0.985); border-color: var(--fruit); }

/* aluno na lista: inicial gigante + adesão display */
.roster { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 56px; height: 56px; border-radius: 16px; flex: none;
  background: linear-gradient(145deg, var(--fruit-deep), var(--fruit));
  color: #fff; display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 1.7rem; text-transform: uppercase;
}
.roster .who { flex: 1; min-width: 0; }
.roster .who .nm { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster .who .sub { margin-top: 2px; }
.bignum {
  font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1;
  text-align: right;
}
.bignum.good { color: var(--leaf); } .bignum.warn { color: var(--amber); } .bignum.mut { color: var(--muted); }
.sub { color: var(--muted); font-size: 0.8rem; }

/* plaquetas de treino (letra gigante) */
.plaques { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.plaque {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; cursor: pointer; transition: transform 0.07s ease, border-color 0.15s ease;
  display: flex; flex-direction: column; gap: 4px; min-height: 118px;
}
.plaque:active { transform: scale(0.97); border-color: var(--fruit); }
.plaque .letter {
  font-family: var(--display); font-weight: 800; font-size: 3rem; line-height: 0.9;
  color: var(--fruit);
}
.plaque .meta { color: var(--muted); font-size: 0.78rem; }
.plaque .send {
  margin-top: auto; font-weight: 700; font-size: 0.82rem; color: var(--leaf);
  display: flex; align-items: center; gap: 6px;
}

/* ── botões ─────────────────────────────────────────────── */
button.primary, a.primary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; border: 0; border-radius: 16px;
  background: linear-gradient(135deg, var(--fruit-deep), var(--fruit));
  color: #fff; font: inherit; font-weight: 800; font-size: 1rem;
  letter-spacing: 0.02em; cursor: pointer; text-decoration: none; padding: 15px 18px;
  box-shadow: 0 10px 28px -12px var(--fruit-deep);
  transition: transform 0.07s ease;
}
button.primary:active { transform: scale(0.98); }
button.ghost {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; border: 1.5px solid var(--line); border-radius: 14px;
  background: transparent; color: var(--ink); font: inherit; font-weight: 600;
  font-size: 0.92rem; cursor: pointer; padding: 11px 16px;
}
button.ghost:active { border-color: var(--fruit); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
button.iconbtn {
  flex: none; width: 42px; height: 42px; min-height: 42px; border-radius: 12px;
  border: 1.5px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 1rem; cursor: pointer; display: grid; place-items: center; padding: 0;
}
button.iconbtn:active { border-color: var(--bad); color: var(--bad); }
button.back {
  width: auto; min-height: 42px; border: 0; background: none; color: var(--muted);
  font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer; padding: 10px 0;
  display: inline-flex; align-items: center; gap: 6px;
}
.btnrow { display: grid; gap: 11px; margin: 16px 0; }

/* ── formulários ────────────────────────────────────────── */
label.field { display: block; margin: 14px 0; }
label.field span { display: block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=number], select, textarea {
  width: 100%; min-height: 50px; border: 1.5px solid var(--line); border-radius: 13px;
  background: var(--surface); color: var(--ink); font: inherit; padding: 11px 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--fruit); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 88px; resize: vertical; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 9px; margin: 10px 0; }
.chip {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 9px 14px; min-height: 42px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 0.84rem; cursor: pointer;
}
.chip.on { background: var(--fruit); border-color: var(--fruit); color: var(--fruit-ink); font-weight: 800; }
.chip.note { background: var(--chip); border: 0; cursor: default; color: var(--fruit); }

/* ── builder: linha de exercício (o layout que tava QUEBRADO) ──
   grid fixo: texto (1fr) | remover (42px). Editores numa sub-linha própria. */
.exrow {
  display: grid; grid-template-columns: minmax(0, 1fr) 42px; gap: 10px;
  border-top: 1px solid var(--line); padding: 14px 0; align-items: start;
}
.exrow:first-child { border-top: 0; padding-top: 4px; }
.exname { font-weight: 700; font-size: 1rem; }
.exmeta { color: var(--muted); font-size: 0.82rem; font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
.swap { color: var(--amber); font-size: 0.78rem; margin-top: 2px; }
.miss { color: var(--bad); font-size: 0.78rem; margin-top: 2px; }
.editors {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center;
}
.stepper {
  display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden;
}
.stepper button {
  width: 40px; height: 44px; border: 0; background: transparent; color: var(--fruit);
  font-size: 1.15rem; font-weight: 800; cursor: pointer;
}
.stepper .val {
  min-width: 34px; text-align: center; font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 0.95rem;
}
.editors input { min-height: 44px; padding: 8px 10px; font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; }
.editors .lbl { position: absolute; }

/* ── modo aluno ─────────────────────────────────────────── */
.hero-plan {
  display: flex; align-items: baseline; gap: 14px; margin: 22px 0 4px;
}
.hero-plan .letter {
  font-family: var(--display); font-weight: 800; font-size: 5rem; line-height: 0.85;
  color: var(--fruit);
}
.hero-plan .rest { flex: 1; min-width: 0; }
.progresswrap { margin: 16px 0 6px; }
.progressbar { height: 12px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.progressbar > div {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--fruit), var(--leaf));
  width: 0; transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.progresslbl { display: flex; justify-content: space-between; margin-top: 6px; }
.progresslbl .pct { font-family: var(--display); font-weight: 800; font-size: 1.3rem; color: var(--leaf); }

.excard { border-top: 1px solid var(--line); padding: 16px 0; }
.excard:first-child { border-top: 0; }
.exhead { display: flex; align-items: baseline; gap: 10px; }
.exhead .nm { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; }
.exhead .rx { font-family: 'JetBrains Mono', monospace; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.exload {
  font-family: var(--display); font-weight: 800; font-size: 1.9rem; line-height: 1;
  color: var(--ink); margin: 4px 0 2px;
}
.exload small { font-size: 0.9rem; color: var(--muted); letter-spacing: 0.06em; }
.sets { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; align-items: center; }
@keyframes pop { 0% { transform: scale(0.8); } 55% { transform: scale(1.14); } 100% { transform: scale(1); } }
.set {
  width: 54px; height: 54px; border-radius: 50%; border: 2.5px solid var(--line);
  background: var(--surface); color: var(--muted);
  font-family: var(--display); font-weight: 800; font-size: 1.25rem; cursor: pointer;
  display: grid; place-items: center; transition: border-color 0.12s ease;
}
.set.done {
  background: var(--leaf); border-color: var(--leaf); color: #102b17;
  animation: pop 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.loadin { width: 96px; min-height: 44px; font-family: 'JetBrains Mono', monospace; }

.celebrate {
  text-align: center; padding: 22px var(--pad);
  border: 1.5px dashed var(--leaf); border-radius: var(--r); margin: 14px 0;
}
.celebrate .big { font-family: var(--display); font-weight: 800; font-size: 1.7rem; text-transform: uppercase; color: var(--leaf); }

/* sparkline */
.spark { width: 100%; height: 48px; }
.spark polyline { fill: none; stroke: var(--fruit); stroke-width: 2.5; stroke-linecap: round; }
.spark circle { fill: var(--leaf); }

/* histórico */
.logrow { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 11px 0; }
.logrow:first-child { border-top: 0; }
.logrow .when { color: var(--muted); font-size: 0.85rem; flex: 1; }
.logrow .kpi { font-family: var(--display); font-weight: 800; font-size: 1.15rem; }
.kpi.good { color: var(--leaf); } .kpi.warn { color: var(--amber); } .kpi.mut { color: var(--muted); }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(130%); transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  background: var(--ink); color: var(--bg); padding: 13px 20px; border-radius: 14px;
  font-size: 0.9rem; font-weight: 600; max-width: min(92vw, 460px); text-align: center; z-index: 50;
  box-shadow: 0 18px 40px -18px rgba(0,0,0,0.6);
}
#toast.show { transform: translateX(-50%) translateY(0); }

footer {
  max-width: 560px; margin: 48px auto 0; padding: 20px var(--pad) 30px;
  color: var(--muted); font-size: 0.78rem; text-align: center; border-top: 1px solid var(--line);
}
footer b { color: var(--ink); }

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