/* Lift — a training log meant to be used with one sweaty thumb.
 *
 * Two constraints drove nearly every choice here. Targets are large because
 * you're tapping between sets with shaky hands, and the palette is dark with a
 * single warm accent because the phone is often the brightest thing in the room.
 */

:root {
  --bg: #0f1115;
  --bg-soft: #161922;
  --card: #191d27;
  --card-2: #1f2430;
  --line: #272d3a;
  --line-soft: #20242f;

  --text: #eef1f6;
  --dim: #99a2b5;
  --faint: #6b7488;

  --accent: #f97316;
  --accent-soft: #fb923c;
  --accent-dim: rgba(249, 115, 22, 0.14);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --pr: #fcd34d;

  --bm-base: #2c3342;
  --bm-lit: var(--accent);

  --radius: 16px;
  --radius-sm: 11px;
  --pad: 16px;

  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

h1 { font-size: 25px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
     color: var(--faint); margin: 26px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0; }
p { margin: 0 0 10px; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

.sub { color: var(--dim); font-size: 13px; }
.stack > * + * { margin-top: 10px; }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.muted { color: var(--dim); }
.tiny { font-size: 12px; }
[hidden] { display: none !important; }

/* ─────────────────────────────── buttons ─────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px;
  font-weight: 600; font-size: 15px;
  background: var(--card-2); border: 1px solid var(--line);
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.985); }
a.btn { text-decoration: none; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #17110a; }
.btn.ghost { background: transparent; border-style: dashed; color: var(--dim); }
.btn.subtle { background: transparent; border-color: transparent; color: var(--faint); }
.btn.block { display: flex; width: 100%; }
.btn.danger { color: var(--bad); border-color: rgba(248, 113, 113, 0.3); }

.chip {
  min-height: 34px; padding: 0 13px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--dim);
}
.chip.accent { background: var(--accent); border-color: var(--accent); color: #17110a; }
.chip.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-soft); }
.chip.pending { background: rgba(251, 191, 36, 0.14); border-color: rgba(251,191,36,.35); color: var(--warn); }

.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  color: var(--dim); font-size: 18px; background: var(--card-2); border: 1px solid var(--line);
}
.linkish { color: var(--accent-soft); font-size: 13px; font-weight: 600; padding: 4px; }

.card {
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: var(--pad);
}

/* The exercise selector on the Progress tab. Reads as a field rather than a
   button, because that's what it does — it holds the current selection. */
.picker-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; min-height: 50px; padding: 0 16px; margin-bottom: 14px;
  border-radius: 12px; font-size: 15px; font-weight: 600; text-align: left;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
}
.picker-btn::after { content: "▾"; color: var(--accent); font-size: 13px; }

/* ──────────────────────────────── gate ───────────────────────────────── */

#gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: 100%; max-width: 380px; }
.gate-mark {
  width: 54px; height: 54px; border-radius: 16px; margin-bottom: 18px;
  background: var(--accent);
  -webkit-mask: radial-gradient(circle at 22% 50%, #000 9px, transparent 10px),
                radial-gradient(circle at 78% 50%, #000 9px, transparent 10px),
                linear-gradient(#000 0 0) 50% 50% / 40% 22% no-repeat;
  mask: radial-gradient(circle at 22% 50%, #000 9px, transparent 10px),
        radial-gradient(circle at 78% 50%, #000 9px, transparent 10px),
        linear-gradient(#000 0 0) 50% 50% / 40% 22% no-repeat;
  background-color: var(--accent);
}
.gate-sub { color: var(--dim); margin-bottom: 22px; }
.gate-error { color: var(--bad); font-size: 13px; }

.field { display: block; margin-bottom: 13px; }
/* The :not() matters — a .field-row nested inside a label (a rep range, say) is
   also a direct span child, and would otherwise be forced back to display:block
   and stack its two inputs vertically. */
.field > span:not(.field-row) {
  display: block; font-size: 12px; color: var(--faint); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); background: var(--card-2);
}
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }

/* ───────────────────────────── app frame ─────────────────────────────── */

#main { padding: max(18px, env(safe-area-inset-top)) 16px calc(var(--nav-h) + var(--safe-b) + 24px); }
.topbar { display: flex; align-items: flex-start; justify-content: space-between;
          gap: 12px; margin-bottom: 18px; }
.topbar h1 { margin-bottom: 2px; }

#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line-soft);
}
#nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em; color: var(--faint);
}
#nav button .ic { font-size: 17px; line-height: 1; }
#nav button.on { color: var(--accent); }

/* ───────────────────────────── body map ──────────────────────────────── */

.ex-icon {
  position: relative; display: inline-grid; place-items: center;
  width: var(--icon-size); height: var(--icon-size);
  background: var(--card-2); border-radius: 10px; flex: none;
  overflow: hidden;
}
.ex-icon .bodymap { height: calc(var(--icon-size) * 0.86); width: auto; }
.ex-icon-badge {
  position: absolute; right: -1px; bottom: -1px;
  display: grid; place-items: center; padding: 2px;
  background: var(--card); border-radius: 7px 0 9px 0;
  color: var(--dim);
}

.bodymap { display: block; }

/* ────────────────────────── exercise rows ────────────────────────────── */

.ex-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--line-soft);
}
.ex-row:active { background: var(--card-2); }
.ex-row .meta { min-width: 0; flex: 1; }
.ex-row .meta strong { display: block; font-weight: 600; font-size: 14.5px;
                       overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-row .meta span { color: var(--faint); font-size: 12px; }
.ex-row .trail { color: var(--faint); font-size: 12px; text-align: right; flex: none; }

/* ───────────────────────────── routines ──────────────────────────────── */

.routine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.routine-tile {
  text-align: left; padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 6px; min-height: 104px;
}
.routine-tile strong { font-size: 15px; }
.routine-tile .rt-ex { color: var(--faint); font-size: 12px; line-height: 1.35;
                       display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
                       overflow: hidden; }
.routine-tile .rt-foot { margin-top: auto; color: var(--accent-soft); font-size: 11.5px; font-weight: 600; }

.folder-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em;
                text-transform: uppercase; color: var(--faint); margin: 20px 0 8px; }

.session-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 14px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--line-soft);
}
.session-row .s-main { flex: 1; min-width: 0; }
.session-row .s-main strong { display: block; font-size: 14.5px; }
.session-row .s-main span { color: var(--faint); font-size: 12px; }
.session-row .s-stat { text-align: right; font-size: 12px; color: var(--dim); }
.session-row .s-stat b { display: block; color: var(--text); font-size: 14px; }

