/* ============================================================
   FORGE - dark industrial, built for a phone in a home gym.

   Accessibility is the driving constraint here, not decoration.
   Mat is legally blind, so: large base type, heavy weights, high
   contrast against near-black, generous tap targets (minimum
   48px), and no information carried by colour alone. Every colour
   lives in this block so a palette change is one edit.
   ============================================================ */
:root {
  --coal:        #0c0b0a;
  --iron:        #171614;
  --iron-2:      #201e1b;
  --iron-3:      #2c2926;
  --edge:        #6a635b;   /* 3.3:1 on coal: input and card edges meet WCAG 1.4.11 */
  --ash:         #b9b3ab;
  --bone:        #f2ede6;
  --ember:       #ff7a1a;
  --ember-dim:   #b8531000;
  --ember-soft:  rgba(255, 122, 26, 0.14);
  --forged:      #ffb347;
  --on-ember:    #1a0d02;   /* text on the accent colour */
  --cool:        #6fa8dc;
  --good:        #5fd08a;
  --bad:         #ff6b5e;

  --tap: 48px;
  --radius: 10px;
  --pad: 14px;

  --font: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Bebas Neue", "Haettenschweiler", "Arial Narrow", var(--font);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--coal);
  color: var(--bone);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body { padding-bottom: 84px; }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: 0.02em; margin: 0; font-weight: 700; }
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }

a { color: var(--ember); }

/* ---------- app bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px var(--pad);
  background: linear-gradient(180deg, var(--iron) 0%, rgba(23,22,20,0.96) 100%);
  border-bottom: 2px solid var(--edge);
}
.bar h1 { flex: 1; font-size: 26px; }
.brand { font-family: var(--font-display); font-size: 26px; letter-spacing: 0.06em; }
/* The O is a black disc with the flame on it (Mat, 2026-10-03): the disc
   is the letter's size, so the wordmark reads as one word, and it backs
   the flame on any theme or colour. */
.brand { display: inline-block; line-height: 1; white-space: nowrap; }
/* Bottom on the baseline, height = the letters' cap height (app.js
   measures the real font on the device and sets it in px; 0.72em is
   the fallback). Side margin small so the gap matches the letters. */
.brand .o { width: 0.72em; height: 0.72em; vertical-align: baseline; margin: 0 0.01em 0 -0.02em; }

/* ---------- layout ---------- */
.wrap { padding: var(--pad); max-width: 760px; margin: 0 auto; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap-row { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ash); }
.small { font-size: 15px; }
.tabular { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- cards ---------- */
.card {
  background: var(--iron);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: var(--pad);
}
.card + .card { margin-top: 12px; }
.card-tap { width: 100%; text-align: left; cursor: pointer; }
.card-tap:active { background: var(--iron-2); }

/* ---------- buttons ---------- */
button, .btn {
  font: inherit; font-weight: 600;
  min-height: var(--tap);
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--edge);
  background: var(--iron-2);
  color: var(--bone);
  cursor: pointer;
}
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--forged); outline-offset: 2px;
}
.btn-primary {
  background: var(--ember); border-color: var(--ember); color: var(--on-ember); font-weight: 800;
}
.btn-danger { color: var(--bad); border-color: #5a2a26; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-lg { min-height: 58px; font-size: 20px; }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 16px; }

/* ---------- inputs ---------- */
input, select, textarea {
  font: inherit;
  min-height: var(--tap);
  padding: 8px 10px;
  background: var(--coal);
  color: var(--bone);
  border: 1px solid var(--edge);
  border-radius: 8px;
  width: 100%;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
label { display: block; font-size: 15px; color: var(--ash); margin-bottom: 4px; }
.field + .field { margin-top: 12px; }

/* ---------- set grid: the core of the logger ---------- */
.exercise { margin-top: 16px; }
.exercise-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.exercise-head h3 { flex: 1; color: var(--forged); }

.sets { width: 100%; border-collapse: collapse; }
.sets th {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ash); text-align: left; padding: 4px 6px; font-weight: 700;
}
.sets td { padding: 4px 6px; vertical-align: middle; }
.sets tr.done td { background: var(--ember-soft); }
.sets .c-set { width: 52px; }
.sets .c-prev { width: 92px; }
.sets .c-num { width: 84px; }
.sets .c-do { width: 56px; }
.sets input { min-height: 44px; text-align: center; padding: 6px 4px; }

.setbadge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; border-radius: 8px;
  background: var(--iron-3); font-weight: 700; font-size: 16px;
}
.setbadge.warmup { background: transparent; border: 1px dashed var(--edge); color: var(--cool); }

