:root {
  --bg: #000;
  --text: #fff;
  --muted: #8a8f98;
  --blue: #3a63e3;
  --blue-strong: #2f5be0;
  --blue-disabled: #2a4aad;
  --track: #0a0f1a;
  --line: #3a3a3a;
  --radius: 12px;
  --tick: 16px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- topo ---------- */
.topbar {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 28px;
  padding: 24px 16px 0;
}
.logo { width: 150px; height: auto; }
.back {
  position: absolute; left: 12px; top: 18px;
  background: none; border: 0; color: #bbb; padding: 8px; cursor: pointer; border-radius: 8px;
}
.back:hover { color: #fff; }
.progress {
  width: min(100%, 448px); height: 5px; border-radius: 99px;
  background: var(--track); overflow: hidden;
}
.progress span {
  display: block; height: 100%; width: 100%;
  background: var(--blue); border-radius: inherit;
  transform-origin: left; transform: scaleX(0);
  transition: transform 0.5s var(--ease);
}

/* ---------- tela ---------- */
.screen {
  width: min(100%, 736px);
  margin: 0 auto;
  padding: 24px 16px 48px;
  min-height: calc(100dvh - 120px);
  display: flex; flex-direction: column; justify-content: center;
  gap: 24px;
}
.screen.top { justify-content: flex-start; padding-top: 48px; }
.enter { animation: enter 0.45s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } }

h1 { font-size: clamp(1.5rem, 1.1rem + 2vw, 2rem); font-weight: 700; text-align: center; line-height: 1.2; }
h1.accent { color: var(--blue); }
.lead { color: var(--muted); text-align: justify; font-size: 1rem; line-height: 1.45; }

.field { display: grid; gap: 8px; }
.field label { font-weight: 600; font-size: 1.125rem; }
.field input {
  font: inherit; font-size: 1.05rem; color: #111;
  background: #fff; border: 2px solid transparent; border-radius: var(--radius);
  padding: 15px 18px; outline: none; width: 100%;
}
.field input::placeholder { color: #9aa0aa; font-style: italic; }
.field input:focus { border-color: var(--blue); }
.field .hint { color: #ff7a7a; font-size: 0.85rem; min-height: 1em; }

.btn {
  font: inherit; font-size: 1.05rem; font-weight: 500;
  width: 100%; padding: 15px; border: 0; border-radius: var(--radius);
  background: var(--blue); color: #fff; cursor: pointer;
  transition: background 0.2s, transform 0.15s var(--ease), color 0.2s;
}
.btn:hover:not(:disabled) { background: #4a72f0; }
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { background: var(--blue-disabled); color: #a9b0c4; cursor: not-allowed; }
.btn:focus-visible, .opt:has(input:focus-visible), .ruler-track:focus-visible { outline: 2px solid #9db4ff; outline-offset: 3px; }

.cover { width: min(100%, 460px); aspect-ratio: 200 / 142; object-fit: cover; border-radius: var(--radius); margin: 0 auto; }

/* ---------- opções ---------- */
.opts { display: grid; gap: 12px; }
.opts.grid { grid-template-columns: 1fr 1fr; }
.opt {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.opt:hover { border-color: #666; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .emoji { font-size: 2rem; line-height: 1; }
.opt .opt-img { flex: none; width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }
.opts.radio .opt:has(.opt-img) { padding-block: 10px; }
.opt:has(input:checked) .opt-img { outline: 2px solid var(--blue); outline-offset: 1px; }
.opt .txt { display: grid; gap: 6px; font-size: 1.05rem; }
.opt .txt b { font-weight: 700; }
.opt .dot {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid #555; display: grid; place-items: center;
  transition: border-color 0.2s;
}
.opt .dot::after {
  content: ''; width: 12px; height: 12px; border-radius: 50%;
  background: var(--blue); transform: scale(0); transition: transform 0.25s var(--ease);
}
.opt:has(input:checked) { border-color: var(--blue); background: rgb(58 99 227 / 0.12); }
.opt:has(input:checked) .dot { border-color: var(--blue); }
.opt:has(input:checked) .dot::after { transform: scale(1); }
.opts.radio .opt .txt { font-weight: 700; }
.opts.radio .opt .txt span { font-weight: 400; }

/* ---------- régua ---------- */
.units {
  display: inline-flex; margin: 0 auto; padding: 4px; gap: 4px;
  background: #444; border-radius: 10px;
}
.units button {
  font: inherit; font-size: 1.05rem; border: 0; cursor: pointer;
  background: none; color: #bbb; padding: 6px 22px; border-radius: 7px;
}
.units button[aria-pressed="true"] { background: var(--blue); color: #fff; }
.ruler-value { text-align: center; font-weight: 700; font-size: 3.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.ruler-value small { font-size: 1.3rem; margin-left: 2px; }
.ruler { position: relative; }
.ruler-track {
  display: flex; overflow-x: auto; scrollbar-width: none;
  scroll-snap-type: x mandatory;
  padding: 0 calc(50% - var(--tick) / 2);
  mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
  cursor: grab; touch-action: pan-x;
}
.ruler-track.dragging { scroll-snap-type: none; cursor: grabbing; }
.ruler-track::-webkit-scrollbar { display: none; }
.tick {
  flex: none; width: var(--tick); height: 110px; position: relative;
  scroll-snap-align: center; user-select: none;
}
.tick::before {
  content: ''; position: absolute; left: 50%; top: 0;
  width: 1px; height: 30px; background: #555;
}
.tick.mid::before { height: 42px; }
.tick.major::before { height: 78px; background: #777; }
.tick b {
  position: absolute; left: 50%; top: 82px; transform: translateX(-50%);
  font-weight: 400; color: #aaa; font-size: 1rem;
}
.ruler-needle {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px;
  background: var(--blue); border-radius: 2px; pointer-events: none;
}
.ruler-needle::after {
  content: ''; position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%);
  border: 13px solid transparent; border-bottom: 18px solid var(--blue); border-top: 0;
}
.ruler-hint { text-align: center; color: var(--muted); font-size: 0.9rem; }

/* ---------- carregamento ---------- */
.loading-img { width: min(100%, 460px); margin: 0 auto; border-radius: var(--radius); }
.bar-meta { display: flex; justify-content: space-between; font-weight: 500; }
.bar { height: 12px; border-radius: 99px; background: #444; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--blue); border-radius: inherit; }
.loading-text { color: var(--muted); text-align: center; line-height: 1.45; }

/* ---------- resultado ---------- */
.result { gap: 20px; }
.result h1, .result h2 { font-weight: 900; color: var(--blue-strong); }
.result h2 { font-size: clamp(1.4rem, 1.1rem + 1.4vw, 1.85rem); text-align: center; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat {
  border-radius: 10px; padding: 18px 12px; text-align: center;
  display: grid; gap: 10px; align-content: center; color: #111;
}
.stat .label { font-weight: 700; font-size: 0.95rem; }
.stat .value { font-weight: 900; font-size: 1.8rem; color: var(--blue-strong); font-variant-numeric: tabular-nums; }
.stat .unit { font-size: 0.95rem; }
.stat.tmb { background: #e6edfd; }
.stat.tmb .label { color: #4a72f0; }
.stat.get { background: #d4f8d4; }
.stat.get .label { color: #2e6b2e; }

.treino { width: min(100%, 470px); margin: 0 auto; border-radius: var(--radius); overflow: hidden; border: 1px solid #222; }
.treino img { display: block; width: 100%; height: auto; }
.treino.vertical { width: min(100%, 240px); }
.treino-card {
  aspect-ratio: 470 / 300; display: grid; place-items: center; align-content: center; gap: 10px;
  background:
    radial-gradient(120% 90% at 0% 100%, rgb(40 110 230 / 0.45), transparent 55%),
    radial-gradient(80% 80% at 100% 0%, rgb(40 110 230 / 0.25), transparent 60%),
    #0b0f18;
}
.treino-card .bars { display: flex; align-items: flex-end; gap: 8px; height: 110px; }
.treino-card .bars i { width: 46px; border-radius: 8px; border: 1.5px solid #777; }
.treino-card .bars i:nth-child(1) { height: 55%; }
.treino-card .bars i:nth-child(2) { height: 78%; }
.treino-card .bars i:nth-child(3) { height: 100%; }
.treino-card .bars i.on { background: #3d93ff; border-color: #3d93ff; }
.treino-card strong { font-weight: 900; font-style: italic; font-size: 1.75rem; }
.treino-card .casa { font-weight: 900; font-size: 3rem; line-height: 1; }
.treino-card .casa + span { color: #3d93ff; font-weight: 900; font-size: 1.5rem; margin-top: -8px; }
.treino-card img { width: 90px; opacity: 0.9; }
.treino-card .plano-titulo { font-weight: 700; font-size: clamp(1.4rem, 1.1rem + 1.5vw, 2rem); }
.treino-card .plano-kcal { font-weight: 900; color: #3d93ff; font-size: clamp(2.6rem, 1.8rem + 4vw, 4.2rem); line-height: 1; font-variant-numeric: tabular-nums; }

.result-text { display: grid; gap: 12px; line-height: 1.45; padding-top: 12px; }
.btn-cta {
  display: block; text-align: center; text-decoration: none; margin-top: 24px;
  background: #2563eb; box-shadow: 0 5px 0 #1d4ed8; text-transform: uppercase;
}

@media (max-width: 480px) {
  .opts.grid .opt { padding: 14px 12px; gap: 10px; }
  .opt .emoji { font-size: 1.6rem; }
  .stats { gap: 10px; }
  .stat .value { font-size: 1.45rem; }
  .stat .label, .stat .unit { font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
