/* ==========================================================================
   Workout Tracker — rossoneri
   Palette: AC Milan red #FB090B, black #0A0A0A, white, gold accent #D4AF37.

   The shared shell — tokens, top bar, panels, inputs, buttons, tabs, report,
   toast — is carried over from Weight Tracker so the two apps feel like one
   pair. Everything below the "workout" divider is new: plan rows, the lift
   session runner, the treadmill display and the bottom sheet.
   ========================================================================== */
:root {
  --red:        #FB090B;
  --red-deep:   #B00507;
  --red-glow:   rgba(251, 9, 11, 0.28);
  --gold:       #D4AF37;

  --bg:         #0A0A0A;
  --panel:      #151515;
  --panel-2:    #1E1E1E;
  --line:       #2A2A2A;
  --line-soft:  #202020;

  --text:       #F5F5F5;
  --text-dim:   #9B9B9B;
  --text-faint: #6A6A6A;

  --radius:     14px;
  --radius-sm:  10px;
  --tabbar-h:   58px;

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

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-num: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(10, 10, 10, 0.86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* Rossoneri stripes */
.crest {
  width: 20px;
  height: 26px;
  border-radius: 3px;
  flex: none;
  background: repeating-linear-gradient(
    90deg,
    var(--red) 0 4px,
    #0A0A0A 4px 8px
  );
  box-shadow: 0 0 0 1px var(--line), 0 2px 10px var(--red-glow);
}

.brand-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }

.sync-status {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}
.sync-status.ok      { color: var(--text-dim); }
.sync-status.working { color: var(--gold); }
.sync-status.error   { color: var(--red); }

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-dim);
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}
.icon-btn:active { background: var(--line); }
.icon-btn.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- layout */

#main { padding: 14px 14px 24px; }
.view { display: flex; flex-direction: column; gap: 14px; }
.view[hidden] { display: none !important; }

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

.panel-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.note {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}
.note.dim, .dim { color: var(--text-faint); }
.note code {
  font-family: var(--font-num);
  font-size: 11.5px;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ forms */

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 16px 0 6px;
}
.field-label:first-child { margin-top: 0; }

.text-input, .date-input, .select {
  width: 100%;
  appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 16px; /* 16px stops iOS zooming on focus */
  font-family: inherit;
}
.text-input:focus, .date-input:focus, .select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}
.select { cursor: pointer; width: auto; padding-right: 32px; font-size: 14px; }
input[type="file"].text-input { padding: 9px 12px; font-size: 13px; color: var(--text-dim); }

.primary-btn {
  appearance: none;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--red) 0%, var(--red-deep) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--red-glow);
}
.primary-btn:active { transform: translateY(1px); box-shadow: none; }
.primary-btn:disabled { opacity: 0.45; box-shadow: none; cursor: default; }

