/*
 * training-log design system. See "Design" in docs/PLAN.md.
 * No web fonts and no external requests: everything is served from static/.
 */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;

  --bg: #e4e6eb;              /* page: clearly darker than the white cards */
  --surface: #ffffff;         /* cards */
  --surface-2: #f6f7f9;       /* chips, table headers, inset areas */
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #6f6e6a;           /* muted text: 5.1:1 on white cards ONLY; on the gray page use --ink-2 */
  --line: #e7e8ec;            /* hairlines inside a card */
  --card-border: #c9cdd6;     /* the visible edge of a card */
  --line-strong: #cfd3db;

  --blue: #2a78d6;
  --blue-bg: #f2f7ff;
  --gray-series: #8a8985;    /* the second series next to blue: planned distance, averages */
  --seg: #eceef2;           /* the track of a group of toggle buttons */
  --good: #006300;
  --good-bg: #e8f5ea;
  --bad: #b3261e;
  --bad-bg: #fdecea;
  --warn: #7a4a00;            /* amber text on --warn-bg: 6.7:1 (changes waiting to be sent) */
  --warn-bg: #fff3d6;

  --tier-2: #dde1e8;          /* plan editor: the exercise header band (darker than --surface-2, lighter than the black activity band) */

  --shadow: 0 1px 2px rgba(16, 24, 40, .07), 0 8px 20px rgba(16, 24, 40, .08);
  --radius: 18px;
  --gap: 20px;

  /* plan editor: header heights, and the save bar's dock (see "Plan: the editor") */
  --act-head-h: 56px;         /* the activity header is pinned, so scroll-padding needs its height */
  --ent-head-h: 48px;
  --dock-h: 108px;            /* height of the save bar's dock, and so of the room reserved under the last card */
  --dock-top: 108px;          /* distance from the bottom of the window to the top of the dock */
  --nav-h: 65px;              /* the phone's bottom navigation: 6 + 52 + 6 padding, and its 1px border */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