.check {
  width: 46px; height: 44px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1;
}
.check.on { background: var(--good); border-color: var(--good); color: #06210f; }

/* ---------- rest timer ---------- */
.rest {
  position: fixed; left: 0; right: 0; bottom: 68px; z-index: 40;
  background: var(--iron-2); border-top: 2px solid var(--ember);
  padding: 10px var(--pad);
  display: flex; align-items: center; gap: 12px;
}
.rest .t { font-family: var(--font-display); font-size: 30px; color: var(--ember); }
.rest progress { width: 100%; height: 8px; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--iron); border-top: 2px solid var(--edge);
}
.nav button {
  border: 0; border-radius: 0; background: transparent;
  min-height: 66px; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ash);
}
.nav button .ico { font-size: 22px; line-height: 1; }
.nav button[aria-current="page"] { color: var(--ember); box-shadow: inset 0 3px 0 var(--ember); }

/* ---------- misc ---------- */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--iron-3); font-size: 14px; font-weight: 700; color: var(--ash);
}
.pill.live { background: var(--ember); color: var(--on-ember); }
.empty { text-align: center; padding: 40px 20px; color: var(--ash); }
.empty .big { font-size: 46px; display: block; margin-bottom: 8px; }
.divider { height: 1px; background: var(--edge); margin: 16px 0; border: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--edge); }
.list-item:last-child { border-bottom: 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 90px; z-index: 80;
  background: var(--bone); color: var(--coal);
  padding: 12px 18px; border-radius: var(--radius);
  font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

dialog {
  border: 1px solid var(--edge); border-radius: var(--radius);
  background: var(--iron); color: var(--bone);
  width: min(560px, 94vw); padding: var(--pad);
}
dialog::backdrop { background: rgba(0,0,0,0.72); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- v0.10: charts, dashboard, measure, full-screen dialogs ---------- */
.chart-wrap { margin-top: 10px; }
.chart { width: 100%; height: auto; display: block; }
.chart .c-frame { fill: none; stroke: var(--edge); stroke-width: 1; }
.chart .c-grid { stroke: var(--iron-3); stroke-width: 1; }
.chart .c-grid.dashed { stroke-dasharray: 3 4; }
.chart .c-lab { fill: var(--ash); font-size: 12px; font-family: var(--font); }
.chart .c-goal { stroke: var(--forged); stroke-width: 1.5; }
.chart .c-goal-lab { fill: var(--forged); font-weight: 700; }
.chart .c-bar { fill: var(--ember-soft); stroke: var(--ember); stroke-width: 1; }
.chart .c-bar.on { fill: var(--ember); }
.chart .c-line { fill: none; stroke: var(--ember); stroke-width: 1.6; stroke-linejoin: round; }
/* Small hollow dots like Strong's (Mat 2026-10-03: big dots crowd the line). */
.chart .c-dot { fill: var(--coal); stroke: var(--ember); stroke-width: 1.3; }
.chart.tappable { cursor: pointer; touch-action: pan-y; }
/* Tap read-out, as Strong: full-height line, grey rounded label,
   value bold on top, date (YYYY-MM-DD) under it. */
.chart .c-cursor { stroke: var(--ember); stroke-width: 1; }
.chart .c-tip-box { fill: var(--iron-3); opacity: .95; }
.chart .c-tip { fill: var(--ash); font-size: 12px; font-family: var(--font); }
.chart .c-tip.b { fill: var(--bone); font-size: 14px; font-weight: 700; }

/* PRs, as Strong: outlined chips under the set that earned them. */
.pr-chip { display: inline-block; padding: 3px 12px; border: 1.5px solid var(--good); border-radius: 999px;
  color: var(--good); font-weight: 700; font-size: .9rem; }
/* Strong's finish screen. */
.done-screen { text-align: center; }
.done-screen .card { text-align: left; }
.done-stars { font-size: 2.6rem; color: var(--forged); letter-spacing: .3em; margin-top: 18px; }
.done-title { margin: 10px 0 4px; }
.done-sub { color: var(--ash); font-size: 1.15rem; }

/* Strong's small "•••" menu, opened beside the button. */
dialog.pop { margin: 0; position: fixed; width: auto; min-width: 210px; max-width: 80vw; padding: 6px 0;
  background: var(--iron-3); border: 0; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.6); }
dialog.pop::backdrop { background: transparent; }
.pop-item { display: block; width: 100%; min-height: var(--tap); padding: 12px 20px; background: none; border: 0;
  border-radius: 0; color: var(--bone); font: inherit; font-size: 1.05rem; text-align: left; }
.pop-item.minor { color: var(--ash); font-size: .95rem; }
.pop-sep { height: 1px; background: var(--edge); margin: 4px 0; }

/* Strong's "Add widget" bottom sheet. */
dialog.sheet { margin: auto 0 0 0; width: 100vw; max-width: 100vw; border: 0; border-radius: 14px 14px 0 0;
  padding: 18px 0 10px; max-height: 85dvh; overflow-y: auto; }
.sheet-title { font-size: 1.15rem; padding: 0 18px 10px; }
.sheet-item { display: block; width: 100%; min-height: 64px; padding: 10px 18px; background: none; border: 0;
  border-radius: 0; color: var(--bone); font: inherit; text-align: left; }
.sheet-item b { display: block; font-size: 1.1rem; }
.sheet-item span { display: block; color: var(--ash); font-size: .95rem; margin-top: 2px; }
.sheet-item[disabled] { opacity: .45; }
.chart .c-trend { stroke: var(--forged); stroke-width: 1.6; opacity: .85; }
.caps { text-transform: uppercase; letter-spacing: .08em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.list-btn { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--edge); border-radius: 0; color: inherit; text-align: left; min-height: var(--tap); font: inherit; }
dialog.full { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; overflow-y: auto; }
input[type=range] { accent-color: var(--ember); }
.set-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 0; border-bottom: 1px solid var(--edge); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; border-radius: 0; color: inherit; font: inherit; text-align: left; }
.set-row .val { color: var(--ash); text-align: right; }
.set-head { font-family: var(--font-display); font-size: 18px; letter-spacing: .04em; color: var(--forged); margin: 22px 0 4px; }
.set-hint { color: var(--ash); font-size: 14px; }

