/* Lift Log Training — "Pulse" design, shared with Intervaly: same tokens,
   Archivo, flat bordered surfaces, pill buttons. Dark by default; light when
   the device asks for it. */
@font-face {
  font-family: 'Archivo';
  src: url('fonts/archivo.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bg: #0b0d14; --surface: #151925; --surface-2: #1c2130; --surface-sunk: #0f121b;
  --line: #232838; --line-strong: #2a3042;
  --text: #f2f4f8; --text-2: #a9b0c2; --muted: #8b93a7;
  --run: #2e9bff; --run-dim: #1b3a5c; --walk: #ff8a2a; --walk-dim: #4a3020;
  --done: #3ddc84; --warm: #c792ff; --danger: #ff5d5d; --on-accent: #06111f;
  --accent: var(--run);
  --r-sm: 12px; --r-md: 18px; --r-lg: 22px; --r-pill: 999px;
  --gutter: 20px; --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow-sheet: 0 -12px 40px rgb(0 0 0 / 0.45);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8; --surface: #ffffff; --surface-2: #eef0f5; --surface-sunk: #e9ecf2;
    --line: #e1e4ec; --line-strong: #cfd4df;
    --text: #11141c; --text-2: #3d4456; --muted: #5c6477;
    --run: #0a72d6; --run-dim: #cfe4fb; --walk: #d4600a; --walk-dim: #fbe1cc;
    --done: #11894a; --warm: #7a45c9; --danger: #c42b2b; --on-accent: #ffffff;
    --shadow-sheet: 0 -12px 40px rgb(17 20 28 / 0.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 560px; margin: 0 auto;
  padding: calc(16px + var(--safe-top)) var(--gutter) calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
}
body.resting #app { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 104px); }

h1 { font-size: 30px; font-weight: 800; font-stretch: 112%; line-height: 1.1; margin: 4px 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 800; margin: 26px 0 10px; }
h3 { font-size: 15px; font-weight: 700; margin: 0; }
a { color: inherit; }
p { margin: 0 0 8px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.hint { color: var(--muted); font-size: 13px; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.brand svg { width: 30px; height: 30px; color: var(--accent); flex: none; }

/* surfaces */
.card {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px; margin: 12px 0; text-decoration: none;
}
.card h2 { margin-top: 0; }
a.card { padding: 14px 16px; border-radius: var(--r-md); transition: transform 0.15s var(--ease); }
a.card:active { transform: scale(0.985); }
.row { display: flex; align-items: center; gap: 10px; }
.row > .grow, .grow { flex: 1; min-width: 0; }
.sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.tag.pr { background: var(--walk-dim); color: var(--walk); }

/* buttons */
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
  min-height: 52px; padding: 0 22px; border-radius: var(--r-pill); border: 1px solid var(--line-strong);
  background: var(--surface); font-size: 16px; font-weight: 800; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 14px; margin-top: 10px; }
.btn.danger { color: var(--danger); background: transparent; border-color: transparent; }
.btn[aria-pressed="true"] { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }
span.btn { min-height: 40px; padding: 0 16px; font-size: 14px; }
.icon {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 17px; cursor: pointer; display: inline-grid; place-items: center;
}
.icon:disabled { opacity: 0.3; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-sunk); border-radius: var(--r-pill); }
.seg button {
  flex: 1; min-height: 40px; border: 0; border-radius: var(--r-pill); background: transparent;
  color: var(--text-2); font-size: 14px; font-weight: 700; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* fields */
input:not([type=file]), select, textarea {
  background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 12px; min-width: 0; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea { margin-top: 12px; resize: vertical; }

/* page header */
.bar { display: flex; align-items: center; gap: 8px; margin: 0 -8px 8px; }
.bar .back { font-size: 26px; line-height: 1; color: var(--text); }
.bar .title { font-weight: 800; font-size: 20px; flex: 1; background: transparent; border-color: transparent; padding-left: 4px; }
.bar .title:focus { background: var(--surface-sunk); }
.bar input[type=date], .bar select { width: auto; flex: none; font-size: 14px; }

/* set rows */
.set {
  display: grid; align-items: center; gap: 6px; margin-top: 8px;
  grid-template-columns: 1.6rem 1fr 0.7rem 1fr 48px 32px;
}
.set.fin { grid-template-columns: 1.6rem 1fr 0.7rem 1fr 32px; }
.set > * { grid-row: 1; }
/* A PR label takes the place of the set number. */
.set .n, .set .pr { grid-column: 1; text-align: center; }
.set:has(.pr:not(:empty)) .n { visibility: hidden; }
.set input::placeholder { font-weight: 600; font-size: 14px; font-stretch: 100%; }
.set .n, .set .x { color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }
.set input {
  text-align: center; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px;
  font-stretch: 112%; height: 48px; padding: 0 6px;
}
.set .tick {
  height: 48px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--muted); font-weight: 800; font-size: 17px; cursor: pointer; transition: transform 0.15s var(--ease);
}
.set .tick:active { transform: scale(0.94); }
.set .tick[aria-pressed="true"] { background: var(--done); border-color: transparent; color: var(--on-accent); }
.set.done input { background: transparent; color: var(--text-2); }
.set .pr { font-size: 11px; font-weight: 800; color: var(--walk); letter-spacing: 0.04em; }
.set .del { width: 32px; height: 40px; padding: 0; }
.entry { padding: 16px; }
.entry h3 { font-size: 17px; font-weight: 800; }
.entry h3 a { text-decoration: none; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; min-height: 76px; }
.tile b { display: block; font-size: 22px; font-weight: 800; font-stretch: 112%; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 12px; font-weight: 600; }

/* charts */
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 9px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar-mark { fill: var(--run-dim); }
.chart .bar-mark.now { fill: var(--accent); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart text.val { fill: var(--text); font-weight: 800; }
.mrow { display: grid; grid-template-columns: 5.5rem 1fr 2rem; align-items: center; gap: 10px; margin-top: 8px; font-size: 14px; font-weight: 600; }
.mrow > span:nth-child(2) { background: var(--surface-sunk); border-radius: 4px; }
.mrow i { display: block; height: 8px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.mrow b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; }
#tip {
  position: fixed; z-index: 60; pointer-events: none; background: var(--text); color: var(--bg);
  padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: pre-line; max-width: 220px;
}

/* tab bar */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface-sunk) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: center;
}
#tabs a {
  flex: 1; max-width: 140px; min-height: 48px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600;
}
#tabs svg, .ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.on { color: var(--accent); font-weight: 800; }