svg.ic {
  width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.muted { color: var(--ink-3); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- app shell: sidebar + content ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.logo {
  width: 32px; height: 32px; border-radius: 10px; background: var(--ink); color: #fff;
  display: grid; place-items: center; flex: none;
}
.logo svg { width: 18px; height: 18px; }
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--ink-2); font-weight: 500; min-height: 44px;
}
.nav-item:hover { background: rgba(11, 11, 11, .06); }
.nav-item.active { background: #d3d7de; color: var(--ink); }
.nav-item.push { margin-top: auto; }

.user {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--card-border); box-shadow: var(--shadow);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #e6e8ec; flex: none;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.user b { display: block; font-weight: 600; font-size: 13.5px; line-height: 1.2; overflow-wrap: anywhere; }
.user-links { display: flex; flex-wrap: wrap; gap: 0 10px; color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.user-links a, .linklike { color: var(--ink-2); text-decoration: underline; }
.linklike { background: none; border: 0; padding: 0; font-size: inherit; }

.main { padding: calc(24px + env(safe-area-inset-top)) 24px 32px 0; min-width: 0; }
.panel { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

.page-head { padding: 2px 2px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.page-head .sub { color: var(--ink-2); font-size: 13.5px; }  /* sits on the gray page */

/* account menu: shown on phones, where the sidebar user card is hidden */
.account-menu { display: none; position: relative; }
.account-menu summary { list-style: none; cursor: pointer; border-radius: 50%; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu .avatar { width: 40px; height: 40px; border: 1px solid var(--card-border); background: var(--surface); box-shadow: var(--shadow); }
.account-menu .menu {
  position: absolute; right: 0; top: 48px; z-index: 30; min-width: 210px; padding: 8px;
  background: var(--surface); border: 1px solid var(--card-border); border-radius: 14px; box-shadow: var(--shadow);
}
.account-menu .menu p { padding: 8px 10px; color: var(--ink-3); font-size: 13px; overflow-wrap: anywhere; }
.account-menu .menu a, .account-menu .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 10px; border: 0;
  background: none; border-radius: 10px; text-align: left; font-weight: 500;
}
.account-menu .menu a:hover, .account-menu .menu button:hover { background: var(--surface-2); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; position: relative; min-width: 0;
}
.card h2 { font-size: 16px; font-weight: 600; }
.card-narrow { max-width: 520px; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 28px 24px; }
.empty .chip-icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--ink-2); margin-bottom: 4px;
}
.empty p { color: var(--ink-2); max-width: 46ch; margin-bottom: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px;
  padding: 0 20px; min-height: 44px; font-weight: 600; font-size: 14.5px; border: 1px solid transparent;
  white-space: nowrap;
}
.btn svg.ic { width: 18px; height: 18px; }
.btn-black { background: var(--ink); color: #fff; }
.btn-black:hover { background: #26262a; }
.btn-ghost { background: var(--surface); border-color: var(--card-border); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; min-height: 50px; font-size: 16px; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field input[type="text"], .field input[type="password"], .field input[type="email"] {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--card-border); border-radius: 14px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; /* 16px stops iOS zooming in */
}
.field input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.field select {
  width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid var(--card-border); border-radius: 14px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}
.field select:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.field .help { color: var(--ink-3); font-size: 13px; margin-top: 6px; }
.field .help ul { margin: 0; padding-left: 18px; }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--bad); font-size: 13.5px; font-weight: 500; }
.alert {
  background: var(--bad-bg); color: var(--bad); border: 1px solid #f1c5c1; border-radius: 12px;
  padding: 10px 14px; font-size: 14px; font-weight: 500;
}
.alert .errorlist { margin: 0; }
.alert.ok { background: var(--good-bg); color: var(--good); border-color: #bfdfc4; }

/* ---------- login / standalone pages ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--gap); }
.auth .brand { justify-content: center; padding: 0; }
.auth .card { padding: 26px 24px; display: flex; flex-direction: column; gap: 18px; }
.auth h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.auth .sub { color: var(--ink-3); margin-top: 4px; }

/* ---------- pills and chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-2); white-space: nowrap;
}
.pill svg.ic { width: 14px; height: 14px; stroke-width: 2; }
.pill.done { color: var(--good); background: var(--good-bg); border-color: transparent; }
.pill.warn { color: #7a4b00; background: #fff3dc; border-color: transparent; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px 4px 9px; border-radius: 999px; min-height: 30px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; color: var(--ink);
}
.chip svg.ic { width: 15px; height: 15px; color: var(--ink-2); }
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--ink-2); font-weight: 600; width: fit-content; }
.back-link svg.ic { width: 18px; height: 18px; }

/* ---------- History: filters, list, pagination ---------- */
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.filters label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.filters select, .filters input[type="date"] {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--card-border); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}
.filters select:focus, .filters input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.filters .actions { display: flex; gap: 8px; }
.filters .alert { grid-column: 1 / -1; }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; font-weight: 600; }
.card-head .muted { font-size: 13px; }
.card .more { color: var(--ink-3); font-size: 13px; margin-top: 12px; }
.tbl-wrap { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
table.sessions { width: 100%; border-collapse: collapse; font-size: 14px; }
table.sessions thead th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--ink-3); background: var(--surface-2);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.sessions tbody tr { position: relative; }
table.sessions tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.sessions tbody tr:last-child td { border-bottom: 0; }
table.sessions tbody tr:hover td { background: #fafbfc; }
table.sessions td[data-k="date"] { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* the whole row is one link target */
table.sessions td[data-k="date"] a { font-weight: 600; }
table.sessions td[data-k="date"] a::after { content: ""; position: absolute; inset: 0; }
table.sessions .stype { font-weight: 600; }
table.sessions .acts-txt { color: var(--ink-2); font-size: 13.5px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pagination .disabled { opacity: .45; pointer-events: none; }
.pagination .muted { color: var(--ink-2); font-size: 14px; }

/* ---------- Session detail ---------- */
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.note { color: var(--ink-2); max-width: 70ch; }
.note-gap-lg { margin-top: 14px; }
.note-gap-md { margin-top: 12px; }
.note-gap-sm { margin-top: 8px; }
.icon-sprite { position: absolute; }
.activity-head { display: flex; align-items: center; gap: 12px; }
.activity-head .chip-icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--ink-2); flex: none;
}
.activity-head h2 { font-size: 17px; }
.activity-head .grow { flex: 1; min-width: 0; }
.activity-head .sub { color: var(--ink-3); font-size: 13px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px 12px; margin: 16px 0 0; }
.metric dt { font-size: 12.5px; color: var(--ink-3); }
.metric dd { margin: 2px 0 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.activity .links { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 12px; }
.activity .links a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: underline; }
.activity .links svg.ic { width: 15px; height: 15px; }
.entry { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.entry-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.entry-head h3 { font-size: 16px; font-weight: 600; margin-right: 4px; }
.entry-head .entry-delete { margin-left: auto; }
.session-facts .sub { color: var(--ink-3); font-size: 13px; }
table.setlist { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14.5px; table-layout: fixed; }
table.setlist th:nth-child(1) { width: 36%; }
table.setlist th:nth-child(2) { width: 26%; }
table.setlist th:nth-child(3) { width: 30%; }
table.setlist th:nth-child(4) { width: 8%; }
table.setlist td:nth-child(2), table.setlist td:nth-child(3) { white-space: nowrap; }
table.setlist th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--ink-3); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.setlist td { padding: 9px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.setlist tr:last-child td { border-bottom: 0; }
table.setlist td:last-child, table.setlist th:last-child { text-align: right; }
table.setlist .vchip { margin-left: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
table.setlist .actual { font-weight: 600; }
table.setlist .corr { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-left: 6px; }
table.setlist .corr svg.ic { width: 12px; height: 12px; stroke-width: 2.4; }
table.setlist tr.todo .actual { color: var(--ink-3); font-weight: 500; }
table.setlist tr.skipped .actual { color: var(--ink-3); font-weight: 500; }
table.setlist .skip-label { display: inline-flex; align-items: center; gap: 5px; }
table.setlist .skip-label svg.ic { width: 14px; height: 14px; }
table.setlist svg.tick { width: 18px; height: 18px; color: var(--good); stroke-width: 2.4; }

/* ---------- messages ---------- */
.messages { display: flex; flex-direction: column; gap: 10px; }
.alert.info { background: var(--surface); color: var(--ink-2); border-color: var(--card-border); box-shadow: var(--shadow); }
.btn-small { min-height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn-small svg.ic { width: 16px; height: 16px; }
table.sessions td[data-k="actions"] { text-align: right; white-space: nowrap; width: 1%; }
table.sessions td[data-k="actions"] .btn { position: relative; z-index: 2; }   /* above the whole-row link */
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- form controls shared by the plan pages ---------- */
.input {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--card-border); border-radius: 12px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}
textarea.input { padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.4; }
.input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.has-error .input { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: 13px; font-weight: 500; margin-top: 4px; }
.field > label, .plan-editor .field > label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

/* ---------- Plan: step 1 ---------- */
.plan-start { display: flex; flex-direction: column; gap: var(--gap); }
.type-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; border: 0; padding: 0; margin: 0; }
.type-card { position: relative; display: block; cursor: pointer; }
.type-card input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.type-card-body {
  display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 16px; background: var(--surface);
  border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.type-card-body b { font-size: 16px; }
.type-card-body .muted { font-size: 13px; }
.type-card-body .acts-txt { color: var(--ink-2); font-size: 13.5px; }
.type-card:hover .type-card-body { background: var(--surface-2); }
.type-card input:checked + .type-card-body { border: 2px solid var(--blue); background: var(--blue-bg); padding: 15px; }
.type-card input:focus-visible + .type-card-body { outline: 3px solid var(--blue); outline-offset: 2px; }
.date-card { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.date-card .field { flex: 1 1 200px; max-width: 280px; }

/* ---------- Plan: the editor ---------- */
.plan-editor { display: flex; flex-direction: column; gap: var(--gap); }
.pe-info { display: flex; gap: 10px; align-items: flex-start; }
.pe-info svg.ic { margin-top: 2px; color: var(--ink-3); }
.pe-info a { text-decoration: underline; font-weight: 600; }
.pe-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.pe-grid .wide { grid-column: 1 / -1; }
.pe-row { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.pe-row .grow { flex: 1 1 200px; min-width: 0; }
.pe-tools { display: inline-flex; gap: 6px; }

/* The editor has three levels, and each one looks different so you always know where you are:
     activity  a white card with a black header band that stays pinned to the top while you scroll through it
     exercise  a bordered block inside it with a gray-blue header band and a numbered badge
     set       plain white rows inside the exercise, divided by hairlines
   (approved in previews/plan_editor.html; see "As built (plan editor design)" in docs/PLAN.md) */
.card.pe-activity { padding: 0; }
.pe-activity-head {
  position: sticky; top: env(safe-area-inset-top); z-index: 4; height: var(--act-head-h);
  display: flex; align-items: center; gap: 12px; padding: 0 14px 0 12px;
  background: var(--ink); color: #fff; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}
.pe-activity-chip { width: 36px; height: 36px; border-radius: 11px; background: rgba(255, 255, 255, .14); display: grid; place-items: center; flex: none; }
.pe-activity-text { min-width: 0; flex: 1; line-height: 1.2; }
.pe-kicker { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255, 255, 255, .74); }
.pe-activity-head .pe-activity-name {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pe-activity-name .t { font-weight: 500; color: rgba(255, 255, 255, .78); }
.pe-meta {
  flex: none; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: rgba(255, 255, 255, .14); color: #fff; white-space: nowrap;
}
.pe-activity-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.pe-activity-body > .pe-add { margin-top: 0; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--card-border); background: var(--surface);
  display: inline-grid; place-items: center; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover:not(:disabled) { color: var(--bad); background: var(--bad-bg); }
.icon-btn svg.ic { width: 18px; height: 18px; }
.pe-entry { border: 1px solid var(--card-border); border-radius: 14px; background: var(--surface); }
.pe-entry-head {
  display: flex; align-items: center; gap: 10px; min-height: var(--ent-head-h); padding: 6px 12px;
  background: var(--tier-2); border-bottom: 1px solid var(--card-border); border-radius: 13px 13px 0 0;
}
.pe-entry-num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.pe-entry-head .pe-entry-name {
  flex: 1; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pe-entry-name.unset { font-weight: 500; color: var(--ink-2); }
.pe-entry-meta {
  flex: none; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--card-border); color: var(--ink-2); white-space: nowrap;
}
.pe-entry-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }

.pe-sets-title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.pe-set-grid {
  display: grid; grid-template-columns: 32px minmax(120px, 1.2fr) minmax(96px, .9fr) 172px 64px 178px; gap: 8px; align-items: center;
}
.pe-set-labels { padding: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.pe-set { padding: 8px 0; border-top: 1px solid var(--line); }
.pe-set .num {
  width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line-strong); color: var(--ink-2);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; justify-self: center;
}
.pe-set .checkbox { margin-left: 4px; }
.pe-set .pe-tools { justify-content: flex-end; }
.pe-set.has-error { background: var(--bad-bg); box-shadow: inset 3px 0 0 var(--bad); padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.pe-sets-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 0; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper input { flex: none; width: 72px; min-height: 44px; text-align: center; border: 1px solid var(--card-border); border-radius: 12px; font: inherit; font-size: 17px; font-weight: 600; background: var(--surface); color: var(--ink); }
.stepper input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
/* Inside a .field the generic ".field input[type=text]" rule (more specific than ".stepper input") would stretch the
   number box to 100% and push the + button out of the card, and would lose the bold 17px number. */
.field .stepper input[type="text"] {
  width: 72px; min-height: 44px; padding: 0; border-radius: 12px; font-size: 17px; font-weight: 600; text-align: center;
}
.stepper .step-btn {
  flex: none; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--card-border); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink);
}
.stepper .step-btn:active { background: var(--surface-2); }
.stepper .step-btn svg.ic { width: 20px; height: 20px; stroke-width: 2.2; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); min-height: 44px; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--ink); }
.pe-notes summary {
  cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); min-height: 36px;
  display: flex; align-items: center; gap: 8px; list-style: none;
}
.pe-notes summary::-webkit-details-marker { display: none; }
.pe-notes summary::before {
  content: "+"; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  display: grid; place-items: center; font-size: 15px; line-height: 1; color: var(--ink-2);
}
.pe-notes[open] summary::before { content: "\2212"; }
.pe-notes[open] summary { margin-bottom: 8px; }
.pe-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.pe-add .label { color: var(--ink-2); font-size: 14px; font-weight: 600; margin-right: 4px; }
.pe-errors ul { margin: 6px 0 0; padding-left: 20px; }

/* The save bar is docked (fixed) above the bottom navigation on a phone and at the bottom of the content column
   elsewhere. Room is reserved under the last card (.pe-room), and focused fields scroll into the clear area between
   the pinned activity header and the dock, so the bar never covers what you are working on. */
html:has(.plan-editor) {
  scroll-padding-top: calc(var(--act-head-h) + 12px);
  scroll-padding-bottom: calc(var(--dock-top) + 12px);
}
.pe-room { height: calc(var(--dock-h) - var(--gap)); }
.pe-dock {
  position: fixed; z-index: 15; left: 232px; right: 0; bottom: 0; padding: 28px 24px 12px 0;
  background: linear-gradient(to bottom, rgba(228, 230, 235, 0), var(--bg) 55%);
  pointer-events: none;                         /* only the bar itself takes clicks */
}
.save-bar {
  pointer-events: auto; display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 12px;
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.save-bar .status {
  margin-right: auto; display: inline-flex; align-items: center; gap: 8px; color: var(--warn); background: var(--warn-bg);
  padding: 4px 12px 4px 10px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
}
.save-bar .status[hidden] { display: none; }
.save-bar .status svg.ic { width: 16px; height: 16px; }

/* ---------- Plan editor: tablet and phone ---------- */
@media (max-width: 1099px) and (min-width: 720px) {
  .pe-dock { left: 76px; }
}
/* below 1100px a set is two lines (one line does not fit next to the icon rail) */
@media (max-width: 1099px) {
  .pe-set-labels { display: none; }
  .pe-set-grid { grid-template-columns: 32px 1fr 1fr; }
  .pe-set { padding: 12px 0; }
  .pe-set .stepper-cell { grid-column: 1 / 3; }
  .pe-set .checkbox { grid-column: 3; }
  .pe-set .pe-tools { grid-column: 1 / -1; }
}

/* ---------- watch data form and the Body page ---------- */
.activity-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.watch-form, .body-form { display: flex; flex-direction: column; gap: 16px; }
.watch-form .intro, .body-form .intro { color: var(--ink-2); max-width: 60ch; }
.watch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 14px; align-items: start; }
.watch-grid .wide { grid-column: 1 / -1; }
.watch-grid > p.help, .body-form > p.help { color: var(--ink-2); font-size: 13px; }
.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit .input { flex: 1 1 0; min-width: 0; }
.input-unit .unit { flex: none; min-width: 34px; color: var(--ink-2); font-size: 14px; font-weight: 600; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field legend { padding: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.duration-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 12px; }
.has-error .unit { color: var(--bad); }
.field .errorlist { margin-top: 6px; }
.field label.checkbox { display: inline-flex; margin-bottom: 0; font-size: 14px; color: var(--ink); }
.watch-grid .wide textarea { max-width: 70ch; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.body-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 14px; align-items: start; }
.body-grid.single { grid-template-columns: 1fr; }
.body-grid .actions { padding-top: 25px; }
table.metrics-list td[data-k="actions"] { width: 1%; white-space: nowrap; }
table.metrics-list tbody tr { position: static; }
table.metrics-list td[data-k="date"] { font-weight: 600; }

/* ---------- Progress: filters, charts, tables ---------- */
.pr-tabs {
  display: inline-flex; align-self: flex-start; background: var(--seg); border-radius: 999px; padding: 4px; gap: 2px;
}
.pr-tabs a {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; min-height: 44px;
  border-radius: 999px; font-weight: 600; font-size: 14.5px; color: var(--ink-2);
}
.pr-tabs a:hover { color: var(--ink); }
.pr-tabs a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, .06); }
.pr-tabs svg.ic { width: 18px; height: 18px; }
.pr-root { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
/* the hidden attribute must win over the display rules of the pieces below */
.pr-root [hidden] { display: none !important; }
.pr-stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.pr-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.inline-link { text-decoration: underline; text-underline-offset: 2px; }

.pr-filters { display: flex; align-items: flex-end; gap: 16px 28px; flex-wrap: wrap; padding: 16px 20px; }
.pr-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pr-cap { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.pr-select {
  appearance: none; -webkit-appearance: none; min-height: 48px; min-width: 260px; max-width: 100%; padding: 0 44px 0 16px;
  font: inherit; font-size: 16px; font-weight: 500; color: var(--ink); background-color: var(--surface);
  border: 1px solid var(--card-border); border-radius: 14px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2352514e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
}
.pr-select:hover { background-color: var(--surface-2); }
.pr-select:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }

.seg { display: inline-flex; background: var(--seg); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; }
.seg button {
  border: 0; background: transparent; padding: 0 14px; min-height: 38px; border-radius: 999px; font-size: 13.5px;
  font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, .06); }

.ch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ch-head h2 { font-size: 15px; font-weight: 600; }
.ch-sub { color: var(--ink-3); font-size: 13px; }
.ch-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ch-tools .icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--ink-2);
}
.ch-tools .icon-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.ch-summary { display: flex; align-items: baseline; gap: 6px 10px; flex-wrap: wrap; margin-bottom: 6px; }
.ch-summaries { display: flex; gap: 6px 36px; flex-wrap: wrap; margin-bottom: 8px; }
.ch-big { font-size: 28px; font-weight: 600; letter-spacing: -0.025em; font-variant-numeric: proportional-nums; }
.ch-big small { font-size: 14px; color: var(--ink-3); font-weight: 500; margin-left: 3px; letter-spacing: 0; }
.ch-what { color: var(--ink-3); font-size: 13px; }
.ch-vs { color: var(--ink-3); font-size: 12.5px; }
.ch-delta {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px 2px 6px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
}
.ch-delta svg.ic { width: 13px; height: 13px; stroke-width: 2.25; }
.ch-delta.good { color: var(--good); background: var(--good-bg); }
.ch-delta.bad { color: var(--bad); background: var(--bad-bg); }
.ch-delta.flat { color: var(--ink-2); background: var(--surface-2); }