/* ---------- themes (Settings > Theme) ---------- */
html[data-theme="oled"] { --coal: #000; --iron: #0a0a0a; --iron-2: #141414; --iron-3: #1f1f1f; }
html[data-theme="light"] {
  /* Darker accents so text passes WCAG AA on light backgrounds
     (checked by scripts/audit-contrast.js). */
  --coal: #f6f3ef; --iron: #ffffff; --iron-2: #efe9e2; --iron-3: #e2dbd2; --edge: #8c8279;
  --ash: #5c554d; --bone: #1b1916;
  --ember: #b34700; --on-ember: #ffffff; --ember-soft: rgba(179, 71, 0, 0.14);
  --forged: #8a4b00; --cool: #1f5f99; --bad: #b3261e;
}

/* ---------- v0.11: set type badge button, RPE badge, supersets ---------- */
button.setbadge { border: 0; cursor: pointer; font: inherit; }
td.has-rpe { position: relative; }
.rpe { position: absolute; top: -8px; right: -4px; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 11px;
  font-size: 12px; font-weight: 700; line-height: 20px; background: var(--iron-3); color: var(--ash); border: 1px solid var(--edge); }
.rpe.on { background: var(--iron); color: var(--bone); border-color: var(--forged); }
.card.superset { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.sets td.has-rpe { padding-top: 12px; }
.sets .rpe { top: -2px; right: 2px; height: 20px; line-height: 18px; min-width: 28px; font-size: 11px; }
@media (max-width: 400px) {
  .sets .c-prev { width: 74px; }
  .sets td { padding: 4px 3px; }
  .sets input { font-size: 17px; }
}
.sets .rpe { min-height: 0; min-width: 30px; height: 20px; padding: 0 6px; top: -4px; right: 4px; box-shadow: 0 0 0 3px var(--iron); }

/* ---------- v0.12: history calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.cal-h { text-align: center; font-size: 13px; color: var(--ash); font-weight: 700; }
.cal-d { aspect-ratio: 1; min-height: 44px; padding: 0; border-radius: 10px; border: 1px solid var(--edge);
  background: var(--iron); color: var(--ash); font: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cal-d small { font-size: 11px; line-height: 1; }
.cal-d.on { background: var(--ember); color: var(--on-ember); border-color: var(--ember); font-weight: 800; }
.cal-d.today { outline: 2px solid var(--forged); outline-offset: 1px; }
.cal-d:disabled { opacity: .55; }
/* WCAG 2.5.8: small controls get at least a 24px hit area. */
.sets .rpe { height: 24px; line-height: 22px; top: -6px; }

/* ---------- v0.14: exercise videos ---------- */
.video-thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border-radius: var(--radius);
  border: 1px solid var(--edge); background: #000 center / cover no-repeat; cursor: pointer; }
.video-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 68px; height: 48px; border-radius: 12px;
  background: rgba(0,0,0,.72); color: #fff; font-size: 24px; line-height: 48px; text-align: center; }
.video-frame { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius); background: #000; }

/* ============================================================
   v0.19 (2026-10-07): the new logger. Fewer buttons, bigger areas:
   one open set as a big card, every other set one tappable row,
   rest lines between sets, a dock above the tab bar.
   ============================================================ */
.bare { background: none; border: 0; padding: 0; min-height: 0; border-radius: 0; color: inherit; font: inherit; font-weight: inherit; }
.bare:active { transform: none; }

.lg-head { display: grid; gap: 4px; margin-bottom: 4px; }
.lg-name { font-family: var(--font-display); font-size: 30px; letter-spacing: .03em; background: transparent; border: 0; border-bottom: 1px dashed var(--iron-3); border-radius: 0; padding: 4px 0; min-height: 0; }
.lg-clock { font-family: var(--font-display); font-size: 22px; color: var(--forged); letter-spacing: .04em; }

.xb { position: relative; margin-top: 14px; background: var(--iron); border: 1px solid var(--iron-3); border-radius: 14px; overflow: hidden; }
.xb.ss { padding-left: 6px; }
.xb.ss::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--ssc); }
.xb.linking { outline: 3px dashed var(--forged); outline-offset: -3px; }
.xb-head { display: grid; grid-template-columns: 1fr 56px; align-items: center; padding: 4px 4px 4px 14px; }
.xb-name { display: flex; flex-direction: column; justify-content: center; text-align: left; min-height: 58px; }
.xb-name b { font-size: 19px; line-height: 1.15; color: var(--forged); }
.xb-name small { display: flex; align-items: center; gap: 6px; color: var(--ash); font-size: 14px; margin-top: 2px; }
.ssdot { width: 11px; height: 11px; border-radius: 50%; background: var(--ssc); display: inline-block; }
.xb-more { height: 56px; font-size: 20px; letter-spacing: 2px; color: var(--ash); }
.xb-add { display: block; width: 100%; height: 50px; border-top: 1px solid var(--iron-2); color: var(--ash); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 15px; }