.ghost-btn {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  margin-top: 10px;
}
.ghost-btn:active { background: var(--panel-2); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btn-row > button { flex: 1 1 160px; width: auto; margin-top: 0; }

/* week strip — seven columns must survive a 375px phone */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.wd {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 8px 1px;
  text-align: center;
  min-width: 0;
  overflow: hidden;
  /* Explicit column: the day and its label are spans here, so they would
     otherwise run together on one line. */
  display: flex;
  flex-direction: column;
  align-items: center;
}
.wd.filled { border-color: var(--red); background: rgba(251, 9, 11, 0.09); }
.wd.today  { box-shadow: 0 0 0 2px var(--red-glow); }
.wd.sat .wd-day { color: var(--gold); }
.wd-day { font-size: 10px; font-weight: 700; letter-spacing: 0; color: var(--text-faint); text-transform: uppercase; }
.wd-val { font-family: var(--font-num); font-size: 11px; letter-spacing: -0.4px; margin-top: 4px; color: var(--text); }
.wd-val.empty { color: var(--line); }

/* entry lists */
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.entry-list li:last-child { border-bottom: none; }
.entry-list .el-date { font-size: 13.5px; color: var(--text-dim); }
.entry-list .el-date.sat { color: var(--gold); font-weight: 600; }
.entry-list .el-right { display: flex; align-items: baseline; gap: 10px; }
.entry-list .el-val { font-family: var(--font-num); font-size: 15px; font-weight: 600; }
.entry-list .el-delta { font-family: var(--font-num); font-size: 12px; min-width: 52px; text-align: right; }
.empty-state { color: var(--text-faint); font-size: 13px; padding: 8px 0; }

.down { color: var(--red); }
.up   { color: var(--gold); }
.flat { color: var(--text-faint); }
/* chart */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-head .panel-title { margin: 0; }

.seg { display: flex; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 7px;
  cursor: pointer;
}
.seg button.is-active { background: var(--red); color: #fff; }

.chart-host { width: 100%; touch-action: pan-y; }
.chart-host svg { display: block; width: 100%; height: auto; overflow: visible; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 11.5px; color: var(--text-dim); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item[hidden] { display: none; }   /* [hidden] alone loses to the rule above */
.swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch-dot   { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.swatch-trend { background: var(--red); }
.swatch-goal  { background: var(--gold); height: 0; border-top: 2px dashed var(--gold); }

/* stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.stat-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--text-faint); }
.stat-value { font-family: var(--font-num); font-size: 21px; font-weight: 600; margin-top: 5px; letter-spacing: -0.5px; }
.stat-value small { font-size: 11px; color: var(--text-faint); font-weight: 500; margin-left: 3px; }
.stat-sub { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------------------------------------------------------------- history */

.month-block { margin-bottom: 18px; }
.month-block:last-child { margin-bottom: 0; }
.month-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 2px solid var(--red);
  margin-bottom: 4px;
}
.month-name { font-size: 13px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }
.month-meta { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-num); }
.entry-list li.editable { cursor: pointer; }
.entry-list li.editable:active { background: var(--panel-2); }
/* ------------------------------------------------------------------ tabs */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(12, 12, 12, 0.93);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  padding: 0;
}
.tab-ico { font-size: 17px; line-height: 1; }
.tab-label { font-size: 9.5px; font-weight: 600; letter-spacing: 0.3px; }
.tab.is-active { color: #fff; }
.tab.is-active::before {
  content: "";
  position: absolute;
  top: 0; left: 22%; right: 22%;
  height: 2px;
  background: var(--red);
  border-radius: 0 0 2px 2px;
}

/* ----------------------------------------------------- sync diagnostics */

.report {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  padding: 4px 12px;
}
.report[hidden] { display: none; }
.report .line {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-dim);
}
.report .line:last-child { border-bottom: none; }
.report .mark { flex: none; font-size: 12px; line-height: 1.45; width: 13px; text-align: center; }
.report .ok   .mark { color: #3FB950; }
.report .warn .mark { color: var(--gold); }
.report .bad  .mark { color: var(--red); }
.report .info .mark { color: var(--text-faint); }
.report .bad  { color: var(--text); }

.advanced { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.advanced summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-faint);
  list-style: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "▸ "; }
.advanced[open] summary::before { content: "▾ "; }
/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translate(-50%, 12px);
  z-index: 60;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 99px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--red); }

/* ==========================================================================
   WORKOUT — everything below here is specific to this app
   ========================================================================== */

/* --------------------------------------------------------------- today */

.next-panel { position: relative; overflow: hidden; }
.next-panel::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(var(--red), var(--red-deep));
}
.next-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); padding-left: 10px; }
.next-name  { font-size: 26px; font-weight: 700; letter-spacing: -0.6px; margin-top: 4px; padding-left: 10px; }
.next-sub   { font-size: 13px; color: var(--text-dim); margin-top: 6px; padding-left: 10px; line-height: 1.5; }

.primary-btn.big { margin-top: 18px; padding: 16px; font-size: 16px; }

.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.start-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; color: var(--text); font-family: var(--font); cursor: pointer;
}
.start-card:active { background: var(--line); }
.start-card b { font-size: 14px; font-weight: 600; }
.start-card span { font-size: 11.5px; color: var(--text-faint); }
.start-card.cardio b { color: var(--gold); }

.wd.done { border-color: var(--red); background: rgba(251, 9, 11, 0.09); }
.wd.done.cardio { border-color: var(--gold); background: rgba(212, 175, 55, 0.10); }

/* ------------------------------------------------------ plan / ladder rows */

.plan-rows, .ladder-rows, .rotation-rows { display: flex; flex-direction: column; gap: 8px; }

.prow {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.prow.dragging { opacity: 0.4; }
.prow.drop-target { border-color: var(--red); box-shadow: 0 0 0 2px var(--red-glow); }
.prow-main { flex: 1 1 auto; min-width: 0; cursor: pointer; }
.prow-name { font-size: 14px; font-weight: 600; }
.prow-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; font-family: var(--font-num); }
.prow-grip {
  flex: none; width: 26px; height: 30px; border: none; background: none;
  color: var(--text-faint); font-size: 15px; cursor: grab; touch-action: none;
  border-radius: 6px;
}
.prow-grip:active { cursor: grabbing; background: var(--line); }
.prow-move { display: flex; flex-direction: column; gap: 2px; flex: none; }
.prow-move button {
  width: 28px; height: 20px; padding: 0; line-height: 1;
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
  color: var(--text-dim); font-size: 11px; cursor: pointer;
}
.prow-move button:active { background: var(--red); border-color: var(--red); color: #fff; }
.prow-move button:disabled { opacity: 0.3; cursor: default; }
.prow-del {
  flex: none; width: 28px; height: 28px; padding: 0;
  background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--text-faint); font-size: 14px; cursor: pointer;
}
.prow-del:active { border-color: var(--red); color: var(--red); }