.ch-legend { display: flex; gap: 6px 18px; flex-wrap: wrap; color: var(--ink-2); font-size: 13px; margin: 2px 0; }
.ch-legend span { display: inline-flex; align-items: center; gap: 7px; }
.ch-legend svg { width: 18px; height: 14px; flex: none; overflow: visible; }
.ch-insight { color: var(--ink-2); font-size: 13.5px; margin-top: 10px; display: flex; gap: 8px; align-items: flex-start; }
.ch-insight svg.ic { width: 16px; height: 16px; margin-top: 2px; color: var(--ink-3); }
.ch-panel-title { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 10px 0 0; }
.ch-wrap + .ch-panel-title { margin-top: 20px; }
.ch-panel-title .muted { font-weight: 500; }
.ch-inline-empty {
  background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 14px 16px;
  color: var(--ink-2); font-size: 14px; margin-top: 8px;
}

.ch-wrap { position: relative; }
.chart { width: 100%; border-radius: 10px; }
.chart:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
.chart svg { display: block; overflow: visible; }
.chart text { font-family: var(--font); }
.chart .ax { fill: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .bar { transition: opacity .12s; }
.chart.dim .bar:not(.on) { opacity: .45; }

.tt {
  position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 8px 10px; box-shadow: 0 8px 24px rgba(11, 11, 11, .10); font-size: 12.5px;
  min-width: 150px; opacity: 0; transition: opacity .1s;
}
.tt.show { opacity: 1; }
.tt .tt-title { color: var(--ink-3); margin-bottom: 4px; }
.tt .row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.tt .row .nm { color: var(--ink-2); }
.tt .row b { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.tt .row.first b { font-size: 15px; }

.tableview { border: 1px solid var(--line); border-radius: 14px; max-height: 380px; overflow: auto; }
.tableview[hidden], .hide-in-table { display: none !important; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--ink-2);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 9px 14px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data td:not(:first-child), table.data th:not(:first-child) { text-align: right; }
table.data td.none { color: var(--ink-3); }

.ch-empty {
  background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 14px; padding: 20px;
  display: flex; gap: 14px; align-items: flex-start;
}
.ch-empty .chip-icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--ink-2); flex: none;
}
.ch-empty h3 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.ch-empty p { color: var(--ink-2); font-size: 14px; }
.ch-empty-table { margin-top: 14px; }