/* rest timer */
#rest {
  position: fixed; left: 0; right: 0; z-index: 39; bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 10px var(--gutter);
}
#rest .inner {
  max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
  background: var(--surface); border: 1px solid var(--walk); border-radius: var(--r-lg); box-shadow: var(--shadow-sheet);
  position: relative; overflow: hidden;
}
#rest .fill { position: absolute; inset: 0 auto 0 0; background: var(--walk-dim); transition: width 0.3s linear; }
#rest .inner > :not(.fill) { position: relative; }
#rest .time { font-size: 26px; font-weight: 800; font-stretch: 112%; font-variant-numeric: tabular-nums; color: var(--walk); min-width: 4.2ch; }
#rest .lbl { flex: 1; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
#rest .btn { min-height: 40px; padding: 0 14px; font-size: 14px; margin: 0; }

/* exercise picker: a bottom sheet on phones */
dialog#picker {
  width: min(560px, 100vw); max-width: 100vw; height: 88dvh; max-height: 88dvh; margin: auto auto 0; padding: 0;
  border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0;
  background: var(--surface); color: var(--text); overflow: hidden; box-shadow: var(--shadow-sheet);
}
dialog#picker[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgb(0 0 0 / 0.55); }
@media (min-width: 720px) { dialog#picker { margin: auto; border-radius: 24px; border-bottom: 1px solid var(--line); height: min(80vh, 720px); } }
.picker-head { padding: 8px 16px 0; }
.picker-head::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 8px; }
.picker-head .row { margin-bottom: 10px; }
.picker-head h2 { margin: 0; font-size: 20px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 700; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: transparent; color: var(--on-accent); }
#plist { overflow-y: auto; flex: 1; padding: 0 8px 8px; }
#plist .opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; background: transparent; border: 0;
  border-top: 1px solid var(--line); padding: 8px; text-align: left; cursor: pointer;
}
#plist .opt:first-child { border-top: 0; }
#plist .opt b { display: block; font-size: 15px; font-weight: 700; }
#plist .opt small { color: var(--muted); font-size: 13px; }
.check {
  width: 28px; height: 28px; flex: none; border-radius: 50%; border: 2px solid var(--line-strong);
  display: grid; place-items: center; color: transparent; font-size: 15px; font-weight: 800;
}
.opt[aria-checked="true"] .check { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
#plist .create { display: flex; gap: 8px; padding: 12px 8px; border-top: 1px solid var(--line); }
#plist .create select { width: 8.5rem; flex: none; }
#plist .create .btn { flex: 1; min-width: 0; min-height: 46px; padding: 0 14px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.picker-foot { padding: 10px 16px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.picker-foot .btn { margin: 0; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  z-index: 70; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 700; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 8px 24px rgb(0 0 0 / 0.3);
}
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
