/* LOAD · estilos do app sobre o MAGU Design System v1
   Só tokens: nenhuma cor solta aqui. Mobile-first (390 px → 641 → 1081). */

:root { --tab-h: 62px; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
body.lock { overflow: hidden; }
body { padding-bottom: calc(var(--tab-h) + var(--safe-b)); }

.wrap { max-width: var(--maxw-tool); margin: 0 auto; padding: 0 var(--gut); }
main.wrap { padding-top: 24px; padding-bottom: 32px; }   /* main.wrap: vence o padding do .wrap */
.muted { margin: 0; color: var(--text-2); font-size: var(--t-sm); }
.eyebrow { margin: 0; color: var(--text-2); font-size: var(--t-sm); font-weight: 500; }
.mt { margin-top: 14px; } .mt-s { margin-top: 10px; } .mt-l { margin-top: 20px; } .mb { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.list { display: flex; flex-direction: column; gap: 12px; }
.ver { margin: 0; font: 400 var(--t-xs)/1.4 var(--f-mono); color: var(--text-3); }

/* ================= menubar ================= */
.brand-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-txt strong { font: 700 var(--t-md)/1.15 var(--f-display); letter-spacing: .02em; }
.brand-txt small { color: var(--text-3); font-size: var(--t-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ================= abas (barra inferior no celular) ================= */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + var(--safe-b));
  padding: 6px 6px var(--safe-b);
  border-width: 1px 0 0; border-radius: 0; box-shadow: none;
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 44px; padding: 0 2px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-3);
  font-size: 11px; font-weight: 600; letter-spacing: 0;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.tab .ic { width: 22px; height: 22px; }
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--core); }

/* ================= aviso iOS ================= */
.notice {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 14px;
  border-radius: var(--r);
  font-size: var(--t-sm); color: var(--text-2);
}
.notice p { margin: 0; flex: 1; }
.notice > .ic { color: var(--core); }

/* ================= cards ================= */
.card { border-radius: var(--r-bento); padding: 18px; }
.list > .card, .view > .card { margin: 0; }
.view { display: flex; flex-direction: column; gap: 14px; }
.card-title { font-size: var(--t-lg); margin: 0 0 14px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 8px 2px 2px; }
.sec-head h2 { font-size: var(--t-xl); letter-spacing: -.035em; }
.sec-actions { display: flex; gap: 6px; }
.a-list { display: flex; flex-direction: column; gap: 12px; }