/* ---------- Dashboard ---------- */
.db-root { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
/* the hidden attribute must win over the display rules of the pieces below */
.db-root [hidden] { display: none !important; }
.db-label { color: var(--ink-2); font-size: 14px; }

.db-next {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; overflow: hidden;
  padding: 22px 24px;
}
.db-next::before {
  content: ""; position: absolute; right: -60px; top: -90px; width: 320px; height: 320px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(122, 90, 240, .16), rgba(76, 201, 240, .10) 55%, transparent 75%);
}
.db-next > * { position: relative; }
.db-next h2 { font-size: 30px; font-weight: 600; letter-spacing: -0.025em; margin: 2px 0 12px; }
.db-when { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--ink-2); font-size: 14px; margin-bottom: 14px; }
.db-when svg.ic { width: 16px; height: 16px; }
.db-acts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.db-acts li {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2);
}
.db-acts li b { color: var(--ink); font-weight: 600; }
.db-acts li.skipped { color: var(--ink-3); }
.db-acts svg.ic { width: 16px; height: 16px; }
.db-cta { display: flex; gap: 10px; flex-wrap: wrap; }

.db-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.db-stat { padding: 18px 20px 16px; overflow: hidden; }
.db-stat::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 55%; pointer-events: none;
  background-image: radial-gradient(circle, rgba(11, 11, 11, .10) 1px, transparent 1.3px); background-size: 11px 11px;
  -webkit-mask-image: linear-gradient(to top, #000, transparent); mask-image: linear-gradient(to top, #000, transparent);
}
.db-stat > * { position: relative; z-index: 1; }
.db-stat .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-height: 42px; }
.db-stat .glyph {
  width: 30px; height: 30px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--ink-2); flex: none;
}
.db-stat .glyph svg.ic { width: 16px; height: 16px; }
.db-stat .value { font-size: 36px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; margin: 14px 0 12px; }
.db-stat .value small { font-size: 15px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-left: 4px; }
.db-stat .value .none { color: var(--ink-3); }
.db-stat .foot { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; }

