html { padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; -webkit-tap-highlight-color: transparent; }

/* Layout: a gym logbook — one card per exercise, each with a row per person (sets + kg) */
:root {
  --bg: #eef0f2;
  --surface: #ffffff;
  --fg: #1c2229;
  --muted: #5d6874;
  --line: #d5dae0;
  --johan: #2a5db0;   /* blue 20 kg plate */
  --emil: #c4352b;    /* red 25 kg plate */
  --done: #2f8a4f;
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #13171b; --surface: #1c2228; --fg: #e6e9ec; --muted: #94a0ab; --line: #2e363e;
  --johan: #6e9de6; --emil: #ec7268; --done: #5cc27f; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #13171b; --surface: #1c2228; --fg: #e6e9ec; --muted: #94a0ab; --line: #2e363e;
  --johan: #6e9de6; --emil: #ec7268; --done: #5cc27f; color-scheme: dark }

body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.45; }
.wrap { max-width: 640px; margin: 0 auto; padding-block: 24px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 20px; }

header h1 { font-family: var(--font-display); font-size: 2.4rem; line-height: 1; margin: 0; text-transform: uppercase; letter-spacing: .01em; text-wrap: balance; }
header p { margin: 6px 0 0; color: var(--muted); }

.progress { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prog { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.prog .name { font-family: var(--font-display); font-size: 1.2rem; text-transform: uppercase; display: flex; justify-content: space-between; align-items: baseline; }
.prog .count { font-family: var(--font-mono); font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; transition: width .25s; }
.johan .bar span { background: var(--johan); } .emil .bar span { background: var(--emil); }
.johan .name { color: var(--johan); } .emil .name { color: var(--emil); }

h2 { font-family: var(--font-display); font-size: .95rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 4px 0 -8px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.ex { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.ex-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.ex-name { font-weight: 600; font-size: 1.02rem; }
.ex-name small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
.rx { font-family: var(--font-mono); font-size: .85rem; color: var(--muted); white-space: nowrap; }
.row { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px; }
.who { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: .95rem; }
.row.johan .who { color: var(--johan); } .row.emil .who { color: var(--emil); }
.sets { display: flex; gap: 6px; flex-wrap: wrap; }
.set { appearance: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: transparent; color: var(--muted);
  font-family: var(--font-mono); font-size: .8rem; cursor: pointer; display: grid; place-items: center; }
.row.johan .set[aria-pressed="true"] { background: var(--johan); border-color: var(--johan); color: var(--surface); }
.row.emil .set[aria-pressed="true"] { background: var(--emil); border-color: var(--emil); color: var(--surface); }
.set:focus-visible, .kg input:focus-visible, button:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.kg { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: .8rem; }
.kg input { width: 56px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg);
  font-family: var(--font-mono); font-size: .9rem; text-align: right; }
.ex.complete { border-color: var(--done); }
.tips { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.tips ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.reset { align-self: flex-start; background: transparent; border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 8px 14px; font: inherit; cursor: pointer; }
.reset.armed { border-color: var(--emil); color: var(--emil); }
.wrap { padding-bottom: 96px; }
.history { display: flex; flex-direction: column; gap: 8px; }
.history .empty { margin: 0; color: var(--muted); }
.week { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.week summary { cursor: pointer; padding: 12px 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; list-style: none; }
.week summary::-webkit-details-marker { display: none; }
.week summary::before { content: "▸"; color: var(--muted); margin-right: 6px; }
.week[open] summary::before { content: "▾"; }
.week-title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; text-transform: uppercase; flex: 1; }
.week-title small { font-family: var(--font-body); font-weight: 400; text-transform: none; color: var(--muted); font-size: .82rem; margin-left: 8px; white-space: nowrap; }
.week-sum { font-family: var(--font-mono); font-size: .82rem; display: flex; gap: 12px; font-variant-numeric: tabular-nums; width: 100%; padding-left: 18px; margin-top: -8px; }
.week-sum .j { color: var(--johan); } .week-sum .e { color: var(--emil); }
.week .tbl { overflow-x: auto; padding: 0 14px 12px; }
.week table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.week th { text-align: left; font-weight: 600; color: var(--muted); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.week th.j { color: var(--johan); } .week th.e { color: var(--emil); }
.week td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: top; }
.week td.num { font-family: var(--font-mono); font-size: .8rem; width: 30%; }
.week td.num .sets-done { display: block; color: var(--muted); }
.week tr:last-child td { border-bottom: 0; }
.up { color: var(--done); font-weight: 600; }
.dim { color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.savebar-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status { color: var(--muted); font-size: .85rem; min-width: 0; }
.status.dirty { color: var(--fg); font-weight: 500; }
.status.err { color: var(--emil); }
.save { appearance: none; border: 0; border-radius: 6px; padding: 10px 22px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--done); color: var(--surface); font-family: var(--font-display); font-size: 1.1rem; letter-spacing: .04em; text-transform: uppercase; }
.save:disabled { opacity: .45; cursor: default; }
.week-del { appearance: none; background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 6px 10px; font: inherit; font-size: .8rem; cursor: pointer; margin: 0 14px 12px; }
.week-del.armed { border-color: var(--emil); color: var(--emil); }
@media (prefers-reduced-motion: reduce) { .bar span { transition: none; } }
.pin { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.pin[hidden] { display: none; }
.pin-box { width: 100%; max-width: 280px; display: flex; flex-direction: column; gap: 10px; }
.pin-box h1 { font-family: var(--font-display); font-size: 2.4rem; line-height: 1; margin: 0 0 8px; text-transform: uppercase; }
.pin-box label { color: var(--muted); font-size: .85rem; }
.pin-box input { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg);
  font-family: var(--font-mono); font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
.pin-msg { margin: 0; min-height: 1.4em; color: var(--emil); font-size: .85rem; }
