/* ===========================================================================
   Instrument — climbing training PWA
   Design tokens transcribed from "Climb Log PWA.dc.html" (TURN 2, training-only)
   =========================================================================== */
:root {
  /* surfaces */
  --page:        #08090a;
  --frame:       #0c0e0f;
  --frame-bd:    #2a2f33;
  --card-done:   #101315;   /* completed block */
  --card-up:     #0f1214;   /* upcoming block  */
  --card-input:  #14181a;   /* inputs / active */
  --hair:        #1c2124;   /* subtle hairline */
  --hair-2:      #191e21;
  --press:       #20262a;   /* active/pressed  */

  /* ink */
  --ink:         #e8eaeb;
  --muted:       #8a9196;
  --dim:         #5f676c;
  --dimmer:      #3a4145;
  --ghost:       #6f7679;

  /* reserved semantics — the whole system hinges on these two never leaking */
  --accent:      #2fe0a0;   /* CONFIRM ONLY */
  --accent-hi:   #5fe9b7;   /* confirm pressed */
  --on-accent:   #062018;
  --accent-tint: #16241f;   /* checkmark disc  */
  --warn:        #ff6b3d;   /* PAIN / tendon load ONLY */
  --warn-bg:     #1a0f0a;
  --warn-bd:     #5a2a18;

  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: none; margin: 0; cursor: pointer; }

/* Device frame: fills the screen on phones, becomes a centred 390×844 slab on desktop */
#device {
  height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
#app {
  position: relative;
  width: 100%;
  max-width: 430px;
  background: var(--frame);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 460px) {
  #device { align-items: center; padding: 24px; }
  #app {
    width: 390px;
    height: min(844px, calc(100dvh - 48px));
    border: 1px solid var(--frame-bd);
    border-radius: 26px;
  }
}

/* ---------- screen scaffold ---------- */
.screen { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.statusbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(14px + var(--safe-t)) 20px 6px;
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  flex: none;
}
.hdr {
  padding: 6px 20px 14px;
  border-bottom: 1px solid var(--hair);
  flex: none;
}
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.thumb {
  flex: none;
  padding: 14px 16px calc(12px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, rgba(12,14,15,0) 0%, var(--frame) 22%);
}

/* ---------- type helpers ---------- */
.mono { font-family: var(--mono); }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .18em; color: var(--muted); }
.klabel { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; color: var(--dim); }

/* ---------- Today: header ---------- */
.today-head { display: flex; align-items: flex-end; justify-content: space-between; }
.week-num {
  font-family: var(--mono); font-size: 56px; font-weight: 600;
  line-height: .88; letter-spacing: -.04em;
}
.week-num small { font-size: 22px; color: var(--dim); font-weight: 400; }
.head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; padding-bottom: 5px; }
.badge {
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .16em;
  color: var(--ink); background: var(--frame-bd);
  padding: 6px 10px; border-radius: 3px;
}

/* ---------- block cards ---------- */
.blocks { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 6px; }

.block { border-radius: 8px; border: 1px solid var(--hair); }

.block.done {
  display: flex; align-items: center; gap: 14px;
  background: var(--card-done); padding: 0 16px; min-height: 60px;
}
.block.done .name { flex: 1; font-size: 16px; font-weight: 600; color: var(--ghost); }
.block.done .meta { font-family: var(--mono); font-size: 14px; color: var(--dim); }

.check {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent);
  font-family: var(--mono); font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex: none;
}

.block.up {
  display: flex; align-items: center; gap: 14px;
  background: var(--card-up); padding: 0 16px; min-height: 74px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--dimmer); flex: none; }
