/* Treinos. Colours follow the plan PDF: navy headers, burnt orange for targets and actions. */
:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #1b2533;
  --muted: #5f6a7a;
  --line: #e2e5ea;
  --head: #1e2a3b;
  --head-ink: #ffffff;
  --accent: #b4530f;
  --accent-ink: #ffffff;
  --accent-soft: #fbeee2;
  --accent-bright: #f08c3e; /* the colour on the navy bar and the app icon */
  --good: #1d7a4c;
  --good-soft: #e2f3ea;
  --danger: #b42318;
  --fig-bg: #f7f8fa; /* panel behind the exercise drawings (the head is filled with it) */
  --radius: 14px;
  --tabs-h: 62px;
  --top-h: calc(58px + env(safe-area-inset-top, 0px));
  --top-shadow: rgb(27 37 51 / .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* The tab bar floats above the bottom edge (or above the iPhone's home indicator). */
  --dock-bottom: calc(max(var(--safe-b), 8px) + 6px);
  --dock: calc(var(--dock-bottom) + var(--tabs-h)); /* from the bottom of the screen to the top of the bar */
  --dock-shadow: rgb(27 37 51 / .14);
  /* achievement medals: Bronze, Prata, Ouro, Platina, Diamante */
  --t1-bg: #f6e3d3; --t1-fg: #8a4b1c;
  --t2-bg: #e8ecf1; --t2-fg: #56616f;
  --t3-bg: #fbefc4; --t3-fg: #8a6200;
  --t4-bg: #dcf2f2; --t4-fg: #1f6f73;
  --t5-bg: #e6e8ff; --t5-fg: #4048c4;
  color-scheme: light;
}

/* Dark colours: the system setting, unless the person chose light or dark in Perfil → Tema.
   theme.js sets data-theme before the first paint; the media query covers pages without it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1218;
    --surface: #161d26;
    --surface-2: #1b232e;
    --ink: #e7eaef;
    --muted: #9ba5b3;
    --line: #28313d;
    --head: #0b1017;
    --head-ink: #e7eaef;
    --accent: #f08c3e;
    --accent-ink: #1b0e04;
    --accent-soft: #3a2415;
    --top-shadow: rgb(0 0 0 / .35);
    --dock-shadow: rgb(0 0 0 / .45);
    --good: #52c98f;
    --good-soft: #15301f;
    --danger: #ff7a6e;
    --fig-bg: #1b232e;
    color-scheme: dark;
    --t1-bg: #3a2516; --t1-fg: #e7a26b;
    --t2-bg: #2a313b; --t2-fg: #c3ccd8;
    --t3-bg: #3a3010; --t3-fg: #f0c94a;
    --t4-bg: #143235; --t4-fg: #6fd3d6;
    --t5-bg: #22264d; --t5-fg: #a3aaff;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1218;
  --surface: #161d26;
  --surface-2: #1b232e;
  --ink: #e7eaef;
  --muted: #9ba5b3;
  --line: #28313d;
  --head: #0b1017;
  --head-ink: #e7eaef;
  --accent: #f08c3e;
  --accent-ink: #1b0e04;
  --accent-soft: #3a2415;
  --top-shadow: rgb(0 0 0 / .35);
  --dock-shadow: rgb(0 0 0 / .45);
  --good: #52c98f;
  --good-soft: #15301f;
  --danger: #ff7a6e;
  --fig-bg: #1b232e;
  color-scheme: dark;
  --t1-bg: #3a2516; --t1-fg: #e7a26b;
  --t2-bg: #2a313b; --t2-fg: #c3ccd8;
  --t3-bg: #3a3010; --t3-fg: #f0c94a;
  --t4-bg: #143235; --t4-fg: #6fd3d6;
  --t5-bg: #22264d; --t5-fg: #a3aaff;
}

/* Accent colours (Perfil → Tema). They also paint the colour samples, which carry data-accent. */
[data-accent="laranja"] { --accent-bright: #f08c3e; --accent: #b4530f; --accent-ink: #ffffff; --accent-soft: #fbeee2; }
[data-accent="azul"] { --accent-bright: #6aa6ff; --accent: #1d5fbf; --accent-ink: #ffffff; --accent-soft: #e3edfb; }
[data-accent="verde"] { --accent-bright: #3fc7b5; --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #dcf3f0; }
[data-accent="roxo"] { --accent-bright: #b28cff; --accent: #6d3fc0; --accent-ink: #ffffff; --accent-soft: #eee7fb; }
[data-accent="rosa"] { --accent-bright: #ff7aa2; --accent: #c0265a; --accent-ink: #ffffff; --accent-soft: #fbe4ec; }
[data-accent="grafite"] { --accent-bright: #c3cbd6; --accent: #3d4a5c; --accent-ink: #ffffff; --accent-soft: #e6e9ee; }
[data-theme="dark"][data-accent="laranja"], [data-theme="dark"] [data-accent="laranja"] { --accent: #f08c3e; --accent-ink: #1b0e04; --accent-soft: #3a2415; }
[data-theme="dark"][data-accent="azul"], [data-theme="dark"] [data-accent="azul"] { --accent: #6aa6ff; --accent-ink: #06142b; --accent-soft: #16263d; }
[data-theme="dark"][data-accent="verde"], [data-theme="dark"] [data-accent="verde"] { --accent: #3fc7b5; --accent-ink: #04201c; --accent-soft: #10302c; }
[data-theme="dark"][data-accent="roxo"], [data-theme="dark"] [data-accent="roxo"] { --accent: #b28cff; --accent-ink: #1a0c33; --accent-soft: #2a1f42; }
[data-theme="dark"][data-accent="rosa"], [data-theme="dark"] [data-accent="rosa"] { --accent: #ff7aa2; --accent-ink: #2b0612; --accent-soft: #3d1825; }
[data-theme="dark"][data-accent="grafite"], [data-theme="dark"] [data-accent="grafite"] { --accent: #c3cbd6; --accent-ink: #11161d; --accent-soft: #262e39; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; touch-action: pan-x pan-y; } /* scroll yes, pinch and double-tap zoom no */
html:has(body.doc) { touch-action: auto; } /* the privacy policy is a document: zoom stays */

/* The app behaves like an installed app: no text selection or copy menu, except in the fields.
   Fields keep 16 px or more: iOS zooms into smaller ones when they get focus. */
body:not(.doc) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body:not(.doc) :is(input, textarea, select) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-top: var(--top-h); /* room for the fixed top bar */
  padding-bottom: calc(var(--dock) + 16px);
}
body.resting { padding-bottom: calc(var(--dock) + 104px); }

a { color: inherit; }
button { font: inherit; color: inherit; }
h2 { font-size: 1.45rem; line-height: 1.2; margin: .15rem 0 .5rem; letter-spacing: -.01em; }
h4 { margin: 1rem 0 .35rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.strong { font-weight: 650; }
.accent { color: var(--accent); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lead { color: var(--muted); margin: .25rem 0 1rem; }

/* ---------- top bar: fixed, so it stays on screen while the page scrolls */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: var(--top-h);
  /* On wide screens the contents line up with the 640 px column of the page. */
  padding: env(safe-area-inset-top, 0px) max(12px, calc((100% - 640px) / 2 + 12px)) 0;
  /* The colour of the page, a little see-through: white in light mode, dark grey in dark mode. */
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .2s ease;
}
body.scrolled .top { box-shadow: 0 4px 18px var(--top-shadow); }
.top h1 {
  flex: 1; min-width: 0; margin: 0; font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* The app icon (navy tile, figure in the colour of the theme) on every screen. */
.brand {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: #1e2a3b; color: var(--accent-bright);
  box-shadow: 0 1px 4px rgb(0 0 0 / .18);
}
.brand svg { width: 25px; height: 25px; display: block; }
.icon-btn {
  flex: none; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 12px;
  display: grid; place-items: center; background: var(--surface-2); color: inherit; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line);
}
.icon-btn:active { background: var(--line); }
.sync {
  display: flex; align-items: center; gap: 7px; flex: none;
  border: 1px solid var(--line); background: var(--surface-2); color: inherit;
  font-size: .75rem; font-weight: 600; padding: 6px 11px 6px 9px; border-radius: 999px; max-width: 46vw; cursor: pointer;
}
.sync span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: #9aa3ad; flex: none; }
.sync[data-state="ok"] i { background: #4ccf8e; box-shadow: 0 0 0 3px rgb(76 207 142 / .22); }
.sync[data-state="warn"] i { background: #f5a524; box-shadow: 0 0 0 3px rgb(245 165 36 / .22); }
/* Narrow phones: with the back button and the icon, an all-good sync shows only its green dot. */
@media (max-width: 430px) {
  .sync[data-state="ok"] { padding: 9px; }
  .sync[data-state="ok"] span { display: none; }
}

/* ---------- layout */
main {
  max-width: 640px; margin: 0 auto; padding: 16px;
  outline: none;
}

.section {
  margin: 1.6rem 0 .6rem; font-size: .8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}

.list {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.list > .section { margin: 0; padding: 14px 16px 6px; background: var(--surface-2); border-top: 1px solid var(--line); }
.list > .section:first-child { border-top: 0; }
.list > a { text-decoration: none; }
.list > * + a, .list > a + * { border-top: 1px solid var(--line); }

.day-row, .ex-row, .prog-row, .sum-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 64px;
}
.day-row:active, .ex-row:active, .prog-row:active, .sum-row:active { background: var(--surface-2); }
.day-row > svg, .sum-row > svg { color: var(--muted); flex: none; }
.day-tag {
  flex: none; width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-content: center; text-align: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; line-height: 1.1;
}
.day-tag b { display: block; font-size: 1.1rem; }
.ex-row { align-items: flex-start; }
.thumb {
  flex: none; width: 88px; height: 72px; padding: 6px; object-fit: contain;
  border-radius: 10px; background: var(--fig-bg);
}
.thumb.ph { display: grid; place-items: center; color: #8a94a3; }
.num { color: var(--accent); font-weight: 700; }
.sum-row .num { width: 28px; flex: none; text-align: center; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 650; text-decoration: none; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.05rem; margin-top: .75rem; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: .875rem; }
.btn.danger { color: var(--danger); }
.btn.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--accent); font-weight: 600; text-decoration: none;
  background: none; border: 0; padding: 6px 0; cursor: pointer;
}
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 1.25rem 0; }

/* ---------- home */
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; display: flex; flex-direction: column; align-items: flex-start;
}
.hero h2 { font-size: 1.7rem; margin: .1rem 0 .2rem; }
.hero .btn.big { align-self: stretch; }
.hero .link { align-self: center; margin-top: .4rem; }
.hero.live { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hero.done .btn { margin-top: .5rem; }
.eyebrow { margin: 0; font-size: .78rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.eyebrow a { text-decoration: none; }

/* Calendar on the home page: week, month or year. */
.cal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 10px 10px 8px; margin: 14px 0 10px;
}
.segmented.compact { margin: 0 0 8px; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.segmented.compact button { min-height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.segmented.compact button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.cal-bar { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; }
.cal-title { flex: 1; margin: 0 0 0 6px; font-size: 1.05rem; font-weight: 700; }
.cal-bar .icon-sq { width: 36px; height: 36px; border-radius: 10px; }
.cal-today {
  border: 1px solid var(--line); background: transparent; color: var(--accent); cursor: pointer;
  font-size: .8rem; font-weight: 700; border-radius: 999px; padding: 7px 12px;
}
.cal-body { touch-action: pan-y; }
.cal-body.from-right { animation: cal-in-right .22s ease-out; }
.cal-body.from-left { animation: cal-in-left .22s ease-out; }
.cal-body.fade { animation: cal-fade .18s ease-out; }
@keyframes cal-in-right { from { opacity: 0; transform: translateX(24px); } }
@keyframes cal-in-left { from { opacity: 0; transform: translateX(-24px); } }
@keyframes cal-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cal-body { animation: none !important; } }

.cal-week, .cal-month { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-d {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 0;
  color: var(--muted); font-size: .72rem; font-weight: 600; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.cal-d b {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  font-size: .95rem; font-weight: 600; color: var(--ink); transition: transform .12s;
}
.cal-d i { width: 5px; height: 5px; border-radius: 50%; }
.cal-d.later b { color: var(--muted); }
.cal-d.plan b { color: var(--ink); }
.cal-d.plan i { background: var(--muted); opacity: .6; }
.cal-d.trained b { background: var(--accent); color: var(--accent-ink); }
.cal-d.today b { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 800; }
.cal-d.today.trained b { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.cal-d.today span { color: var(--accent); }
a.cal-d:active b { transform: scale(.9); }
.cal-week .cal-d { padding: 4px 0 2px; }
.cal-wd { text-align: center; font-size: .7rem; font-weight: 700; color: var(--muted); padding: 2px 0 4px; }

.cal-year { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) { .cal-year { grid-template-columns: repeat(4, 1fr); } }
.cal-mini {
  display: flex; flex-direction: column; justify-content: flex-start; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 7px 8px 8px;
}
.cal-mini.now { border-color: var(--accent); }
.cal-mini:active { transform: scale(.97); }
.cal-mini-h { display: flex; justify-content: space-between; align-items: center; min-height: 1.2rem; font-size: .8rem; margin-bottom: 5px; }
.cal-mini-h span { color: var(--accent); font-weight: 800; font-size: .75rem; }
.cal-mini-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-mini-g i { aspect-ratio: 1; border-radius: 2px; background: var(--line); }
.cal-mini-g i.x { background: transparent; }
.cal-mini-g i.later { opacity: .45; }
.cal-mini-g i.on { background: var(--accent); opacity: 1; }
.cal-mini-g i.today { box-shadow: 0 0 0 1.5px var(--ink); }

.cal-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px;
  margin: 8px 2px 0; padding-top: 8px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted);
}
.cal-sum b { color: var(--ink); }
.cal-key { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; }
.cal-key i { width: 9px; height: 9px; border-radius: 50%; }
.cal-key .k-done { background: var(--accent); }
.cal-key .k-plan { background: var(--muted); opacity: .6; margin-left: 6px; }

.callout {
  background: var(--accent-soft); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 12px 14px; margin: 1rem 0;
}
.callout p { margin: .3rem 0; }
.callout.good { background: var(--good-soft); border-left-color: var(--good); }
.callout ul { margin: .4rem 0 0; padding-left: 1.2rem; }

.sticky-action {
  position: sticky; bottom: calc(var(--dock) + 10px);
  margin-top: 12px;
}
.sticky-action .btn { box-shadow: 0 6px 20px rgb(0 0 0 / .18); }

/* ---------- workout */
.wbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.elapsed { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }

.pager {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; margin: 0 -2px;
  scrollbar-width: none;
}
.pager::-webkit-scrollbar { display: none; }
.chip-n {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer;
}
.chip-n.partial { border-color: var(--accent); }
.chip-n.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-n.on { outline: 3px solid var(--ink); outline-offset: 2px; }

.ex-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px 16px;
}
.illu {
  margin: -2px -4px 12px; height: 168px; padding: 12px 16px;
  background: var(--fig-bg); border-radius: 12px; overflow: hidden;
}
.illu.big { margin: 0 0 14px; height: 240px; }
.title { margin-top: .3rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: .4rem 0; }
.chip { font-size: .85rem; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.chip.strong { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 700; }
.cue { font-size: .95rem; }

.segmented { display: flex; gap: 6px; margin: .6rem 0; }
.segmented button {
  flex: 1; min-height: 42px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--surface); font-size: .85rem; font-weight: 600; cursor: pointer;
}
.segmented button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.howto { margin: .6rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.howto summary {
  cursor: pointer; padding: 12px 0; font-weight: 650; color: var(--accent);
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: "+"; font-size: 1.3rem; line-height: 1; }
.howto[open] summary::after { content: "−"; }
.howto[open] { padding-bottom: 8px; }
.howto ul, .howto ol { margin: 0; padding-left: 1.25rem; }
.howto li { margin: .25rem 0; }
.howto.open { border: 0; }
.howto.open h4:first-of-type { margin-top: .6rem; }
ul.warn li::marker { color: var(--danger); }
.muscles { display: flex; flex-wrap: wrap; gap: 6px; margin: .4rem 0 0; }
.tag { font-size: .78rem; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }

.last { display: flex; flex-direction: column; gap: 2px; margin: .8rem 0 .4rem; font-size: .9rem; }
.last b { font-variant-numeric: tabular-nums; font-size: 1rem; }
.hint {
  background: var(--good-soft); color: var(--good); font-weight: 600; font-size: .9rem;
  padding: 10px 12px; border-radius: 10px;
}

.sets { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.set { display: grid; align-items: center; gap: 8px; }
.set.f2 { grid-template-columns: 30px 1fr 1fr 52px; }
.set.f1 { grid-template-columns: 30px 1fr 52px; }
.set.head { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.set.head span:not(:first-child) { text-align: center; }
.set-n { font-weight: 700; color: var(--muted); text-align: center; }
.set input {
  width: 100%; min-width: 0; height: 52px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink);
  font: 600 1.3rem/1 system-ui, sans-serif; text-align: center; font-variant-numeric: tabular-nums;
}
.set input::placeholder { color: var(--muted); opacity: .55; font-weight: 500; }
.set input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.set input.bad { border-color: var(--danger); }
.check {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
}
.set.done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.set.done input { background: var(--accent-soft); border-color: transparent; }
.set.done .set-n { color: var(--accent); }
.set-tools { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.set-tools .muted { margin-left: auto; }

/* ---------- exercise drawings (figures.js): colours follow the theme */
.thumb > .fig { width: 100%; height: 100%; }
.fig { display: block; width: 100%; height: 100%; }
.fig path, .fig circle { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fig .fl { stroke: var(--line); stroke-width: 4; }
.fig .bd { stroke: var(--ink); stroke-width: 7; }
.fig .hd { stroke: var(--ink); stroke-width: 5; fill: var(--fig-bg); }
.fig .eq { stroke: var(--muted); stroke-width: 4; opacity: .55; }
.fig .pad { stroke: var(--muted); stroke-width: 9; opacity: .4; }
.fig .rail { stroke: var(--muted); stroke-width: 6; opacity: .55; }
.fig .wall { stroke: var(--muted); stroke-width: 5; opacity: .35; }
.fig .mat { stroke: var(--accent); stroke-width: 5; opacity: .3; }
.fig .box { stroke: var(--muted); stroke-width: 3; fill: var(--fig-bg); opacity: .7; }
.fig .slab { stroke: none; fill: var(--muted); opacity: .16; }
.fig .wt { stroke: var(--accent); stroke-width: 4; }
.fig .wp { stroke: var(--accent); stroke-width: 7; }
.fig .wd, .fig .gp { fill: var(--accent); }
.fig .wh { fill: var(--fig-bg); }
.fig .ww { stroke: var(--accent); stroke-width: 4; }
.fig .cb { stroke: var(--accent); stroke-width: 2; opacity: .7; }
.fig .cb2 { stroke: var(--accent); stroke-width: 3; }
.fig .far { opacity: .32; }
/* Thumbnails are drawn at about a third of the size: thicker lines keep the figure readable. */
.thumb .fig .bd { stroke-width: 10; }
.thumb .fig .hd { stroke-width: 7; }
.thumb .fig .eq, .thumb .fig .fl { stroke-width: 6; }

.wnav { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 14px; }

/* ---------- summary, history, progress */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-bottom: 14px; }
.stats > div {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 2px;
}
.stats b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.stats span { font-size: .78rem; color: var(--muted); }
.badge { font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); vertical-align: 2px; margin-left: 4px; }
.badge.live { background: var(--accent); color: var(--accent-ink); }
.note { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; font-weight: 600; font-size: .9rem; }
.note textarea {
  font: inherit; font-size: 1rem; font-weight: 400; padding: 10px 12px; border-radius: 12px; resize: vertical;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.prog-row { gap: 10px; }
.spark { color: var(--accent); flex: none; }
.delta { font-size: .78rem; font-weight: 700; flex: none; }
.delta.up { color: var(--good); }
.delta.down { color: var(--danger); }

.chart { width: 100%; height: auto; margin: 6px 0 4px; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dots circle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.hist { list-style: none; padding: 0; margin: 8px 0; }
.hist li { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 10px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.hist li b { flex-basis: 100%; font-weight: 600; }

.settings { display: flex; flex-direction: column; gap: 4px; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

/* ---------- plan editor and forms */
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-row .section { margin-bottom: .6rem; }
.section-row .lead { margin: .25rem 0; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label, .form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; font-weight: 650; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form input, .form select, .form textarea, .form-grid input, .form-grid select, .search {
  font: inherit; font-size: 1rem; font-weight: 400; color: var(--ink);
  min-height: 46px; padding: 8px 12px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--surface); width: 100%; min-width: 0;
}
.form textarea { resize: vertical; min-height: 64px; }
.form input:focus, .form select:focus, .form textarea:focus, .form-grid input:focus, .search:focus { outline: none; border-color: var(--accent); }
input.bad { border-color: var(--danger) !important; }
.edit-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.edit-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 4px 12px; }
.edit-head { display: flex; align-items: center; gap: 8px; }
.edit-head .num { width: 22px; flex: none; }
.icon-sq {
  flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; padding: 0;
}
.icon-sq:disabled { opacity: .3; }
.icon-sq.armed { width: auto; padding: 0 10px; font-size: .8rem; font-weight: 700; }
.edit-targets summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .85rem; padding: 8px 0 8px 30px; }
.edit-targets[open] { padding-bottom: 10px; }
.edit-targets .form-grid { padding-left: 30px; }
.search { margin-bottom: 4px; }
.pick-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 14px; min-height: 64px; border: 0; background: none; cursor: pointer;
}
.pick-row + .pick-row { border-top: 1px solid var(--line); }
.pick-row:active { background: var(--surface-2); }
.pick-row .thumb { width: 64px; height: 52px; }
.pick-row > svg { color: var(--accent); flex: none; }
.pick-row[hidden], .pick-group[hidden] { display: none; }
a.pick-row { color: var(--ink); text-decoration: none; }
a.pick-row > svg:last-child { color: var(--muted); }
.pick-row .in-plan { font-size: .75rem; font-weight: 700; color: var(--accent); }

/* Exercise library: the search and the group chips stay under the top bar. */
.lib-tools {
  position: sticky; top: var(--top-h); z-index: 5;
  margin: -8px -16px 0; padding: 8px 16px 6px; background: var(--bg);
}
.lib-tools .search { margin: 0; }
.group-chips {
  display: flex; gap: 6px; overflow-x: auto; margin: 8px -16px 0; padding: 2px 16px 4px;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.group-chips::-webkit-scrollbar { display: none; }
.group-chips button {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .85rem; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.group-chips button span { font-size: .75rem; color: var(--muted); font-weight: 700; }
.group-chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.group-chips button[aria-pressed="true"] span { color: inherit; opacity: .8; }
.lib-tools + .pick-group .section { margin-top: .9rem; }
.disclaimer { margin: 1.2rem 2px .4rem; }

/* ---------- sign-in gate and people */
body.gated .tabs, body.gated #sync, body.gated #rest { display: none !important; }
body.gated { padding-bottom: 24px; }
.gate-card {
  max-width: 420px; margin: 8vh auto 0; padding: 28px 22px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.gate-card img { border-radius: 16px; }
.gate-card h2 { font-size: 1.6rem; margin-top: 10px; }
.gate-card .btn.big { align-self: stretch; }
.gate-card .callout { text-align: left; align-self: stretch; }
.gate-card .legal { margin-top: 14px; }

/* ---------- plain pages (privacy policy) */
body.doc { padding-bottom: 32px; }
body.doc h3 { margin: 1.4rem 0 .4rem; font-size: 1.05rem; }
body.doc ul { padding-left: 1.2rem; margin: .4rem 0; }
body.doc li { margin: .35rem 0; }
body.doc main a:not(.btn) { color: var(--accent); }
.person { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: wrap; }
.person + .person { border-top: 1px solid var(--line); }
.person-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge.pending { background: var(--accent-soft); color: var(--accent); }
.badge.approved { background: var(--good-soft); color: var(--good); }
.badge.blocked { background: var(--surface-2); color: var(--danger); }
.tabs a { position: relative; }
.tabs a.dot::after {
  content: ""; position: absolute; top: 5px; left: calc(50% + 8px);
  width: 9px; height: 9px; border-radius: 50%; background: var(--danger);
}

/* ---------- profile: weekly goal, achievements, theme */
progress {
  -webkit-appearance: none; appearance: none; display: block;
  width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--line);
}
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

.profile-card, .goal-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
}
.profile-card { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.avatar {
  flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.25rem; letter-spacing: .02em;
}
.pname { font-size: 1.15rem; }

.goal-top { display: flex; align-items: center; gap: 14px; }
.ring { flex: none; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 7; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; }
.ring.met .ring-fg { stroke: var(--good); }
.ring text { fill: var(--ink); font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.streak { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: .85rem; font-weight: 650; color: var(--muted); }
.streak.on { color: var(--accent); }
.weeks { display: block; width: 100%; height: auto; margin-top: 14px; }
.weeks .goal { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 4 4; }
.weeks rect { fill: var(--line); }
.weeks .part rect { fill: var(--accent); opacity: .5; }
.weeks .met rect { fill: var(--good); opacity: 1; }
.weeks text { fill: var(--muted); font-size: 11px; }
.weeks .now text { fill: var(--ink); font-weight: 700; }
.weeks text.extra { fill: var(--good); font-weight: 700; }
.goal-edit { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.goal-edit .icon-sq { font-size: 1.3rem; font-weight: 700; }
.goal-n { min-width: 28px; text-align: center; font-size: 1.3rem; font-variant-numeric: tabular-nums; }

.goal-line {
  display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; padding: 10px 14px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.goal-line:active { background: var(--surface-2); }
.goal-line > svg:last-child { flex: none; color: var(--muted); }
.goal-line .muted svg { vertical-align: -4px; color: var(--accent); }
.goal-line .ring text { font-size: 19px; }

.groups {
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.grp { display: grid; grid-template-columns: 8.6em 1fr 4.4em; align-items: center; gap: 10px; font-size: .9rem; }
.grp-n { text-align: right; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.grp-n.ok { color: var(--good); font-weight: 700; }

.medal {
  flex: none; width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid currentColor;
}
.medal.sm { width: 36px; height: 36px; border-width: 1.5px; }
.medal.t0 { color: var(--muted); background: var(--surface-2); border: 1.5px dashed var(--line); }
.medal.t1 { color: var(--t1-fg); background: var(--t1-bg); }
.medal.t2 { color: var(--t2-fg); background: var(--t2-bg); }
.medal.t3 { color: var(--t3-fg); background: var(--t3-bg); }
.medal.t4 { color: var(--t4-fg); background: var(--t4-bg); }
.medal.t5 { color: var(--t5-fg); background: var(--t5-bg); }
.medal.tgoal { color: var(--good); background: var(--good-soft); }

.ach-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ach {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.ach b { margin-top: 6px; font-size: .95rem; line-height: 1.25; }
.ach .tier { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.ach.locked .tier { color: var(--muted); }
.ach progress { margin: 5px 0 2px; }
.ach .num-line { font-weight: 650; font-variant-numeric: tabular-nums; }
.recent {
  list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.recent li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.recent li + li { border-top: 1px solid var(--line); }

.wins ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.wins li { display: flex; align-items: center; gap: 12px; }
.wins li > span:last-child { display: flex; flex-direction: column; }
.wins .link { margin-top: 6px; }

.swatches { display: flex; flex-wrap: wrap; gap: 14px; margin: 14px 0 6px; padding-left: 4px; }
.swatch {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
}
.swatch svg { opacity: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.swatch[aria-pressed="true"] svg { opacity: 1; }

/* ---------- rest timer */
.rest {
  /* A floating card just above the tab bar, with the same side margins. */
  position: fixed; z-index: 30;
  left: max(12px, calc((100% - 520px) / 2)); right: max(12px, calc((100% - 520px) / 2));
  bottom: calc(var(--dock) + 10px);
  background: var(--head); color: var(--head-ink);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 10px 28px rgb(0 0 0 / .28);
}
.rest-track { height: 4px; background: rgb(255 255 255 / .15); }
.rest-fill { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform .25s linear; }
.rest-row { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; }
.rest-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rest-time { font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rest-label { font-size: .78rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rest button {
  min-width: 52px; min-height: 44px; border-radius: 10px; border: 0;
  background: rgb(255 255 255 / .12); color: inherit; font-weight: 700; cursor: pointer;
}
.rest.over { background: var(--accent); color: var(--accent-ink); }
.rest.over button { background: rgb(0 0 0 / .15); }

/* ---------- tabs: a floating capsule with round ends, like the iPhone apps */
.tabs {
  position: fixed; z-index: 40;
  left: max(12px, calc((100% - 520px) / 2)); right: max(12px, calc((100% - 520px) / 2));
  bottom: var(--dock-bottom);
  height: var(--tabs-h);
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 6px;
  border-radius: calc(var(--tabs-h) / 2);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px var(--dock-shadow), 0 2px 6px var(--dock-shadow);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: calc((var(--tabs-h) - 12px) / 2);
  text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 600;
  transition: background-color .2s ease, color .2s ease, transform .1s ease;
}
.tabs a.on { color: var(--accent); background: var(--accent-soft); }
.tabs a:active { transform: scale(.95); }

/* ---------- toast and update banner */
.toast {
  position: fixed; left: 50%; z-index: 50;
  bottom: calc(var(--dock) + 16px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: .9rem; max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.resting .toast { bottom: calc(var(--dock) + 108px); }
.update {
  position: sticky; top: var(--top-h); z-index: 19;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px 16px; background: var(--accent); color: var(--accent-ink); font-size: .9rem;
}
.update[hidden] { display: none; }
.update button { border: 0; border-radius: 8px; padding: 6px 12px; font-weight: 700; background: rgb(0 0 0 / .15); color: inherit; }

[hidden] { display: none !important; }

@media (min-width: 700px) {
  .thumb { width: 120px; height: 96px; }
  .illu { height: 220px; }
}