.sr { display: grid; grid-template-columns: 60px 1fr auto; align-items: center; min-height: 60px; border-top: 1px solid var(--iron-2); padding-right: 14px; cursor: pointer; position: relative; }
.sr:active { background: var(--iron-2); }
.sr-main { display: flex; flex-direction: column; min-width: 0; }
.sr-val { font-family: var(--font-display); font-size: 26px; letter-spacing: .03em; line-height: 1.05; color: var(--ash); }
.sr-prev { font-size: 14px; color: var(--ash); }
.sr-rpe { font-weight: 700; font-size: 15px; color: var(--ash); }
.sr.done { background: linear-gradient(90deg, var(--ember-soft), transparent 75%); }
.sr.done .sr-val { color: var(--bone); }
.sr.done::after { content: ""; position: absolute; right: 14px; top: 50%; width: 9px; height: 17px; margin-top: -12px; border: solid var(--ember); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.sr.done .sr-rpe { margin-right: 26px; }
.sr.just { animation: srflash .8s ease-out; }
@keyframes srflash { from { background: rgba(255, 179, 71, .5); } }

.chipb { width: 60px; height: 60px; display: grid; place-items: center; font-family: var(--font-display); font-size: 25px; color: var(--ash); }
.t-warmup { color: var(--forged) !important; }
.t-myo, .t-myomatch { color: #c38bff !important; }
.t-failure { color: var(--bad) !important; }
.t-dropset { color: var(--cool) !important; }

.fc { border-top: 1px solid var(--iron-2); background: var(--iron-2); padding: 10px 12px 12px; display: grid; gap: 10px; box-shadow: inset 0 0 0 2px var(--ember); }
.fc-head { display: flex; align-items: center; gap: 10px; }
.fc-head .chipb { width: 52px; height: 52px; border-radius: 12px; background: var(--iron-3); }
.fc-head b { display: block; font-size: 16px; letter-spacing: .06em; text-transform: uppercase; }
.fc-head small { display: block; color: var(--ash); font-size: 15px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiles.one { grid-template-columns: 1fr; }
.tile { display: grid; grid-template-columns: 50px 1fr 50px; height: 88px; background: var(--coal); border: 1px solid var(--iron-3); border-radius: 12px; overflow: hidden; }
.tile-step { font-family: var(--font-display); font-size: 34px; color: var(--ash); }
.tile-step:active { background: var(--iron-3); color: var(--bone); }
.tile-val { display: flex; flex-direction: column; align-items: center; justify-content: center; border-inline: 1px solid var(--iron-2); min-width: 0; }
.tile-val b { font-family: var(--font-display); font-size: 44px; line-height: .95; letter-spacing: .02em; }
.tile-val b.ghost { color: var(--ash); opacity: .75; }
.tile-val span { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ash); }
@media (max-width: 380px) { .tile { grid-template-columns: 42px 1fr 42px; } .tile-val b { font-size: 38px; } }
.rpes { display: grid; grid-template-columns: auto repeat(7, 1fr); gap: 5px; align-items: center; }
.rpes-l { font-size: 13px; font-weight: 700; letter-spacing: .1em; color: var(--ash); padding-right: 4px; }
.rpes button { height: 46px; border-radius: 10px; background: var(--coal); border: 1px solid var(--iron-3); font-family: var(--font-display); font-size: 23px; color: var(--ash); }
.rpes button[aria-pressed="true"] { background: var(--forged); border-color: var(--forged); color: var(--on-ember); }

.slab { display: block; width: 100%; min-height: 62px; border-radius: 14px; background: var(--ember); color: var(--on-ember); font-family: var(--font-display); font-size: 28px; letter-spacing: .06em; position: relative; overflow: hidden; text-align: center; }
.slab:active { transform: scale(.985); }
.slab.ghost { background: var(--iron-2); color: var(--bone); border: 1px solid var(--iron-3); font-size: 22px; }
.slab .heat { position: absolute; inset: 0; background: linear-gradient(100deg, transparent 0 30%, rgba(255,255,255,.55) 45%, transparent 60%); transform: translateX(-110%); pointer-events: none; }
.slab.hit .heat { animation: heat .38s ease-out forwards; }
@keyframes heat { to { transform: translateX(110%); } }

.rest-pill { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 14px 0 60px; border-top: 1px solid var(--iron-2); color: var(--ash); font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.rest-pill::before, .rest-pill::after { content: ""; flex: 1; height: 2px; background: repeating-linear-gradient(90deg, var(--iron-3) 0 6px, transparent 6px 10px); }
.rest-pill.on { color: var(--forged); }

.spark { position: fixed; z-index: 90; width: 7px; height: 7px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--forged); box-shadow: 0 0 8px var(--ember); pointer-events: none; animation: spark .65s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.toast.record { background: var(--forged); color: var(--on-ember); text-align: center; bottom: auto; top: 90px; }
.toast.record b { font-family: var(--font-display); font-size: 26px; letter-spacing: .04em; display: block; }

/* the dock: rest countdown or what is up next, above the tab bar */
body.has-dock { padding-bottom: 170px; }
#rest-host .dock { position: fixed; left: 0; right: 0; bottom: 68px; z-index: 40; display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; min-height: 86px; padding: 10px 14px; background: var(--iron); border-top: 2px solid var(--ember); }
.dock .ring { width: 64px; height: 64px; }
.dock .ring-bg { fill: none; stroke: var(--iron-3); stroke-width: 6; }
.dock .ring-arc { fill: none; stroke: var(--ember); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.dock-t { display: flex; flex-direction: column; min-width: 0; text-align: left; }
.dock-t b { font-family: var(--font-display); font-size: 36px; line-height: 1; letter-spacing: .03em; }
.dock-t span { color: var(--ash); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock:not(.resting) .dock-t b { font-size: 26px; }
.dock-acts { display: flex; gap: 6px; }
.dock-acts button, .dock-go { height: 54px; min-width: 54px; padding: 0 10px; border-radius: 12px; background: var(--iron-2); border: 1px solid var(--iron-3); font-family: var(--font-display); font-size: 21px; letter-spacing: .04em; }
.dock-disc { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: #2b2825; border: 2px solid var(--ember); color: var(--ember); font-family: var(--font-display); font-size: 28px; }
.dock.ending .dock-t b { color: var(--forged); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }

/* bottom sheets (v2): set type, rest, keypad, exercise menu */
dialog.sheet.v2 { padding: 8px 16px 18px; }
dialog.sheet.v2 .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--edge); margin: 2px auto 12px; }
.sheet-h { margin: 0 0 10px; font-size: 28px; }
.opt { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; text-align: left; border-bottom: 1px solid var(--iron-2); font-size: 18px; }
.opt small { display: block; color: var(--ash); font-size: 14px; }
.opt.on { color: var(--forged); }
.opt.danger { color: var(--bad); }
.opt-k { width: 40px; font-family: var(--font-display); font-size: 26px; text-align: center; color: var(--ash); }
.kdisp { display: flex; align-items: baseline; justify-content: flex-end; gap: 10px; min-height: 80px; padding: 10px 16px; background: var(--coal); border: 1px solid var(--iron-3); border-radius: 14px; }
.kdisp b { font-family: var(--font-display); font-size: 58px; line-height: 1; }
.kraw, .kunit { color: var(--ash); font-size: 15px; }
.kraw { margin-right: auto; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.keypad button { height: 66px; border-radius: 14px; background: var(--iron-2); border: 1px solid var(--iron-3); font-family: var(--font-display); font-size: 34px; }
.keypad button:active { background: var(--iron-3); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.tile-val b.long { font-size: 30px; }

/* ---------- v0.19: History (this week, cards) and Workout-tab templates ---------- */
.label-caps { font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ash); margin: 4px 0 8px; }
.week { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--iron-3); border: 1px solid var(--iron-3); border-radius: 14px; overflow: hidden; }
.week > div { background: var(--iron); padding: 12px 14px; }
.week .label-caps { margin: 0; }
.week-v { font-family: var(--font-display); font-size: 34px; line-height: 1; margin-top: 6px; letter-spacing: .02em; }
.week-v small { font-family: var(--font); font-size: 14px; font-weight: 700; color: var(--ash); margin-left: 4px; letter-spacing: 0; }
.muscles { display: grid; gap: 8px; margin-top: 10px; padding: 12px 14px; background: var(--iron); border: 1px solid var(--iron-3); border-radius: 14px; }
.muscles .label-caps { margin: 0 0 2px; }
.mrow { display: grid; grid-template-columns: 104px 1fr 28px; align-items: center; gap: 10px; font-size: 16px; }
.mrow > span:last-child { text-align: right; font-weight: 700; }
.mbar { height: 10px; border-radius: 5px; background: var(--iron-3); overflow: hidden; }
.mbar i { display: block; height: 100%; border-radius: 5px; background: var(--ember); }
.hcard { margin-top: 12px; background: var(--iron); border: 1px solid var(--iron-3); border-radius: 14px; padding: 2px 4px 10px 14px; }
.hcard-top { display: grid; grid-template-columns: 1fr 56px; align-items: start; }
.hcard-main { display: flex; flex-direction: column; text-align: left; padding-top: 10px; min-width: 0; }
.hcard-date { font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ash); }
.hcard-name { font-family: var(--font-display); font-size: 27px; line-height: 1.1; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hcard-name .pill { font-family: var(--font); letter-spacing: 0; }
.hstats { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 10px 6px 0; font-weight: 700; font-size: 16px; }
.hlines { display: block; width: 100%; text-align: left; padding-right: 10px; }
.hline { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 6px 0; border-top: 1px solid var(--iron-2); font-size: 16px; }
.edit-field { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 76px; padding: 8px 12px; margin: 0; background: var(--coal); border: 1px solid var(--iron-3); border-radius: 12px; text-align: left; color: var(--ash); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.edit-field input { min-height: 40px; padding: 4px 0; border: 0; background: transparent; font-size: 17px; letter-spacing: 0; text-transform: none; }
.edit-field b { font-family: var(--font-display); font-size: 32px; color: var(--bone); letter-spacing: .02em; }

.tpls { display: grid; gap: 10px; }
.tpl { position: relative; background: var(--iron); border: 1px solid var(--iron-3); border-radius: 14px; overflow: hidden; }
.tpl::after { content: ""; position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%; border: 1px dashed var(--iron-3); pointer-events: none; }
.tpl-top { display: grid; grid-template-columns: 1fr 56px; align-items: start; }
.tpl-head { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px 4px 14px 16px; min-width: 0; }
.tpl-name { font-family: var(--font-display); font-size: 28px; line-height: 1; letter-spacing: .03em; }
.tpl-sum { color: var(--ash); font-size: 16px; line-height: 1.35; }
.tpl-sum b { color: var(--bone); font-weight: 700; }
.tpl-last { color: var(--ash); font-size: 14px; }
.tpl-detail { border-top: 1px solid var(--iron-3); padding: 6px 16px 16px; display: grid; }
.tpl-row { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 10px; min-height: 54px; text-align: left; border-left: 4px solid transparent; padding-left: 8px; margin-left: -12px; }
.tpl-row .n { font-family: var(--font-display); font-size: 25px; color: var(--ember); text-align: right; }
.tpl-row small { display: block; color: var(--ash); font-size: 14px; }

/* ---------- v0.19: drag to reorder, Exercises tab, pickers ---------- */
.sortable > * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.drag-lift { position: relative; z-index: 6; transform: scale(1.02); box-shadow: 0 16px 36px rgba(0,0,0,.6); outline: 2px solid var(--ember); transition: transform .12s; }
.chiprow { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chiprow::-webkit-scrollbar { display: none; }
.chip-btn { flex: none; height: 44px; padding: 0 16px; border-radius: 22px; background: var(--iron); border: 1px solid var(--iron-3); color: var(--ash); font-size: 15px; font-weight: 700; letter-spacing: .04em; }
.chip-btn[aria-pressed="true"] { background: var(--ember); border-color: var(--ember); color: var(--on-ember); }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.field .label-caps { display: block; }
.newx { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; margin-top: 12px; padding: 0 14px; border: 1px dashed var(--edge); border-radius: 14px; font-weight: 700; text-align: left; }
.mono { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: var(--iron-2); border: 1px solid var(--iron-3); font-family: var(--font-display); font-size: 26px; color: var(--forged); }
.newx .mono { border-style: dashed; color: var(--ember); }
.letter { font-family: var(--font-display); font-size: 24px; color: var(--ember); margin: 18px 0 2px; }
.xrow { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 14px; align-items: center; width: 100%; min-height: 66px; text-align: left; border-bottom: 1px solid var(--iron-2); }
.xrow-t { display: flex; flex-direction: column; min-width: 0; }
.xrow-t small { color: var(--ash); font-size: 14px; }
.xrow-n { color: var(--ash); font-weight: 700; padding-right: 6px; }

/* ---------- v0.19: Profile, Settings, exercise page ---------- */
.card { border-radius: 14px; }
.page-head { display: flex; align-items: center; gap: 8px; min-height: 60px; margin-bottom: 6px; }
.page-head h1 { font-size: 36px; letter-spacing: .03em; }
.icon-btn { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 12px; font-size: 34px; line-height: 1; color: var(--ash); }
.icon-btn:active { background: var(--iron-2); }
.sec-head { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.sec-head h2 { font-size: 28px; }
.hero-stat { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--iron); border: 1px solid var(--iron-3); border-radius: 14px; }
.hero-name { display: block; font-size: 21px; }
.widget { margin-top: 12px; padding: 4px 4px 12px 16px; background: var(--iron); border: 1px solid var(--iron-3); border-radius: 14px; }
.widget > .row { align-items: center !important; }
.widget h3 { font-family: var(--font); font-size: 18px; font-weight: 700; letter-spacing: 0; padding-top: 6px; }
.widget .chart-wrap { padding-right: 12px; }
.widgets .widget:first-child { margin-top: 0; }

.set-head { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ember); margin: 24px 0 8px; font-family: var(--font); }
.set-group { background: var(--iron); border: 1px solid var(--iron-3); border-radius: 14px; overflow: hidden; }
.set-group .set-row { padding: 10px 16px; min-height: 60px; border-bottom: 1px solid var(--iron-2); }
.set-group .set-row:last-child { border-bottom: 0; }
.set-row:active { background: var(--iron-2); }
.set-row .val { max-width: 45%; }
.chev { color: var(--ash); font-size: 26px; line-height: 1; margin-left: 4px; }
.sw { flex: none; position: relative; width: 54px; height: 32px; border-radius: 16px; background: var(--iron-3); border: 1px solid var(--edge); transition: background .15s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--ash); transition: transform .15s; }
[aria-checked="true"] > .sw { background: var(--ember); border-color: var(--ember); }
[aria-checked="true"] > .sw::after { transform: translateX(22px); background: var(--on-ember); }

.xpage-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; margin: calc(var(--pad) * -1) calc(var(--pad) * -1) 0; padding: 8px var(--pad) 4px 6px; background: var(--iron); }
.xpage-head h2 { font-size: 26px; line-height: 1.1; }
.tabsx { position: sticky; top: 64px; z-index: 4; display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 calc(var(--pad) * -1) 12px; background: var(--iron); border-bottom: 1px solid var(--iron-3); }
.tabsx button { height: 54px; font-size: 15px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ash); }
.tabsx button[aria-selected="true"] { color: var(--ember); box-shadow: inset 0 -3px 0 var(--ember); }
dialog.pop .pop-item { min-height: 54px; font-size: 17px; }

/* ---------- v0.19 finish: bars, workout mode, sheets everywhere ---------- */
/* Top bar: back arrow when there is one, the flame disc, the screen's title. */
.bar { gap: 8px; min-height: 64px; padding: 6px 10px 6px 14px; background: var(--iron); border-bottom: 1px solid var(--iron-3); }
.bar .logo { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; }
.bar .logo .o { width: 34px; height: 34px; margin: 0; }
#bar-title { font-family: var(--font-display); font-size: 32px; line-height: 1; letter-spacing: .03em; margin: 0; }
.bar-back { width: 44px; height: 48px; font-size: 38px; line-height: 1; color: var(--ash); }
.bar-back[hidden] { display: none; }
.bar .icon-btn { font-size: 26px; }

/* Tab bar: line icons, an orange marker on the current tab. */
.nav { border-top: 1px solid var(--iron-3); padding-bottom: env(safe-area-inset-bottom, 0px); }
.nav button { position: relative; gap: 4px; min-height: 66px; color: var(--ash); }
.nav button .ico { width: 25px; height: 25px; }
.nav button[aria-current="page"] { color: var(--bone); box-shadow: none; }
.nav button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 26%; right: 26%; height: 3px; border-radius: 0 0 3px 3px; background: var(--ember); }

/* During a workout the logger has the whole screen. */
body.in-workout .nav { display: none; }
body.in-workout { padding-bottom: 24px; }
body.in-workout.has-dock { padding-bottom: 120px; }
body.in-workout #rest-host .dock { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
body.in-workout .lg-name { font-size: 28px; }

/* Segmented switch: chart ranges, List / Calendar. */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; margin: 10px 0; background: var(--iron); border: 1px solid var(--iron-3); border-radius: 14px; }
.seg button { height: 46px; border-radius: 10px; font-weight: 700; letter-spacing: .06em; color: var(--ash); }
.seg button[aria-pressed="true"] { background: var(--ember); color: var(--on-ember); }