.dot.on { background: var(--accent); border-color: var(--accent); }
.block.up .body { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.block.up .name { font-size: 16px; font-weight: 600; }
.rationale { font-family: var(--mono); font-size: 12px; color: var(--muted); line-height: 1.35; }
.block .num { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.block .num b { font-family: var(--mono); font-size: 26px; font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.block .num span { font-family: var(--mono); font-size: 11px; color: var(--dim); letter-spacing: .1em; }
.block .num b small { color: var(--dim); font-size: .6em; }

/* active (expanded) block */
.block.active { background: var(--card-input); border-color: var(--accent); overflow: hidden; }
.block.active .row-top {
  display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 60px;
  border-bottom: 1px solid #202629;
}
.block.active .row-top .name { flex: 1; font-size: 17px; font-weight: 600; }
.block.active .row-top .set { font-family: var(--mono); font-size: 13px; color: var(--accent); letter-spacing: .08em; }
.ex-row {
  padding: 13px 16px; display: flex; gap: 12px; align-items: center;
  border-bottom: 1px solid var(--hair-2);
}
.ex-row:last-child { border-bottom: none; }
.ex-row .body { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ex-row .body .name { font-size: 15px; font-weight: 600; }
.ex-row .num b { font-size: 30px; }
.ex-row.done .body .name { color: var(--ghost); }

/* ---------- primary buttons ---------- */
.primary {
  width: 100%; min-height: 74px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 3px; text-align: center;
}
.primary:active { background: var(--accent-hi); }
.primary .big { font-size: 19px; font-weight: 700; letter-spacing: .02em; }
.primary .sub { font-family: var(--mono); font-size: 12px; opacity: .72; }
.primary.wide { flex-direction: row; justify-content: space-between; padding: 0 24px; min-height: 92px; }
.primary.wide .big { font-size: 25px; }
.primary.wide .sub { font-size: 19px; font-weight: 600; opacity: .8; }

.continue-row { display: flex; gap: 10px; }
.icon-btn {
  width: 74px; height: 74px; flex: none;
  border: 1px solid var(--frame-bd); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted);
}
.icon-btn:active { background: var(--press); }
.icon-btn .g { font-family: var(--mono); font-size: 20px; font-weight: 600; }
.icon-btn .t { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; }

.ghost-btn {
  flex: 1; min-height: 56px; border: 1px solid var(--frame-bd); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--mono); font-size: 13px; letter-spacing: .1em; color: var(--muted);
}
.ghost-btn:active { background: var(--press); }
.ghost-btn.warn { border-color: var(--warn-bd); background: var(--warn-bg); color: var(--warn); }
.ghost-btn .diamond { width: 9px; height: 9px; background: var(--warn); transform: rotate(45deg); }

/* ---------- bottom nav ---------- */
.nav { display: flex; border-top: 1px solid var(--hair); padding-top: 4px; }
.nav button {
  flex: 1; min-height: 58px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--dim);
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
}
.nav button.on { color: var(--ink); }
.nav .ic { width: 16px; height: 16px; }
.nav .ic.today  { border: 2px solid currentColor; border-radius: 2px; }
.nav .ic.history{ border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; }
.nav .ic.dash   { border: 2px solid currentColor; border-radius: 2px; transform: rotate(45deg); }

/* ---------- Active Set screen ---------- */
.set-hdr {
  padding: 8px 20px 14px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--hair); flex: none;
}
.set-hdr h1 { margin: 0; font-size: 23px; font-weight: 600; letter-spacing: -.01em; }
.set-hdr .klabel { margin-top: 4px; letter-spacing: .1em; color: var(--muted); }
.pips { display: flex; gap: 5px; }
.pip { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--dimmer); }
.pip.done { background: var(--accent); border-color: var(--accent); }
.pip.cur  { border-color: var(--accent); }

.suggest { padding: 14px 20px 0; display: flex; flex-direction: column; gap: 5px; flex: none; }
.suggest .k { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; color: var(--dim); }
.suggest .v { font-family: var(--mono); font-size: 13px; color: var(--muted); line-height: 1.4; }

.dials { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 0 20px; }
.stepper { display: flex; align-items: center; gap: 14px; }
.step-btn {
  flex: none; width: 84px; border: 1px solid var(--frame-bd);
  background: var(--card-input); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 500; color: var(--ink); user-select: none;
}
.step-btn:active { background: var(--press); }
.step-btn.lg { height: 104px; font-size: 40px; }
.step-btn.sm { height: 80px; font-size: 34px; }
.dial-val { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.dial-val .n-load { font-family: var(--mono); font-size: 78px; font-weight: 600; line-height: 1; letter-spacing: -.05em; margin-bottom: 4px; }
.dial-val .n-reps { font-family: var(--mono); font-size: 56px; font-weight: 600; line-height: 1; letter-spacing: -.04em; }
.dial-val .u { font-family: var(--mono); font-size: 13px; letter-spacing: .18em; color: var(--dim); }

.rpe-wrap { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.rpe-head { display: flex; justify-content: space-between; align-items: baseline; }
.rpe-head .k { font-family: var(--mono); font-size: 12px; letter-spacing: .16em; color: var(--dim); }
.rpe-head .n { font-family: var(--mono); font-size: 36px; font-weight: 600; line-height: 1; }
.rpe-track {
  position: relative; height: 64px; background: var(--card-input);
  border: 1px solid var(--frame-bd); border-radius: 10px; overflow: hidden; touch-action: none;
}
.rpe-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--press); }
.rpe-grid { position: absolute; inset: 0; display: flex; }
.rpe-grid i { flex: 1; border-right: 1px solid var(--hair); }
.rpe-grid i:last-child { border-right: none; }
.rpe-knob { position: absolute; top: 6px; bottom: 26px; width: 6px; border-radius: 3px; background: var(--ink); margin-left: -3px; }
.rpe-ticks {
  position: absolute; left: 12px; right: 12px; bottom: 6px;
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 11px; color: var(--dim);
}