/* herói */
.hero { padding: 22px 20px; }
.hero-title { margin-top: 4px; font-size: clamp(1.75rem, 1.3rem + 2vw, 2.4rem); letter-spacing: -.04em; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.stat {
  min-width: 0; padding: 12px 8px; text-align: center;
  border-radius: var(--r);
  background: color-mix(in srgb, var(--bg) 45%, transparent);
  border: 1px solid var(--line);
}
.stat b { display: block; font: 700 var(--t-lg)/1.2 var(--f-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 2px; color: var(--text-3); font-size: var(--t-xs); }

/* formulário */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label, .lbl { color: var(--text-2); font-size: var(--t-xs); font-weight: 600; }
.inline-form { display: flex; flex-direction: column; gap: 10px; }

/* acordeão */
.acc-head {
  width: 100%; min-height: 44px; padding: 0;
  display: flex; align-items: center; gap: 10px;
  border: 0; background: none; color: var(--text);
  font-size: var(--t-md); font-weight: 600; text-align: left;
}
.acc-head span { flex: 1; }
.acc-head > .ic:first-child { color: var(--text-2); }
.caret { color: var(--text-3); transition: transform var(--dur) var(--ease); }
.acc.collapsed .caret, .tCard.collapsed .caret { transform: rotate(-90deg); }
.acc.collapsed .acc-body, .tCard.collapsed .tBody { display: none; }
.acc-body { margin-top: 12px; display: flex; flex-direction: column; gap: 14px; }

/* blocos de ação */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 84px; padding: 14px 8px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 4%, transparent);
  color: var(--text);
  font-size: var(--t-sm); font-weight: 600; text-align: center;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tile .ic { width: 22px; height: 22px; color: var(--core); }
.tile:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.tile.is-danger, .tile.is-danger .ic { color: var(--danger); }
.tile.is-danger:hover { background: var(--danger-soft); }
.tile:focus-within { outline: 2px solid var(--core); outline-offset: 2px; }

/* botão só com ícone */
.ib {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 4%, transparent);
  color: var(--text-2);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ib .ic { width: 18px; height: 18px; }
.ib:hover { color: var(--text); background: color-mix(in srgb, var(--text) 9%, transparent); }
.ib.is-danger { color: var(--danger); }
.ib.is-danger:hover { background: var(--danger-soft); }
.ib:disabled { opacity: .3; pointer-events: none; }

/* ================= card de treino ================= */
.tCard { padding: 16px; }
.tHead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tTitle {
  flex: 1 1 100%; min-width: 0; min-height: 40px;
  display: flex; align-items: center; gap: 8px;
  padding: 0; border: 0; background: none; color: var(--text); text-align: left;
}
.tTitle b { font: 700 var(--t-lg)/1.25 var(--f-display); letter-spacing: -.025em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tActions { display: flex; gap: 6px; margin-left: auto; }
.tCard .chips { margin-top: 10px; }
.tBody { margin-top: 16px; }

.exList { display: flex; flex-direction: column; gap: 8px; }
.exRow {
  padding: 12px; border-radius: var(--r);
  background: color-mix(in srgb, var(--bg) 40%, transparent);
  border: 1px solid var(--line);
}
.exTop { display: flex; align-items: center; gap: 10px; }
.num {
  width: 26px; height: 26px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs);
  background: var(--core-soft); color: var(--core-hi);
  font-size: var(--t-xs); font-weight: 700; font-variant-numeric: tabular-nums;
}
.exTop b { flex: 1; min-width: 0; font-size: var(--t-md); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exRow .chips { margin-top: 8px; }
.exActs { display: flex; gap: 6px; margin-top: 10px; }
.exActs .ib { flex: 1; width: auto; min-width: 40px; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 12px; color: var(--text-2); font-size: var(--t-sm); text-align: center; }
.empty-ic {
  width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r); background: var(--core-soft); color: var(--core);
}
.empty-ic .ic { width: 24px; height: 24px; }
.empty.is-ok .empty-ic { background: var(--ok-soft); color: var(--ok-text); }

.addBox {
  margin-top: 14px; padding: 14px;
  border-radius: var(--r);
  border: 1px dashed color-mix(in srgb, var(--text) 18%, transparent);
}
.addGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.addGrid .full { grid-column: 1 / -1; }

/* ================= sessão ================= */
.sessHead .chips { margin-top: 10px; }
.sessHead .meter { margin-top: 14px; }
.sess-title { margin-top: 2px; font-size: var(--t-xl); letter-spacing: -.035em; }
.sessHead .row { margin-top: 14px; }
.sessHead .row .btn { flex: 1; }

.exCard { padding: 16px; }
.exCard.full { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.exCard-title { font: 700 var(--t-lg)/1.25 var(--f-display); letter-spacing: -.025em; margin: 0; }
.exCard .chips { margin-top: 8px; }

.setRow { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 14px 0 2px; margin-top: 12px; border-top: 1px solid var(--line); }
.setRow.done .setCol { opacity: .5; }
.setN {
  width: 34px; height: 34px; flex: none; margin-bottom: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  font-weight: 700; font-size: var(--t-sm); font-variant-numeric: tabular-nums;
}
.setN .ic { width: 18px; height: 18px; }
.setRow.done .setN { background: var(--ok-soft); color: var(--ok-text); }
.setCol { flex: 1 1 120px; min-width: 112px; display: flex; flex-direction: column; gap: 6px; }
.stepper {
  display: flex; align-items: center; gap: 4px; padding: 3px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
.stepper input {
  flex: 1; min-width: 0; width: 100%;
  border: 0; background: none; color: var(--text);
  text-align: center; padding: 8px 0;
  font: 700 var(--t-lg)/1 var(--f-display); font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: 2px solid var(--core); outline-offset: 0; border-radius: var(--r-xs); }
.stepper button {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text); font-size: 20px; font-weight: 500;
  transition: background-color var(--dur) var(--ease);
}
.stepper button:hover { background: color-mix(in srgb, var(--text) 14%, transparent); }
.stepper button:disabled { opacity: .35; pointer-events: none; }
.setDone { flex: 1 1 100%; }
.setRow .chip--ok { flex: 1 1 100%; justify-content: center; min-height: 46px; border-radius: var(--r); font-size: var(--t-sm); }

/* modo foco */
.foco { padding: 20px; }
.foco-nome { margin: 4px 0 12px; font-size: var(--t-xl); letter-spacing: -.035em; }
.dots { display: flex; gap: 6px; margin: 16px 0 2px; }
.dots i { flex: 1; height: 6px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--text) 12%, transparent); }
.dots i.on { background: var(--ok); }
.dots i.now { background: var(--core); }
.foco .setRow { padding-top: 16px; }
.foco .stepper input { font-size: var(--t-xl); padding: 10px 0; }
.foco .stepper button { width: 48px; height: 48px; }
.foco .setDone { min-height: 54px; font-size: var(--t-md); }
.foco-hist { margin-top: 12px; font-variant-numeric: tabular-nums; }
.foco-next { margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--line); }
.foco-next b { color: var(--text); }