/* Every remaining pop-up becomes a bottom sheet, like the prototype. */
dialog:not(.full):not(.pop) { margin: auto auto 0; width: min(100vw, 600px); max-width: 100vw; max-height: 88dvh; overflow-y: auto;
  border: 0; border-top: 1px solid var(--iron-3); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); animation: sheetup .22s cubic-bezier(.2,.8,.2,1); }
@keyframes sheetup { from { transform: translateY(40px); opacity: .4; } }
dialog:not(.full):not(.pop) > h2:first-child { font-size: 28px; margin-bottom: 8px; }
dialog .btn-block { min-height: 56px; border-radius: 14px; }
dialog.full { padding-top: 0; }
dialog.full > .row:first-child { position: sticky; top: 0; z-index: 5; background: var(--iron); min-height: 60px; }

/* Buttons and lists in the v0.19 shape. */
button, .btn { border-radius: 12px; }
.btn-lg { min-height: 60px; border-radius: 14px; font-family: var(--font-display); font-size: 24px; letter-spacing: .05em; font-weight: 400; }
.btn-sm { border-radius: 10px; }
.list-item { min-height: 54px; border-bottom-color: var(--iron-2); }
.empty { padding: 36px 16px; }

/* ---------- v0.19: the FORGE wordmark in the top bar (Mat, 2026-10-08) ---------- */
.bar .wordmark { flex: none; height: 24px; width: auto; color: var(--bone); }
#bar-title { font-size: 26px; padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--iron-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 370px) { .bar .wordmark { height: 20px; } #bar-title { font-size: 23px; } }
#bar-title:empty { border-left: 0; padding-left: 0; }

/* ---------- the ChatGPT logo (Mat, 2026-10-08) ---------- */
.bar .wordmark { flex: none; height: 38px; width: auto; color: inherit; margin: -4px 0; }
.bar .wm-light { display: none; }
html[data-theme="light"] .bar .wm-light { display: block; }
html[data-theme="light"] .bar .wm-dark { display: none; }
@media (max-width: 370px) { .bar .wordmark { height: 32px; } }