/* ---------- Rest screen ---------- */
.rest-body { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; padding: 0 20px; }
.rest-clock { font-family: var(--mono); font-size: clamp(96px, 34vw, 150px); font-weight: 600; line-height: .92; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.rest-clock.over { color: var(--warn); }
.rest-sub { font-family: var(--mono); font-size: 13px; letter-spacing: .22em; color: var(--dim); margin-bottom: 22px; }
.rest-bar { width: 100%; height: 10px; background: var(--card-input); border-radius: 5px; overflow: hidden; }
.rest-bar > i { display: block; height: 100%; background: var(--dimmer); }
.rest-cards { padding: 0 20px; display: flex; flex-direction: column; gap: 10px; flex: none; }
.logged-card {
  border: 1px solid var(--hair); background: var(--card-done); border-radius: 8px;
  padding: 13px 16px; display: flex; align-items: center; gap: 12px;
}
.logged-card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.logged-card .body .k { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--dim); }
.logged-card .body .name { font-size: 15px; font-weight: 600; color: #8f9699; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logged-card .amt { font-family: var(--mono); font-size: 16px; font-weight: 600; color: #8f9699; white-space: nowrap; }
.next-card {
  border: 1px solid var(--frame-bd); background: var(--card-input); border-radius: 8px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.next-card .body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.next-card .body .k { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--dim); }
.next-card .body .name { font-size: 17px; font-weight: 600; }
.next-card .num { flex: none; text-align: right; display: flex; flex-direction: column; gap: 2px; }
.next-card .num b { font-family: var(--mono); font-size: 30px; font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.next-card .num span { font-family: var(--mono); font-size: 11px; color: var(--dim); letter-spacing: .1em; }

/* ---------- checklist (mobility) & timer (warm-up) ---------- */
.simple-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.checkitem {
  display: flex; align-items: center; gap: 14px; min-height: 60px;
  background: var(--card-up); border: 1px solid var(--hair); border-radius: 8px; padding: 0 16px;
}
.checkitem.on { background: var(--card-done); }
.checkitem .name { flex: 1; font-size: 16px; font-weight: 600; }
.checkitem.on .name { color: var(--ghost); }
.checkbox { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--dimmer); flex: none; display:flex; align-items:center; justify-content:center; }
.checkitem.on .checkbox { background: var(--accent-tint); border-color: var(--accent-tint); color: var(--accent); font-family: var(--mono); font-size: 13px; }

.timer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; }
.timer-clock { font-family: var(--mono); font-size: clamp(88px, 30vw, 132px); font-weight: 600; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }

/* ---------- History / Dash ---------- */
.list-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--dim); font-family: var(--mono); font-size: 13px; text-align: center; padding: 48px 20px; line-height: 1.6; }
.hist-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--card-done); border: 1px solid var(--hair); border-radius: 8px;
}
.hist-row .body { flex: 1; min-width: 0; }
.hist-row .body .name { font-size: 15px; font-weight: 600; }
.hist-row .body .k { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--dim); margin-bottom: 3px; }
.hist-row .amt { font-family: var(--mono); font-size: 16px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.hist-row.pain { border-color: var(--warn-bd); }
.hist-row.pain .amt { color: var(--warn); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--card-input); border: 1px solid var(--frame-bd); border-radius: 10px; padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat .k { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--dim); }
.stat .v { font-family: var(--mono); font-size: 40px; font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.stat .v small { font-size: 16px; color: var(--dim); }

.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card-input); border: 1px solid var(--frame-bd); border-radius: 10px; padding: 16px;
}
.setting .name { font-size: 15px; font-weight: 600; }
.setting .desc { font-family: var(--mono); font-size: 12px; color: var(--dim); margin-top: 3px; }
/* neutral on-state — accent stays reserved for confirm actions only */
.toggle { width: 52px; height: 30px; border-radius: 15px; background: var(--press); position: relative; flex: none; transition: background .15s; }
.toggle.on { background: var(--ink); }
.toggle > i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--dim); transition: left .15s; }
.toggle.on > i { left: 25px; background: var(--frame); }

.section-title { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; color: var(--dim); padding: 8px 2px 2px; }
.link-btn { color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-decoration: underline; text-underline-offset: 3px; align-self: flex-start; padding: 8px 2px; }