/* ================= tabelas ================= */
.tScroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); min-width: 380px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 8px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { color: var(--text-3); font-size: var(--t-xs); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.up { color: var(--ok-text); font-weight: 700; }
.down { color: var(--danger); font-weight: 700; }

/* ================= progressão ================= */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { padding: 14px 8px; text-align: center; border-radius: var(--r); }
.kpi b { display: block; font: 700 var(--t-lg)/1.2 var(--f-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi span { display: block; margin-top: 2px; color: var(--text-3); font-size: var(--t-xs); }
.chart { width: 100%; height: 180px; display: block; overflow: visible; }
.chart .c-area { fill: var(--core-soft); stroke: none; }
.chart .c-line { fill: none; stroke: var(--core); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .c-base { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-wrap { position: relative; }
.chart-pts { position: absolute; inset: 0; pointer-events: none; }
.chart-pt {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--core);
}
.chart-v, .chart-l {
  position: absolute; transform: translateX(-50%);
  font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chart-v { color: var(--text-2); margin-top: -24px; }
.chart-l { bottom: -24px; color: var(--text-3); }
.chart-box { padding-bottom: 26px; }

.kv { display: grid; gap: 10px; }
.kv div { display: flex; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); color: var(--text-2); font-size: var(--t-sm); }
.kv div:last-child { border-bottom: 0; padding-bottom: 0; }
.kv b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ================= sobreposições ================= */
.overlay {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: var(--scrim);
}
.overlay.sheet { align-items: flex-end; padding: 0; }
.modal {
  width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
  padding: 20px; border-radius: var(--r-bento);
}
.modal h3 { font-size: var(--t-lg); margin: 0 0 16px; }
.overlay.sheet .modal { max-width: 520px; margin: 0 auto; border-radius: var(--r-bento) var(--r-bento) 0 0; padding-bottom: calc(20px + var(--safe-b)); }
.grab { width: 40px; height: 5px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--text) 22%, transparent); margin: -6px auto 14px; }
#mAviso:empty { display: none; }

.timer-box { max-width: 340px; text-align: center; padding: 26px 22px 22px; }
#timerNum { font: 700 clamp(4.5rem, 3rem + 8vw, 6rem)/1.05 var(--f-display); letter-spacing: -.05em; font-variant-numeric: tabular-nums; margin: 6px 0 16px; }

.dlg h3 { margin-bottom: 8px; }
.dlg #dlgX { white-space: pre-line; }
.dlg #dlgIn { margin-top: 14px; }
.dlg-acts { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 90;
  width: max-content; max-width: min(440px, calc(100% - 32px));
  padding: 12px 18px; border-radius: var(--r);
  font-size: var(--t-sm); font-weight: 600; text-align: center;
}

/* botão flutuante */
.fab {
  position: fixed; right: 16px; z-index: 60;
  bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px; min-height: 56px; padding: 0;
  border-radius: var(--r);
  box-shadow: 0 12px 28px -10px color-mix(in srgb, var(--core) 60%, transparent);
}
.fab .ic { width: 24px; height: 24px; }

.foot { margin-top: 8px; }
.foot-links { align-items: center; }
.foot-power { margin: 0; }

/* ================= 641 px ou mais: 2 colunas ================= */
@media (min-width: 641px) {
  main.wrap { padding-top: 32px; }
  .inline-form { flex-direction: row; }
  .inline-form .input { flex: 1; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tiles-4 { grid-template-columns: repeat(4, 1fr); }
  .addGrid { grid-template-columns: repeat(4, 1fr); }
  .tTitle { flex: 1 1 auto; }
  .exRow { display: flex; align-items: center; gap: 12px; }
  .exRow .exBody { flex: 1; min-width: 0; }
  .exActs { margin-top: 0; }
  .exActs .ib { flex: none; width: 40px; }
  .setRow { flex-wrap: nowrap; }
  .setDone, .setRow .chip--ok { flex: 0 0 150px; }
  .foco .setDone { flex-basis: 190px; }
  .grid-dados { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .grid-dados .span-2 { grid-column: 1 / -1; }
  .grid-dados > .card { margin: 0; }
  .dlg-acts { flex-direction: row-reverse; }
  .dlg-acts .btn { flex: 1; }
  .overlay.sheet { align-items: center; padding: 16px; }
  .overlay.sheet .modal { border-radius: var(--r-bento); padding-bottom: 20px; }
  .grab { display: none; }
}
@media (max-width: 640px) {
  .grid-dados { display: flex; flex-direction: column; gap: 14px; }
  /* série no celular: carga e repetições empilhadas, alvos grandes */
  .setRow { display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; row-gap: 10px; align-items: end; }
  .setRow .setN { grid-column: 1; grid-row: 1 / span 2; align-self: center; margin: 0; }
  .setRow .setCol { grid-column: 2; min-width: 0; }
  .setRow .setDone, .setRow .chip--ok { grid-column: 1 / -1; }
  .foco .setRow { grid-template-columns: 1fr; }
  .foco .setRow .setN { display: none; }
  .foco .setRow .setCol { grid-column: 1; }
}

/* ================= 1081 px ou mais: abas na menubar ================= */
@media (min-width: 1081px) {
  body { padding-bottom: 0; }
  :root { --bar-h: 64px; }                 /* menubar mais alta: abas de 44 px cabem com folga */
  main.wrap { padding-top: 44px; }
  .tabbar {
    top: calc(var(--safe-t) + (var(--bar-h) - 52px) / 2); bottom: auto;
    left: 50%; right: auto; transform: translateX(-50%);
    height: 52px; padding: 3px; gap: 2px;
    display: flex;
    border-width: 1px; border-radius: var(--r);
    background: color-mix(in srgb, var(--text) 5%, transparent);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .tabbar .tab { flex-direction: row; gap: 7px; min-height: 44px; height: 44px; padding: 0 16px; font-size: var(--t-sm); border-radius: var(--r-sm); }
  .tabbar .tab .ic { width: 17px; height: 17px; }
  .tab.active { background: var(--core-soft); color: var(--core-hi); }
  .fab { bottom: calc(24px + var(--safe-b)); right: 24px; }
  .toast { bottom: calc(24px + var(--safe-b)); }

  .v-treinos {
    display: grid; gap: 16px; align-items: start;
    grid-template-columns: minmax(320px, 380px) 1fr;
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: "hero list" "novo list" "xfer list" ". list";
  }
  .a-hero { grid-area: hero; } .a-novo { grid-area: novo; } .a-xfer { grid-area: xfer; } .a-list { grid-area: list; }
  .a-novo .inline-form { flex-direction: column; }
  .a-xfer .tiles { grid-template-columns: 1fr 1fr; }
  .a-list .sec-head { margin-top: 0; }
  .list-2 { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .v-narrow { max-width: 760px; margin: 0 auto; width: 100%; }
}

/* "Powered by MAGU": produtos ficam sob o guarda-chuva MAGU */

/* Design system · alvos de toque: tudo que se toca tem pelo menos 44 px */
.menubar-brand, .foot-links a, .tab { min-height: 44px; display: inline-flex; align-items: center; }
.btn, button.btn, .btn-glass, .btn-core { min-height: 44px; }