/* ────────────────────────────── logger ───────────────────────────────── */

#logger {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column;
}
.logger-top {
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  border-bottom: 1px solid var(--line-soft); background: var(--bg-soft);
}
.logger-title { flex: 1; min-width: 0; }
.logger-title strong { display: block; font-size: 16px; overflow: hidden;
                       text-overflow: ellipsis; white-space: nowrap; }
.logger-title span { color: var(--accent-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.logger-scroll { flex: 1; overflow-y: auto; padding: 14px 14px 8px; -webkit-overflow-scrolling: touch; }
.logger-actions {
  display: flex; gap: 10px; padding: 10px 14px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line-soft); background: var(--bg-soft);
}
.logger-actions .btn { flex: 1; }

.log-ex { margin-bottom: 16px; border-radius: var(--radius);
          background: var(--card); border: 1px solid var(--line-soft); overflow: hidden; }
.log-ex.superset { border-color: rgba(249, 115, 22, 0.4); }
.log-ex-head { display: flex; align-items: center; gap: 11px; padding: 12px 12px 10px; }
.log-ex-head .meta { flex: 1; min-width: 0; }
.log-ex-head .meta strong { display: block; font-size: 15px; }
.log-ex-head .meta span { color: var(--faint); font-size: 11.5px; }

.ghost-line {
  padding: 0 13px 8px; font-size: 12px; color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.hint-line {
  margin: 0 12px 10px; padding: 8px 11px; border-radius: 10px;
  background: var(--accent-dim); color: var(--accent-soft);
  font-size: 12px; line-height: 1.4;
}
.hint-line.stall { background: rgba(251, 191, 36, 0.13); color: var(--warn); }
.hint-line button { color: inherit; text-decoration: underline; font-weight: 700; }

.set-head, .set-row {
  display: grid; grid-template-columns: 34px 1fr 1fr 52px 44px;
  gap: 7px; align-items: center; padding: 0 12px;
}
.set-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
            color: var(--faint); font-weight: 700; padding-bottom: 5px; }
.set-head span:nth-child(4), .set-head span:nth-child(5) { text-align: center; }
.set-row { padding-top: 4px; padding-bottom: 4px; }
.set-row.done { background: rgba(52, 211, 153, 0.07); }
.set-row.done .set-no { color: var(--good); }

.set-no {
  height: 38px; border-radius: 9px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--dim); background: var(--card-2);
}
.set-no.warmup { color: var(--warn); }
.set-row input {
  height: 38px; width: 100%; text-align: center; border-radius: 9px;
  background: var(--card-2); border: 1px solid var(--line);
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.set-row input::placeholder { color: var(--faint); font-weight: 500; }
.set-row input:focus { outline: none; border-color: var(--accent); }
.set-row .rir-in { font-size: 13px; }
.set-check {
  height: 38px; border-radius: 9px; display: grid; place-items: center;
  background: var(--card-2); border: 1px solid var(--line); color: var(--faint); font-size: 16px;
}
.set-check.on { background: var(--good); border-color: var(--good); color: #06281c; }

.set-tools { display: flex; gap: 8px; padding: 8px 12px 12px; }
.set-tools .chip { min-height: 30px; font-size: 12px; }

.pr-flash {
  margin: 0 12px 10px; padding: 9px 12px; border-radius: 10px;
  background: rgba(252, 211, 77, 0.14); color: var(--pr);
  font-size: 12.5px; font-weight: 600;
}

/* rest timer */
.rest-bar { position: relative; background: var(--card); border-top: 1px solid var(--line);
            overflow: hidden; }
.rest-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent-dim);
             transition: width 1s linear; }
