
  :root {
    --bg: #F2F1ED;
    --surface: #FBFAF8;
    --surface2: #EBE9E3;
    --ink: #23201C;
    --muted: #6B665C;
    --line: #DEDAD1;
    --accent: #A63E0F;
    --accent-ink: #FFFFFF;
    --accent-soft: #F4E0D3;
    --good: #3E7C4F;
    --good-soft: #E0EBE3;
    --warn-soft: #F2E8CE;
    --shadow: 0 1px 3px rgba(35, 32, 28, 0.08);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #16181C;
      --surface: #1F2227;
      --surface2: #282C33;
      --ink: #E9E7E1;
      --muted: #9B968D;
      --line: #32363E;
      --accent: #FF7A3D;
      --accent-ink: #1C1006;
      --accent-soft: #3B2517;
      --good: #6AB47F;
      --good-soft: #20301F;
      --warn-soft: #363019;
      --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    }
  }
  :root[data-theme="light"] {
    --bg: #F2F1ED;
    --surface: #FBFAF8;
    --surface2: #EBE9E3;
    --ink: #23201C;
    --muted: #6B665C;
    --line: #DEDAD1;
    --accent: #A63E0F;
    --accent-ink: #FFFFFF;
    --accent-soft: #F4E0D3;
    --good: #3E7C4F;
    --good-soft: #E0EBE3;
    --warn-soft: #F2E8CE;
    --shadow: 0 1px 3px rgba(35, 32, 28, 0.08);
  }
  :root[data-theme="dark"] {
    --bg: #16181C;
    --surface: #1F2227;
    --surface2: #282C33;
    --ink: #E9E7E1;
    --muted: #9B968D;
    --line: #32363E;
    --accent: #FF7A3D;
    --accent-ink: #1C1006;
    --accent-soft: #3B2517;
    --good: #6AB47F;
    --good-soft: #20301F;
    --warn-soft: #363019;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }
  .wrap { max-width: 680px; margin: 0 auto; padding: 20px 16px 120px; }

  .eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
    font-weight: 600;
  }
  h1 {
    margin: 4px 0 2px;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.015em;
    text-wrap: balance;
  }
  .subtitle { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

  /* ---- status card ---- */
  .status {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
  }
  .status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .week-pill {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 800;
    font-size: 13px;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
  }
  .phase-name { font-weight: 700; font-size: 15px; }
  .phase-desc { color: var(--muted); font-size: 13px; margin-top: 6px; }
  .next-line { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .next-line .lbl { font-size: 13px; color: var(--muted); }
  .next-line .val { font-weight: 700; }

  /* ---- buttons ---- */
  button { font: inherit; cursor: pointer; }
  .btn {
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--ink);
    border-radius: 8px;
    padding: 11px 16px;
    font-weight: 600;
    font-size: 14px;
  }
  .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
  }
  .btn-big { width: 100%; padding: 13px; font-size: 16px; border-radius: 10px; }
  .btn-ghost { background: none; border: none; color: var(--muted); font-size: 13px; padding: 6px 8px; text-decoration: underline; }
  button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  /* ---- tabs ---- */
  .tabs {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 0 10px;
    margin-bottom: 12px;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    border-radius: 999px;
    padding: 11px 15px;
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .tab.active {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
  }
  .tab.suggested::after {
    content: "";
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent);
    margin-left: 6px;
    vertical-align: 1px;
  }
  .tab.active.suggested::after { background: var(--bg); }

  /* ---- workout view ---- */
  .banner {
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13.5px;
    margin-bottom: 12px;
    background: var(--warn-soft);
    border: 1px solid var(--line);
  }
  .banner.good { background: var(--good-soft); }
  .wo-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
  .wo-head h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
  .wo-head .tag { color: var(--muted); font-size: 13px; }

  .ex-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
  }
  .ex-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .ex-name { font-weight: 700; font-size: 15.5px; }
  .ex-target {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
  }
  .ex-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
  .ex-last {
    margin-top: 9px;
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }
  .ex-hint {
    display: inline-block;
    margin-top: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
  }
  .ex-hint.keep { color: var(--good); }

  .sets { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
  .set-row {
    display: grid;
    grid-template-columns: 46px 1fr 1fr 44px;
    gap: 6px;
    align-items: center;
  }
  .set-row .set-lbl { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
  .set-row input[type="text"] {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--ink);
    border-radius: 7px;
    padding: 11px 9px;
    font: inherit;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
  }
  .set-row input[type="text"]::placeholder { color: var(--muted); opacity: 0.7; }
  .set-row.done input[type="text"] { border-color: var(--good); background: var(--good-soft); }
  .chk {
    appearance: none;
    -webkit-appearance: none;
    width: 44px; height: 44px;
    margin: 0 auto;
    border: 2px solid var(--line);
    border-radius: 10px;
    background: var(--surface2);
    display: grid;
    place-content: center;
    cursor: pointer;
  }
  .chk:checked { background: var(--good); border-color: var(--good); }
  .chk:checked::after {
    content: "";
    width: 8px; height: 13px;
    border: solid var(--bg);
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg) translateY(-1px);
  }
  .finish-area { margin: 18px 0 8px; display: flex; flex-direction: column; gap: 6px; align-items: center; }

  /* ---- guide ---- */
  .guide h3 { font-size: 16px; margin: 22px 0 6px; font-weight: 800; }
  .guide p, .guide li { font-size: 14.5px; max-width: 62ch; }
  .guide ul, .guide ol { padding-left: 20px; margin: 6px 0; }
  .guide .card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 8px 0; }
  .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
  .kv dt { font-weight: 700; white-space: nowrap; }
  .kv dd { margin: 0; color: var(--muted); }
  .danger-zone { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; }

  /* ---- history ---- */
  .hist-item {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
  }
  .hist-item summary { cursor: pointer; font-weight: 700; font-size: 14.5px; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
  .hist-item summary::-webkit-details-marker { display: none; }
  .hist-item summary .d { color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
  .hist-body { margin-top: 10px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
  .hist-body .row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-top: 1px dashed var(--line); }
  .hist-body .row span:last-child { color: var(--muted); white-space: nowrap; }
  .empty { color: var(--muted); font-size: 14px; text-align: center; padding: 30px 0; }

  /* ---- timer ---- */
  .timerbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 20;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }
  .timerbar-inner { max-width: 680px; margin: 0 auto; display: flex; align-items: center; gap: 8px; }
  .timerbar .lbl { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; margin-right: 2px; }
  .tbtn {
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--ink);
    border-radius: 999px;
    padding: 10px 15px;
    font-weight: 700;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
  }
  .t-count {
    border: none;
    background: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
    margin-left: auto;
    padding: 12px 4px;
    min-height: 44px;
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    min-width: 68px;
    text-align: right;
  }
  .t-count.idle { color: var(--muted); font-size: 14px; font-weight: 500; }
  @media (prefers-reduced-motion: no-preference) {
    .t-count.ringing { animation: pulse 0.6s ease-in-out infinite alternate; }
    @keyframes pulse { from { opacity: 1; } to { opacity: 0.35; } }
  }

  .toast {
    position: fixed;
    left: 50%;
    bottom: 90px;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--bg);
    padding: 9px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    z-index: 30;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
    white-space: nowrap;
  }
  .toast.show { opacity: 1; }

  .hidden { display: none !important; }

  /* ---- como executar ---- */
  .how { margin-top: 9px; border-top: 1px dashed var(--line); padding-top: 8px; }
  .how summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .how summary::-webkit-details-marker { display: none; }
  .how summary::before { content: "▸"; font-size: 11px; transition: transform 0.15s; }
  .how[open] summary::before { transform: rotate(90deg); }
  @media (prefers-reduced-motion: reduce) { .how summary::before { transition: none; } }
  .how ul { margin: 8px 0 6px; padding-left: 18px; font-size: 13.5px; }
  .how li { margin: 3px 0; }
  .alt-title { margin: 10px 0 2px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
  .alt-list { margin: 4px 0 8px; padding-left: 20px; font-size: 13.5px; }
  .alt-list li { margin: 2px 0; }
  .ytlink {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    margin-top: 2px;
  }
  .ytlink:hover { text-decoration: underline; }
  .how-img {
    position: relative;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px;
    margin: 8px auto 6px;
    max-width: 340px;
  }
  .how-img img { display: block; width: 100%; height: auto; }
  .how-img .fr2 {
    position: absolute;
    inset: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    object-fit: contain;
    background: #fff;
    opacity: 0;
  }
  @media (prefers-reduced-motion: no-preference) {
    .how-img.anim .fr2 { animation: exflip 2.4s steps(1) infinite; }
    @keyframes exflip { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }
  }

  /* ---- progresso ---- */
  .prog h3 { font-size: 16px; margin: 20px 0 8px; font-weight: 800; }
  .prog .note { color: var(--muted); font-size: 13.5px; max-width: 62ch; margin: 4px 0 12px; }
  .m-form {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
  }
  .m-form .fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
  @media (min-width: 480px) { .m-form .fields { grid-template-columns: repeat(3, 1fr); } }
  .m-form label { font-size: 12px; line-height: 1.25; color: var(--muted); font-weight: 600; display: block; min-height: 2.5em; }
  .m-form input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--ink);
    border-radius: 7px;
    padding: 7px 8px;
    font: inherit;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
  }
  .m-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  @media (min-width: 480px) { .m-grid { grid-template-columns: repeat(3, 1fr); } }
  .m-tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: var(--shadow);
  }
  .m-name { font-size: 12px; line-height: 1.25; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
  .m-val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
  .m-val small { font-size: 12px; font-weight: 600; color: var(--muted); }
  .m-delta { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 1px; }
  .m-delta.up { color: var(--accent); }
  .m-delta.flat { color: var(--muted); font-weight: 500; }
  .spark { display: block; margin-top: 6px; width: 100%; height: 32px; }
  .spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .spark .pt-end { fill: var(--accent); }
  .spark .pt-start { fill: var(--muted); }
  .s-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 4px 14px;
    align-items: center;
  }
  .s-row .n { font-weight: 700; font-size: 14px; }
  .s-row .d { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .s-row .d b { color: var(--accent); }
  .s-row .spark { grid-row: 1 / 3; grid-column: 2; margin: 0; }

  /* ---- print sheets ---- */
  .print-sheets { display: none; }
  @media print {
    body { background: #fff; color: #000; }
    .app, .timerbar, .toast { display: none !important; }
    .print-sheets { display: block; font-size: 11px; }
    .sheet { page-break-after: always; padding: 4px 0; }
    .sheet:last-child { page-break-after: auto; }
    .sheet h2 { font-size: 16px; margin: 0 0 2px; }
    .sheet .sub { font-size: 10px; color: #444; margin: 0 0 8px; }
    .sheet table { width: 100%; border-collapse: collapse; }
    .sheet th, .sheet td { border: 1px solid #999; padding: 3px 5px; vertical-align: top; text-align: left; }
    .sheet th { background: #eee; font-size: 10px; }
    .sheet .exn { font-weight: 700; width: 24%; }
    .sheet .exn small { font-weight: 400; color: #444; }
    .sheet .slot { height: 14px; border-bottom: 1px dotted #bbb; }
    .sheet .slot:last-child { border-bottom: none; }
    .rules { font-size: 10.5px; margin-top: 8px; }
    .rules b { display: inline-block; margin-right: 4px; }
  }


/* controle de semana (app agnóstico de fase) */
.week-ctrl {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 10px 0 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.wk-lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.wk-sel {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
}
.wk-auto {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.wk-auto input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

/* barra do timer em telas pequenas (evita overflow em 320–390px) */
@media (max-width: 400px) {
  .timerbar .lbl { display: none; }
  .timerbar-inner { gap: 6px; }
  .tbtn { padding: 11px 12px; }
  .t-count { min-width: 56px; font-size: 20px; }
}

/* pares de superset ligados visualmente */
.ex-card.superset { border-left: 3px solid var(--accent); }

/* exercício com todas as séries concluídas */
.ex-card.ex-done { opacity: 0.6; }
.ex-card.ex-done .ex-name::after { content: " ✓"; color: var(--good); font-weight: 800; }

/* card de status: detalhes/ajuste de semana recolhíveis */
.status-more { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.status-more > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 6px; }
.status-more > summary::-webkit-details-marker { display: none; }
.status-more > summary::before { content: "▸"; font-size: 11px; }
.status-more[open] > summary::before { content: "▾"; }
.status-more .week-ctrl { margin-top: 8px; }

/* aviso persistente de falha de armazenamento */
.storagewarn {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.storagewarn button {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: inherit;
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
}

/* classes que substituem inline styles (CSP style-src 'self') */
.btn-label { display: inline-block; }
.muted-link { color: var(--muted); }
.credit { font-size: 12px; color: var(--muted); margin-top: 14px; }