.lrow { display: flex; align-items: center; gap: 10px; font-family: var(--font-num); font-size: 13px; padding: 8px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.lrow .lr-i { width: 22px; color: var(--text-faint); font-size: 11px; flex: none; }
.lrow .lr-kind { flex: none; font-size: 10px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; font-family: var(--font); }
.lrow .lr-kind.work { background: rgba(251, 9, 11, 0.14); color: var(--red); }
.lrow .lr-kind.warmup, .lrow .lr-kind.cooldown { background: var(--line); color: var(--text-faint); }
.lrow .lr-spec { flex: 1 1 auto; }
.lrow .lr-dur { color: var(--text-dim); flex: none; }

.rrow { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13.5px; }
.rrow .rr-n { width: 20px; color: var(--text-faint); font-family: var(--font-num); font-size: 11px; flex: none; }
.rrow.is-next { border-color: var(--red); }
.rrow .rr-tag { margin-left: auto; font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--red); }

/* ------------------------------------------------------------- the runner */

.runner {
  position: fixed; inset: 0; z-index: 80; background: var(--bg);
  display: flex; flex-direction: column;
}
.runner[hidden] { display: none !important; }

.runner-top {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.runner-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.runner-title > span:first-child { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
.runner-clock { font-family: var(--font-num); font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.finish-btn {
  flex: none; padding: 9px 16px; border-radius: 9px; border: none; cursor: pointer;
  background: var(--red); color: #fff; font-family: var(--font); font-size: 13.5px; font-weight: 600;
}
.finish-btn:active { background: var(--red-deep); }

.runner-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; }
.runner-body[hidden] { display: none !important; }
.runner-foot {
  flex: none; border-top: 1px solid var(--line); background: var(--panel);
  padding: 10px 12px calc(10px + var(--safe-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: 12px;
}
.runner-foot .btn-row { margin-top: 0; }
.runner-foot .btn-row > button { flex: 0 0 auto; }

/* -------------------------------------------------------- lift session rows */

.lift-rows { display: flex; flex-direction: column; gap: 10px; }

.xrow {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.xrow[data-state="done"]    { border-color: rgba(251, 9, 11, 0.45); }
.xrow[data-state="skipped"] { opacity: 0.5; }
.xrow.dragging { opacity: 0.4; }
.xrow.drop-target { border-color: var(--red); box-shadow: 0 0 0 2px var(--red-glow); }

.xrow-head { display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer; }
.xrow-mark {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--bg); background: none;
}
.xrow[data-state="done"] .xrow-mark    { background: var(--red); border-color: var(--red); color: #fff; }
.xrow[data-state="skipped"] .xrow-mark { border-style: dashed; color: var(--text-faint); background: none; }
.xrow-name { flex: 1 1 auto; min-width: 0; }
.xrow-name b { display: block; font-size: 14.5px; font-weight: 600; }
.xrow-target { display: block; font-size: 12px; color: var(--red); font-family: var(--font-num); margin-top: 3px; }
.xrow[data-state="done"] .xrow-target { color: var(--text-dim); }
.xrow-last { display: block; font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.xrow-body { border-top: 1px solid var(--line-soft); padding: 12px; display: none; }
.xrow.is-open .xrow-body { display: block; }

.set-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.set-n { flex: none; width: 20px; font-family: var(--font-num); font-size: 12px; color: var(--text-faint); }
.num-input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 8px; color: var(--text);
  font-family: var(--font-num); font-size: 15px; text-align: center;
}
.num-input:focus { outline: none; border-color: var(--red); }
.set-field { flex: 1 1 0; display: flex; align-items: center; gap: 5px; min-width: 0; }
.set-field small { flex: none; font-size: 10.5px; color: var(--text-faint); }
.set-ok {
  flex: none; width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-faint); font-size: 14px;
}
.set-ok.is-on { background: var(--red); border-color: var(--red); color: #fff; }

.xrow-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.xrow-actions button {
  flex: 1 1 auto; padding: 9px 10px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text-dim); font-family: var(--font); font-size: 12.5px;
}
.xrow-actions button:active { background: var(--line); }
.xrow-actions .is-primary { background: var(--red); border-color: var(--red); color: #fff; }

.dir-row { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.dir-label { font-size: 11px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.dir-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.dir-btns button {
  padding: 8px 2px; border-radius: 7px; cursor: pointer; line-height: 1.25;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text-dim); font-family: var(--font); font-size: 10.5px;
}
.dir-btns button.is-on { background: var(--gold); border-color: var(--gold); color: #0A0A0A; font-weight: 700; }
.dir-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 8px; line-height: 1.5; }

/* ------------------------------------------------------- treadmill display */

.runner-body.cardio {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  text-align: center; padding: 18px 14px;
}
.cardio-phase {
  font-size: 12px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 12px;
}
.cardio-phase.work    { color: var(--red); }
.cardio-phase.rest    { color: var(--gold); }
.cardio-phase.done    { color: var(--red); }

.cardio-numbers { display: flex; gap: 22px; align-items: flex-end; justify-content: center; }
.cardio-metric { display: flex; flex-direction: column; align-items: center; }
.cardio-value {
  font-family: var(--font-num); font-weight: 700; letter-spacing: -3px; line-height: 0.92;
  font-size: clamp(58px, 21vw, 108px);
}
.cardio-metric:first-child .cardio-value { color: var(--red); }
.cardio-metric:last-child  .cardio-value { color: var(--gold); }
.cardio-unit { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); margin-top: 8px; }

.cardio-clock {
  font-family: var(--font-num); font-size: clamp(38px, 13vw, 60px); font-weight: 600;
  letter-spacing: -2px; margin-top: 18px;
}
.cardio-bar { width: 100%; max-width: 420px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 12px; }
.cardio-fill { height: 100%; width: 0; background: var(--red); border-radius: 3px; transition: width 0.25s linear; }
.runner-body.cardio.is-rest .cardio-fill { background: var(--gold); }

.cardio-next {
  margin-top: 16px; font-size: 14px; color: var(--text-dim); line-height: 1.5;
  min-height: 42px; max-width: 420px;
}
.cardio-next b { color: var(--text); font-family: var(--font-num); font-size: 17px; }

.cardio-actions { width: 100%; max-width: 420px; margin-top: 6px; }
.cardio-actions .primary-btn.big { padding: 18px; font-size: 17px; }

.cardio-track {
  display: flex; flex-wrap: wrap; gap: 3px; justify-content: center;
  margin-top: 22px; max-width: 420px;
}
.ctick { width: 13px; height: 13px; border-radius: 3px; background: var(--line); }
.ctick.clean   { background: var(--red); }
.ctick.rested  { background: var(--gold); }
.ctick.current { box-shadow: 0 0 0 2px var(--red-glow); }

/* ------------------------------------------------------------ bottom sheet */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop[hidden] { display: none !important; }
.sheet {
  width: 100%; max-width: 560px; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding-bottom: var(--safe-bottom);
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
  padding: 14px 14px 10px; border-bottom: 1px solid var(--line-soft);
}
.sheet-head .panel-title { margin: 0; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px; }
.sheet-body .field-label:first-child { margin-top: 0; }

.pick-search { margin-bottom: 12px; }
.pick-group { font-size: 10.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-faint); margin: 14px 0 6px; }
.pick-group:first-child { margin-top: 0; }
.pick-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 11px 12px; margin-bottom: 6px; cursor: pointer; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font); font-size: 14px;
}
.pick-item:active { border-color: var(--red); }
.pick-item small { color: var(--text-faint); font-size: 11px; flex: none; }

.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1 1 0; min-width: 0; }

/* ------------------------------------------------- desktop / wide screens */

@media (min-width: 760px) {
  #main { max-width: 720px; margin: 0 auto; padding: 20px 20px 32px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .runner-body { max-width: 720px; margin: 0 auto; width: 100%; }
  .runner-top, .runner-foot { padding-left: 20px; padding-right: 20px; }
  .sheet { border-radius: var(--radius); margin-bottom: 5vh; }
  .sheet-backdrop { align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  .cardio-fill { transition: none; }
}

/* Placeholders must read as hints, not as values already entered — the weight
   field is prefilled with the target, the reps field only suggests it. */
.num-input::placeholder { color: var(--text-faint); opacity: 1; }

/* A button sitting beside a panel title should hug its label, not stretch to
   the full width the base .ghost-btn rule gives it. */
.chart-head .ghost-btn.sm { width: auto; flex: none; margin-top: 0; padding: 8px 14px; font-size: 12.5px; }

/* ------------------------------------------------------- tap behaviour

   Text inside a control is selectable by default, so a tap held a fraction
   too long — which is most taps, mid-set, with sweaty hands — selects the
   label instead of pressing the button. Everything interactive opts out, and
   the grey iOS tap flash goes with it. Inputs stay selectable, obviously. */

button, .tab, .start-card, .pick-item, .prow-main, .xrow-head, .lrow, .wd,
.entry-list li.editable, .seg button, .dir-btns button, .cardio-actions button {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

input, textarea, select { -webkit-user-select: auto; user-select: auto; }

/* Comfortable thumb targets on the controls used mid-set. */
.set-ok, .prow-move button, .prow-del { touch-action: manipulation; }