.rest-inner { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 14px; }
.rest-read { flex: 1; text-align: center; }
.rest-read strong { font-size: 20px; font-variant-numeric: tabular-nums; color: var(--accent-soft); }
.rest-read span { display: block; font-size: 10px; text-transform: uppercase;
                  letter-spacing: 0.08em; color: var(--faint); }
.rest-inner .icon-btn { width: auto; padding: 0 12px; font-size: 13px; font-weight: 700; }

/* ──────────────────────────── bottom sheet ───────────────────────────── */

#sheet { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
         justify-content: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.sheet-panel {
  position: relative; background: var(--bg-soft); border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line); max-height: 88dvh; display: flex; flex-direction: column;
  animation: rise 0.2s ease;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0.6; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between;
              padding: 14px 14px 10px; border-bottom: 1px solid var(--line-soft); }
.sheet-head strong { font-size: 16px; }
.sheet-body { overflow-y: auto; padding: 14px 14px calc(20px + var(--safe-b)); }
.sheet-body .stack > * + * { margin-top: 9px; }

.search-input {
  width: 100%; min-height: 44px; padding: 10px 14px; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.filter-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 10px;
              scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row .chip { flex: none; }

/* ─────────────────────────────── charts ──────────────────────────────── */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2;
               stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#chartFade); }
.chart .dot { fill: var(--accent); }
.chart .lbl { fill: var(--faint); font-size: 9px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 9px; }
.stat-tile { background: var(--card); border: 1px solid var(--line-soft);
             border-radius: var(--radius-sm); padding: 12px; }
.stat-tile b { display: block; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.stat-tile span { font-size: 11px; color: var(--faint); text-transform: uppercase;
                  letter-spacing: 0.05em; font-weight: 600; }

.vol-row { display: grid; grid-template-columns: 88px 1fr 44px; gap: 10px;
           align-items: center; padding: 4px 0; }
.vol-row .vol-name { font-size: 12.5px; color: var(--dim); }
.vol-track { position: relative; height: 9px; border-radius: 5px; background: var(--card-2);
             overflow: hidden; }
.vol-band { position: absolute; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.07); }
.vol-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 5px; }
.vol-fill.low { background: var(--warn); }
.vol-fill.ok { background: var(--good); }
.vol-fill.high { background: var(--bad); }
.vol-fill.none { background: var(--line); }
.vol-row .vol-num { text-align: right; font-size: 12px; color: var(--dim);
                    font-variant-numeric: tabular-nums; }

.map-pair { display: flex; gap: 14px; justify-content: center; padding: 6px 0 2px; }
.map-pair figure { margin: 0; text-align: center; }
.map-pair figcaption { font-size: 10.5px; color: var(--faint); text-transform: uppercase;
                       letter-spacing: 0.07em; margin-top: 4px; }

/* ─────────────────────────────── toast ──────────────────────────────── */

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 100;
  max-width: min(92vw, 420px); padding: 11px 16px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); font-size: 13.5px;
}
#toast.pr { background: rgba(252, 211, 77, 0.16); border-color: var(--pr); color: var(--pr); }
/* With the logger open there's no nav bar, but there is a rest timer — and a
   personal-best announcement landing on top of the countdown makes both
   unreadable. */
body.logging #toast { bottom: calc(var(--safe-b) + 132px); }

/* Wider screens get breathing room rather than a stretched phone layout. */
@media (min-width: 720px) {
  #main, .logger-scroll { max-width: 680px; margin: 0 auto; }
  .logger-top, .logger-actions { max-width: 680px; margin: 0 auto; width: 100%; }
  .sheet-panel { max-width: 620px; margin: 0 auto; border-radius: 20px; margin-bottom: 24px; }
  #sheet { justify-content: center; padding: 20px; }
}