.db-charts { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: var(--gap); }
.db-scope { margin-top: 12px; }
.tbl-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tbl-head h2 { font-size: 15px; font-weight: 600; }
table.sessions .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.sessions .none { color: var(--ink-3); }
table.sessions.with-totals .stype { white-space: nowrap; }   /* "Ride day" stays on one line; the phone cards wrap it again */

/* a key in a tooltip row: a short line in the series' color */
.tt .key { width: 12px; height: 0; border-top: 2px solid; border-radius: 2px; display: inline-block; margin-right: 7px; vertical-align: middle; }
.tt .key.cur { border-color: var(--blue); }
.tt .key.prev { border-color: var(--gray-series); }
.chart .ax-name { fill: var(--ink-2); font-size: 13px; font-weight: 600; }
.chart .hit { fill: transparent; }

@media (max-width: 1099px) {
  .db-charts { grid-template-columns: 1fr; }
  .db-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- tablet: icon rail ---------- */
@media (max-width: 1099px) and (min-width: 720px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  .brand-name, .nav-item span { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .sidebar { align-items: center; padding: 20px 10px; }
  .brand { padding: 0; }
  /* the rail has no room for the user card, so the header menu takes over */
  .user { display: none; }
  .account-menu { display: block; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .actions { grid-column: 1 / -1; }
}

/* ---------- phone: bottom navigation ---------- */
@media (max-width: 719px) {
  :root {
    --gap: 18px;
    --act-head-h: 52px; --ent-head-h: 44px;
    --dock-h: 124px; --dock-top: calc(124px + var(--nav-h) + env(safe-area-inset-bottom));
  }
  .app { display: block; }
  .main { padding: calc(14px + env(safe-area-inset-top)) 14px calc(92px + env(safe-area-inset-bottom)); }
  .sidebar {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; top: auto; height: auto; flex-direction: row;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .96);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--card-border); box-shadow: 0 -4px 16px rgba(16, 24, 40, .06); gap: 0;
  }
  .sidebar .brand, .sidebar .user { display: none; }
  .nav { flex-direction: row; justify-content: space-between; width: 100%; gap: 0; }
  .nav-item {
    flex: 1; flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 11px; min-height: 52px;
    justify-content: center; border-radius: 12px;
  }
  .nav-item.push { margin-top: 0; }
  .nav-item.active { background: transparent; color: var(--ink); font-weight: 700; }
  .nav-item.active svg.ic { stroke-width: 2.4; }
  .account-menu { display: block; }
  .page-head .btn { display: none; }
  .card { padding: 16px; }

  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .filters .actions { grid-column: 1 / -1; }
  .filters .actions .btn { flex: 1; min-height: 48px; }
  table.setlist .vchip { display: block; margin: 3px 0 0; width: fit-content; }
  table.setlist .corr { display: flex; margin: 2px 0 0; }
  .pagination .btn { min-height: 48px; }

  /* the sessions table becomes stacked cards, as in the approved preview */
  .tbl-wrap { border: 0; border-radius: 0; overflow: visible; }
  table.sessions, table.sessions tbody, table.sessions tr, table.sessions td { display: block; }
  table.sessions thead { display: none; }
  table.sessions tbody tr {
    display: flex; flex-wrap: wrap; gap: 4px 14px; border: 1px solid var(--card-border); background: var(--surface-2);
    border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
  }
  table.sessions tbody td { padding: 0; border: 0; }
  table.sessions tbody tr:hover td { background: transparent; }
  td[data-k="date"], td[data-k="session"] { flex: 0 0 100%; padding-right: 96px; }
  td[data-k="date"] { color: var(--ink-3); font-size: 13px; }
  td[data-k="session"] { font-size: 16px; }
  td[data-k="acts"] { flex: 0 0 100%; }
  td[data-k="status"] { position: absolute; top: 12px; right: 14px; }
  td[data-k="time"], td[data-k="dist"], td[data-k="hr"] { flex: 0 0 auto; color: var(--ink-2); font-size: 13px; margin-top: 4px; }
  .db-next { padding: 18px; }
  .db-next h2 { font-size: 26px; }
  .db-cta { width: 100%; }
  .db-cta .btn { flex: 1; min-height: 50px; }
  .db-stats { gap: 14px; }
  .db-stat { padding: 14px; }
  .db-stat .value { font-size: 30px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  td[data-k="actions"] { flex: 0 0 100%; text-align: left; margin-top: 6px; width: auto; }
  .row-actions { justify-content: flex-start; }
  .row-actions .btn { flex: 1; min-height: 44px; }
  .type-cards { grid-template-columns: 1fr; }
  .activity-actions .btn { min-height: 44px; }
  .watch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
  .input-unit { gap: 6px; }
  .input-unit .unit { min-width: 0; font-size: 13px; }
  .duration-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .form-actions .btn { flex: 1 1 140px; min-height: 50px; }
  .body-grid { grid-template-columns: 1fr 1fr; gap: 14px 10px; }
  .body-grid > .field:first-child { grid-column: 1 / -1; }
  .body-grid.single { grid-template-columns: 1fr; }
  .body-grid .actions { grid-column: 1 / -1; padding-top: 0; }
  .body-grid .actions .btn { width: 100%; min-height: 50px; }
  table.metrics-list tbody td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); font-size: 13px; }
  table.metrics-list td[data-k="date"] { flex: 0 0 100%; padding-right: 0; color: var(--ink); font-size: 16px; }
  .date-card .field { max-width: none; }
  .date-card .btn { width: 100%; min-height: 50px; }
  .pe-grid { grid-template-columns: 1fr; }
  .plan-editor { gap: 14px; }
  .pe-activity-head { padding: 0 10px; gap: 10px; border-radius: 17px 17px 0 0; }
  .pe-activity-chip { width: 34px; height: 34px; }
  .pe-meta { display: none; }
  .pe-activity-body { padding: 14px; gap: 14px; }
  .pe-entry-head { padding: 6px 10px; }
  .pe-entry-body { padding: 12px; }
  .pe-row .grow { flex-basis: 100%; }
  .pe-row .pe-tools { margin-left: auto; }
  /* the dock sits right above the bottom navigation; the status gets its own line above Cancel and Save */
  .pe-dock { left: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 24px 14px 8px; }
  .save-bar { flex-wrap: wrap; padding: 10px; gap: 8px; }
  .save-bar .status { flex: 0 0 100%; margin-right: 0; background: none; padding: 0 4px; }
  .save-bar .btn { min-height: 48px; }
  .save-bar .btn-black { flex: 1; }
  .save-bar .btn-ghost { flex: 0 0 auto; }
  .pr-tabs { display: flex; width: 100%; }
  .pr-tabs a { flex: 1; padding: 0 6px; }
  .pr-tabs svg.ic { display: none; }
  .pr-filters { padding: 14px 16px; gap: 14px; }
  .pr-field { width: 100%; }
  .pr-select { width: 100%; min-width: 0; }
  .pr-field .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 8px; min-height: 44px; min-width: 44px; }
  #bars-card .ch-tools { width: 100%; flex-wrap: nowrap; }
  #bars-card .ch-tools .seg { flex: 1; }
  table.sessions.with-totals .stype { white-space: normal; }
  .ch-tools .icon-btn { width: 44px; height: 44px; }
  #ex-tools { width: 100%; flex-wrap: nowrap; }
  #ex-tools .seg { flex: 1; width: auto; }
  .ch-big { font-size: 24px; }
  .ch-empty { flex-direction: column; }
}

/* ---------- Settings ---------- */
.settings-form { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.settings-form .card > .help, .settings-form + .card .help { color: var(--ink-2); font-size: 13px; margin-top: 10px; }
.settings-form .body-grid + .help { margin-top: 12px; }
/* A locked box has to look locked: a gray fill and a dashed edge. `.field .input:disabled` is deliberately more
   specific than `.field input[type="text"]` above: a plain `.input:disabled` lost to it, which is why a locked box
   used to look editable. (-webkit-text-fill-color: Safari on iOS otherwise paints disabled text its own gray.) */
.input:disabled, .field .input:disabled, .field select:disabled {
  background: #e9ebf0; border: 1px dashed #aeb3bf; color: var(--ink-2); -webkit-text-fill-color: var(--ink-2);
  opacity: 1; cursor: not-allowed;
}
.settings-form .field:has(.input:disabled) > label { color: var(--ink-2); }
.locked-note { display: flex; align-items: flex-start; gap: 8px; }
.locked-note svg.ic { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.settings-form + .card .help, .card-narrow .btn + .help { margin-top: 10px; }
.card-narrow .help + .btn { margin-top: 16px; }

/* ---------- Exercises and session types (under Settings; the session type pages reuse these classes) ---------- */
.ex-list { list-style: none; margin: 0; padding: 0; }
.ex-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.ex-row:first-child { border-top: 0; padding-top: 4px; }
.ex-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ex-name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.ex-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.ex-use { color: var(--ink-2); font-size: 13.5px; }
.ex-use-line { display: grid; grid-template-columns: 4.8em minmax(0, 1fr); column-gap: 8px; }
.ex-use .nowrap { white-space: nowrap; }
.ex-use-label { font-weight: 600; color: var(--ink); }
.ex-row .row-actions { flex: none; flex-wrap: wrap; }
.ex-help { color: var(--ink-2); font-size: 13px; margin-top: 8px; }
.ex-notes { display: flex; flex-direction: column; gap: 8px; }
.ex-notes .help { color: var(--ink-2); font-size: 13px; max-width: 60ch; }
@media (max-width: 640px) {
  .ex-row { flex-direction: column; align-items: stretch; }
  .ex-row .row-actions { justify-content: flex-start; }
  .ex-row .row-actions .btn { flex: 1 1 90px; min-height: 44px; }
}
.ch-vs a { text-decoration: underline; text-underline-offset: 2px; }
