/* Rondo — "Topo". Base, the route components, and every non-player screen.
   Colours, radii and fonts come from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--navy); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--navy);
  color: var(--chalk);
  font: 17px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--chalk);
}

::selection { background: var(--chalk); color: var(--ink); }
:focus-visible { outline: 3px solid var(--chalk); outline-offset: 3px; }
* { scrollbar-color: var(--chalk-40) transparent; scrollbar-width: thin; }

input, textarea, select, [contenteditable] { user-select: text; -webkit-user-select: text; }
button, a, label, summary, [role="button"] { touch-action: manipulation; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1, h2 { text-wrap: balance; }
[hidden] { display: none !important; }

.cond { font-stretch: var(--cond); }
.num { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--chalk-72); }
.icon { width: 24px; height: 24px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Tape: the only label component ---------- */

.tag {
  display: inline-flex; align-items: center; flex: none;
  height: 30px; padding: 0 14px;
  font-stretch: var(--cond); font-weight: 800; font-size: 16px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink); background: var(--chalk);
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  white-space: nowrap;
}
.tag-work { background: var(--work); }
.tag-rest { background: var(--rest); }
.tag-dim { background: var(--navy-3); color: var(--chalk); }

/* ---------- Holds and the route line ---------- */

/* Hold diameter comes from --s (px, sized by duration); --k scales a whole route down on small screens. */
.route { --k: 1; display: flex; align-items: flex-start; }
.route .hold { width: calc(var(--s) * var(--k) * 1px); height: calc(var(--s) * var(--k) * 1px); font-size: calc(var(--s) * var(--k) * .36px); }
/* Every stop gets an equal share of the width, so holds sit at even intervals whatever the labels say.
   The connector is one dashed line drawn through the slots, behind the holds. */
.route .stop { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: 1 1 0; min-width: 0; }
.route .slot { position: relative; align-self: stretch; height: calc(104px * var(--k)); display: flex; align-items: center; justify-content: center; }
.route .slot::before { content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 1.5px); border-top: 3px dashed var(--chalk-55); }
.route .stop:first-child .slot::before { left: 50%; }
.route .stop:last-child .slot::before { right: 50%; }
.route .stop:only-child { flex: none; }
.route-solid .slot::before { border-top-style: solid; border-color: var(--chalk-82); }
.route .hold { position: relative; background: var(--navy); }
.route .hold-done { background: var(--chalk); }
.route .lbl { font-size: 15px; color: var(--chalk-82); text-align: center; text-wrap: balance; }
.hold {
  border-radius: 50%; border: 3px solid var(--chalk); flex: none;
  display: flex; align-items: center; justify-content: center;
  font-stretch: var(--cond); font-weight: 800; color: var(--chalk);
}
.hold-done { background: var(--chalk); color: var(--ink); }
.hold-now { border-color: var(--work); border-width: 5px; }
.hold-partial { background: linear-gradient(90deg, var(--chalk) 0 82%, transparent 82% 100%); color: var(--ink); }
.hold-todo { border-width: 2px; border-color: var(--chalk-55); }

/* ---------- App shell ---------- */

.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  min-height: 88px;
  padding: calc(env(safe-area-inset-top) + 16px) max(var(--gutter), env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left));
  background: var(--navy);
}
.topbar.has-back { padding-left: max(28px, env(safe-area-inset-left)); }
.topbar h1 { flex: 1; min-width: 0; font-size: 44px; line-height: 1; font-weight: 800; font-stretch: var(--cond); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.back { display: inline-flex; align-items: center; gap: 6px; height: var(--tap); padding: 0 12px; font-size: 18px; font-weight: 600; }
.back svg { width: 22px; height: 22px; }

.main {
  flex: 1; width: 100%; max-width: 1100px; margin: 0 auto;
  padding: 8px max(var(--gutter), env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
.main.no-tabs { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  background: var(--navy); border-top: 1px solid var(--chalk-14);
}
.tab {
  display: flex; align-items: center; min-height: var(--tap); padding: 14px 4px 10px;
  font-stretch: var(--cond); font-weight: 700; font-size: 19px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--chalk-72); border-bottom: 3px solid transparent;
}
.tab[aria-current="page"] { color: var(--chalk); border-bottom-color: var(--chalk); }

.wordmark { display: inline-flex; align-items: baseline; gap: 3px; font-weight: 800; letter-spacing: -.03em; font-size: 34px; }
.wordmark .dot { width: .26em; height: .26em; border-radius: 50%; background: var(--work); display: inline-block; }

/* ---------- Flash ---------- */

.flash { margin: 0 0 20px; padding: 14px 0; border-top: 1px solid var(--chalk-14); border-bottom: 1px solid var(--chalk-14); font-weight: 600; display: flex; gap: 12px; align-items: center; }
.flash.alert, .errors, .login .error, .p-error { font-weight: 700; }
.flash.alert::before, .errors::before, .login .error::before, .p-error::before {
  content: "!"; display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 10px; flex: none;
  border-radius: 50%; background: var(--chalk); color: var(--ink); font-weight: 900; font-size: 16px; vertical-align: middle;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); min-width: var(--tap); padding: 0 22px;
  border: 2px solid var(--chalk-40); border-radius: var(--radius);
  background: transparent; color: var(--chalk);
  font: 600 18px/1 var(--font); cursor: pointer;
  transition: transform .1s ease;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn-primary { background: var(--chalk); border-color: var(--chalk); color: var(--ink); font-stretch: var(--cond); font-weight: 800; font-size: 24px; }
.btn-ghost { border-color: transparent; padding: 0 14px; }
.btn-danger { border-color: transparent; text-decoration: underline; text-underline-offset: 5px; }
.btn-lg { min-height: 88px; padding: 0 32px; font-size: 36px; }
.btn-block { width: 100%; justify-content: space-between; }
.btn-icon { padding: 0; width: var(--tap); border-color: transparent; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
form.button_to { display: contents; }

/* ---------- Week strip ---------- */

.week { display: flex; padding: 14px 0; border-top: 1px solid var(--chalk-14); border-bottom: 1px solid var(--chalk-14); }
.week .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 76px; justify-content: center; background: none; border: 0; color: inherit; font: inherit; padding: 4px 0; cursor: pointer; border-radius: var(--radius); min-width: 0; }
.week .day:disabled { cursor: default; }
.week .day-l { font-size: 14px; font-weight: 600; color: var(--chalk-72); }
.week .day-m { font-size: 13px; font-weight: 700; font-stretch: 75%; text-transform: uppercase; letter-spacing: .05em; color: var(--chalk-82); max-width: 96%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week .mark { width: 18px; height: 18px; border-radius: 50%; }
.week .mark-climb { background: var(--chalk); }
.week .mark-session { border: 3px solid var(--chalk); }
/* a dashed ring drawn with a mask: Safari renders dashed borders on small circles as broken arcs */
.week .mark-today {
  background: repeating-conic-gradient(from -12deg, var(--chalk) 0 27deg, transparent 0 45deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
}
.week .mark-none { width: 10px; height: 3px; margin: 7px 0; border-radius: 0; background: var(--chalk-40); }
.week .is-today .day-l, .week .is-today .day-m { color: var(--chalk); }
.week-hint { margin-top: 10px; font-size: 15px; color: var(--chalk-72); }

/* ---------- Workouts ---------- */

.section-title { font-size: 18px; font-weight: 600; margin: 0 0 12px; }
.next-up { margin-top: 40px; }
.next-up .reason { display: flex; align-items: center; gap: 12px; font-size: 16px; color: var(--chalk-72); }
.next-up h2 { margin-top: 30px; font-size: 76px; line-height: .95; font-weight: 800; font-stretch: var(--cond); text-wrap: pretty; }
.next-up .desc { margin-top: 14px; font-size: 19px; max-width: 62ch; color: var(--chalk-82); }
.next-up .meta { margin-top: 12px; font-size: 17px; font-weight: 600; }
.next-up .btn-lg { margin-top: 28px; }
.next-up .reason-line { margin-top: 12px; font-size: 19px; color: var(--chalk-82); }
.others { margin-top: 44px; }
/* Wide screens: text left, Start bottom-right, so the block uses the full width
   instead of a long title and a 62ch paragraph stopping two thirds across. */
@media (min-width: 900px) {
  .next-up { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); column-gap: 48px; align-items: end; }
  .next-up .route { grid-column: 1 / -1; }
  .next-up h2 { font-size: clamp(52px, 5.4vw, 64px); }
  .next-up .start-col { grid-column: 2; grid-row: 2; align-self: end; }
  .next-up .btn-lg { margin-top: 0; }
}
@media (orientation: landscape) and (max-height: 820px) {
  .week { padding: 6px 0; }
  .week .day { min-height: 60px; gap: 4px; }
  .week-hint { display: none; }
  .next-up { margin-top: 22px; }
  .next-up .route { --k: .8; }
  .next-up h2 { margin-top: 18px; font-size: 58px; }
  .next-up .desc { display: none; }
  .next-up .btn-lg { min-height: 80px; }
}
.wk-row { display: flex; align-items: center; gap: 18px; padding: 20px 0; border-bottom: 1px solid var(--chalk-14); }
.wk-row:first-of-type { border-top: 1px solid var(--chalk-14); }
.wk-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.wk-row .name { font-size: 32px; line-height: 1.05; font-weight: 800; font-stretch: var(--cond); }
.wk-row .sub { font-size: 16px; color: var(--chalk-72); }
.wk-row .dur { font-size: 30px; font-weight: 700; font-stretch: var(--cond); }
.hint { margin-top: 18px; font-size: 16px; line-height: 1.5; color: var(--chalk-72); max-width: 62ch; }

.empty { padding: 56px 0; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; border-top: 1px solid var(--chalk-14); border-bottom: 1px solid var(--chalk-14); }
.empty h2 { font-size: 40px; font-weight: 800; font-stretch: var(--cond); }
.empty p { color: var(--chalk-82); max-width: 56ch; }

/* ---------- Workout detail: the vertical route ---------- */

.detail-title { font-size: 60px; line-height: .98; font-weight: 800; font-stretch: var(--cond); }
.detail-meta { margin-top: 10px; font-size: 17px; font-weight: 600; }
.detail-notes { margin-top: 12px; font-size: 18px; color: var(--chalk-82); max-width: 62ch; white-space: pre-line; }
.vroute { margin-top: 24px; display: flex; flex-direction: column; }
.v-block { display: grid; grid-template-columns: 72px minmax(0, 1fr); column-gap: 16px; align-items: center; min-height: 58px; }
.v-block .bline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.v-block .bmeta { font-size: 15px; color: var(--chalk-72); }
.v-row { display: grid; grid-template-columns: 72px 56px minmax(0, 1fr) auto; column-gap: 16px; align-items: center; min-height: 66px; }
.v-rail { position: relative; align-self: stretch; display: flex; align-items: center; justify-content: center; }
.v-rail::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 3px dashed var(--chalk-55); transform: translateX(-1.5px); }
.v-rail .hold { position: relative; width: 30px; height: 30px; background: var(--navy); }
.v-row .name { font-size: 20px; font-weight: 600; line-height: 1.2; }
.v-row .sub { font-size: 15px; color: var(--chalk-72); margin-top: 3px; }
.v-row .dose { font-stretch: var(--cond); font-weight: 800; font-size: 28px; text-align: right; white-space: nowrap; }
.v-row .dose small { font-size: 18px; font-weight: 700; color: var(--chalk-82); }
.v-rest { display: grid; grid-template-columns: 72px minmax(0, 1fr); column-gap: 16px; align-items: center; height: 40px; }
.v-rest .line { justify-self: center; width: 3px; height: 100%; background: var(--rest); }
.v-rest span { font-size: 15px; font-weight: 600; color: var(--rest); }

.thumb { width: 56px; height: 56px; border-radius: 4px; overflow: hidden; flex: none; background: var(--navy-3); display: grid; place-items: center; color: var(--chalk-72); }
.thumb img, .duo { filter: url(#duo); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 28px; height: 28px; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .label { font-size: 17px; font-weight: 600; color: var(--chalk); }
.input, .textarea {
  width: 100%; min-height: var(--tap); padding: 0 16px;
  border: 2px solid var(--chalk-40); border-radius: var(--radius);
  background: var(--navy-2); color: var(--chalk);
  font: 500 19px/1.3 var(--font); outline: none;
}
.textarea { padding: 14px 16px; min-height: 120px; resize: vertical; line-height: 1.45; }
.input:focus, .textarea:focus { border-color: var(--chalk); }
.input::placeholder, .textarea::placeholder { color: var(--chalk-55); }
.input-sm { min-height: 50px; font-size: 17px; padding: 0 12px; }
.errors { padding: 16px 0; border-top: 1px solid var(--chalk-14); border-bottom: 1px solid var(--chalk-14); margin-bottom: 20px; }
.errors ul { margin: 6px 0 0; padding-left: 20px; }

.segmented { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px; min-width: 56px; padding: 0 16px;
  border: 2px solid var(--chalk-40); border-radius: var(--radius);
  font-size: 17px; font-weight: 600; color: var(--chalk-82); cursor: pointer; white-space: nowrap;
}
.segmented input:checked + span { background: var(--chalk); border-color: var(--chalk); color: var(--ink); font-weight: 700; }
.segmented input:focus-visible + span { outline: 3px solid var(--chalk); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: center; border: 2px solid var(--chalk-40); border-radius: var(--radius); }
.stepper button { width: 56px; height: 56px; border: 0; background: none; color: var(--chalk); font-size: 26px; cursor: pointer; }
.stepper button:active { background: var(--navy-2); }
.stepper input {
  width: 60px; height: 56px; border: 0; background: none; color: var(--chalk); text-align: center;
  font: 800 24px var(--font); font-stretch: var(--cond); font-variant-numeric: tabular-nums; outline: none;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { padding-right: 8px; color: var(--chalk-72); font-size: 15px; margin-left: -8px; }
.stepper-field { display: flex; flex-direction: column; gap: 6px; }
.stepper-field > span { font-size: 15px; font-weight: 600; color: var(--chalk-82); }

.switch { position: relative; display: inline-block; width: 68px; height: 40px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: var(--radius); border: 2px solid var(--chalk-40); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 5px; left: 5px; width: 26px; height: 26px; border-radius: 3px; background: var(--chalk-72); transition: transform .15s; }
.switch input:checked + span { background: var(--chalk); border-color: var(--chalk); }
.switch input:checked + span::after { transform: translateX(28px); background: var(--ink); }
.switch input:focus-visible + span { outline: 3px solid var(--chalk); outline-offset: 2px; }

/* selectable words (filters, objectives, "counts as") */
.picks { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { position: relative; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 0 14px;
  border: 2px solid transparent; border-radius: var(--radius);
  font-size: 17px; font-weight: 600; color: var(--chalk-72); text-transform: capitalize; cursor: pointer; white-space: nowrap;
}
.pick span small { font-size: 14px; font-weight: 600; color: var(--chalk-55); font-variant-numeric: tabular-nums; }
.pick input:checked + span { background: var(--chalk); color: var(--ink); }
.pick input:checked + span small { color: rgba(15, 26, 43, .7); }
.pick input:focus-visible + span { outline: 3px solid var(--chalk); outline-offset: 2px; }
.scroll-x { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.scroll-x::-webkit-scrollbar { display: none; }

/* ---------- Lists (settings, gear, logbook) ---------- */

.list { border-top: 1px solid var(--chalk-14); }
.list-row { display: flex; align-items: center; gap: 18px; min-height: 76px; padding: 14px 0; border-bottom: 1px solid var(--chalk-14); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; font-size: 19px; }
.list-row .sub { color: var(--chalk-72); font-size: 15px; margin-top: 2px; }
.code {
  display: block; margin-top: 10px; padding: 12px 14px;
  font: 500 15px/1.5 var(--font); color: var(--chalk);
  background: var(--navy-2); border-radius: var(--radius);
  overflow-wrap: anywhere; user-select: all; -webkit-user-select: all;
}
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.group-title { font-size: 28px; font-weight: 800; font-stretch: var(--cond); margin: 44px 0 8px; }
.group-title:first-child { margin-top: 8px; }

/* logbook */
.log-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto auto; gap: 18px; align-items: start; padding: 18px 0; border-bottom: 1px solid var(--chalk-14); }
.log-date { display: flex; flex-direction: column; font-stretch: var(--cond); line-height: 1; }
.log-date b { font-size: 40px; font-weight: 800; }
.log-date span { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--chalk-72); margin-top: 4px; }
.log-row .name { font-size: 24px; font-weight: 800; font-stretch: var(--cond); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.log-row .when { font-size: 15px; color: var(--chalk-72); margin-top: 2px; }
.log-row .notes { margin-top: 6px; font-size: 16px; color: var(--chalk-82); white-space: pre-line; user-select: text; -webkit-user-select: text; max-width: 60ch; }
.log-row .stat { text-align: right; font-stretch: var(--cond); line-height: 1.1; }
.log-row .stat b { display: block; font-size: 26px; font-weight: 800; }
.log-row .stat span { font-size: 14px; color: var(--chalk-72); font-stretch: 100%; }

/* ---------- Exercises ---------- */

.searchbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.searchbar .row { display: flex; gap: 16px; align-items: center; }
.search-input { position: relative; flex: 1; }
.search-input svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--chalk-72); pointer-events: none; }
.search-input .input { padding-left: 50px; }
.toggle-label { display: inline-flex; align-items: center; gap: 12px; font-weight: 600; white-space: nowrap; }
.result-count { color: var(--chalk-72); font-size: 15px; margin: 0 0 4px; font-variant-numeric: tabular-nums; }

.ex-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
@media (max-width: 600px) { .ex-grid { grid-template-columns: minmax(0, 1fr); } }
.ex-row {
  display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 16px; align-items: center;
  padding: 14px 0; border: 0; border-bottom: 1px solid var(--chalk-14);
  background: none; color: inherit; font: inherit; text-align: left; width: 100%; cursor: pointer;
}
.ex-row .thumb { width: 88px; height: 66px; }
.ex-row .name { font-size: 18px; font-weight: 600; line-height: 1.3; }
.ex-row .sub { font-size: 15px; color: var(--chalk-72); text-transform: capitalize; margin-top: 2px; }
.load-more { display: flex; justify-content: center; margin-top: 20px; }

.ex-frames { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 20px 0 28px; }
.ex-frames .frame { background: var(--navy-3); aspect-ratio: 3 / 2; overflow: hidden; display: grid; place-items: center; color: var(--chalk-72); }
.ex-frames img { width: 100%; height: 100%; object-fit: cover; }
.ex-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 40px; }
@media (max-width: 760px) { .ex-cols { grid-template-columns: minmax(0, 1fr); } }
.ex-cols h2 { font-size: 28px; font-weight: 800; font-stretch: var(--cond); margin-bottom: 12px; }
.muscles { display: flex; flex-direction: column; gap: 6px; font-size: 18px; text-transform: capitalize; }
.muscles .primary { font-weight: 700; }
.muscles .secondary { color: var(--chalk-72); }
.howto { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 16px; }
.howto li { counter-increment: step; display: grid; grid-template-columns: 40px 1fr; gap: 12px; font-size: 18px; line-height: 1.5; }
.howto li::before { content: counter(step); width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--chalk); display: grid; place-items: center; font-weight: 800; font-stretch: var(--cond); font-size: 17px; }

/* ---------- Login ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); }
.login form { width: min(420px, 100%); display: flex; flex-direction: column; gap: 18px; }
.login .wordmark { font-size: 72px; align-self: center; }
.login .tagline { text-align: center; color: var(--chalk-72); margin: -10px 0 24px; font-size: 19px; }
.login .error { text-align: center; }

/* ---------- Bottom sheet (picker) ---------- */

dialog.sheet {
  margin: auto auto 0; padding: 0; border: 0;
  width: 100%; max-width: 900px; height: min(88dvh, 980px);
  background: var(--navy); color: var(--chalk);
  border-radius: var(--radius) var(--radius) 0 0; border-top: 2px solid var(--chalk-40);
  overscroll-behavior: contain;
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet::backdrop { background: rgba(4, 8, 14, .7); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 16px var(--gutter) 8px; }
.sheet-head h2 { flex: 1; font-size: 36px; font-weight: 800; font-stretch: var(--cond); }
.sheet-body { flex: 1; overflow-y: auto; padding: 8px var(--gutter) calc(24px + env(safe-area-inset-bottom)); }

/* ---------- Editor ---------- */

.ed-meta { display: flex; flex-direction: column; gap: 20px; padding-bottom: 28px; border-bottom: 1px solid var(--chalk-14); }
.ed-blocks { display: flex; flex-direction: column; }
.ed-block { padding: 26px 0; border-bottom: 1px solid var(--chalk-14); display: flex; flex-direction: column; gap: 18px; }
.ed-block-head { display: flex; gap: 12px; align-items: center; }
.ed-block-name { flex: 1; font-weight: 800; font-stretch: var(--cond); font-size: 26px; }
.ed-tools { display: flex; gap: 2px; flex: none; }
.ed-tools .btn { min-width: 52px; width: 52px; min-height: 52px; }
.ed-block-fields, .ed-step-fields { display: flex; flex-wrap: wrap; gap: 16px 20px; align-items: flex-end; }
.ed-steps { display: flex; flex-direction: column; }
.ed-steps:empty::before { content: "No exercises yet. Add one below."; color: var(--chalk-72); padding: 16px 0; }
.ed-step { padding: 16px 0 18px 22px; margin-left: 20px; border-left: 1px dashed var(--chalk-55); display: flex; flex-direction: column; gap: 14px; }
.ed-step-head { display: flex; gap: 14px; align-items: center; }
.ed-step-head .grow { flex: 1; min-width: 0; }
.ed-step-head .name { font-weight: 600; font-size: 19px; }
.ed-step-head .sub { color: var(--chalk-72); font-size: 15px; text-transform: capitalize; }
.ed-kg { width: 100px; }
.ed-cue { flex: 1 1 240px; }
.ed-add-step { align-self: flex-start; }
.ed-add-block { margin-top: 24px; }
.ed-hint { margin-top: 14px; color: var(--chalk-82); }
.editor .topbar h1 { font-size: 34px; }
.estimate { font-size: 28px; font-weight: 800; font-stretch: var(--cond); font-variant-numeric: tabular-nums; }

/* ---------- Phone (iPhone portrait, ≤ 520px): same world, tighter gutters and phone type sizes ---------- */

@media (max-width: 520px) {
  body { font-size: 16px; }

  .topbar { min-height: 68px; padding-top: calc(env(safe-area-inset-top) + 10px); gap: 8px; }
  .topbar.has-back { padding-left: max(8px, env(safe-area-inset-left)); }
  .topbar h1 { font-size: 34px; }
  .topbar .btn { min-height: 48px; padding: 0 14px; font-size: 16px; }
  .topbar .btn-primary { font-size: 20px; }
  .back { padding: 0 8px; font-size: 16px; }
  .wordmark { font-size: 28px; }
  .main { padding-top: 4px; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  .tabbar { justify-content: space-between; }
  .tab { font-size: 15px; letter-spacing: .05em; padding: 12px 2px 8px; }

  .btn-lg { min-height: 72px; font-size: 30px; padding: 0 24px; }

  /* week strip */
  .week { padding: 10px 0; }
  .week .day { min-height: 64px; gap: 6px; }
  .week .day-l { font-size: 12px; }
  .week .day-m { font-size: 10px; letter-spacing: .03em; }
  .week .mark:not(.mark-none) { width: 14px; height: 14px; }
  .week-hint { display: none; }

  /* routes scale down; labels may wrap under their hold */
  .route { --k: .6; }
  .route .stop { gap: 6px; }
  .route .lbl { font-size: 12px; line-height: 1.2; }

  .next-up { margin-top: 28px; }
  .next-up h2 { margin-top: 18px; font-size: 44px; }
  .next-up .reason-line, .next-up .desc { font-size: 16px; }
  .next-up .desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .next-up .meta { font-size: 15px; }
  .next-up .btn-lg { margin-top: 22px; }
  .others { margin-top: 36px; }
  .wk-row { gap: 12px; padding: 16px 0; }
  .wk-row .name { font-size: 26px; }
  .wk-row .dur { font-size: 24px; }
  .empty h2 { font-size: 32px; }

  /* detail */
  .detail-title { font-size: 40px; }
  .detail-notes { font-size: 16px; }
  .v-rest { grid-template-columns: 34px minmax(0, 1fr); column-gap: 10px; }
  /* block headers drop the rail column so their tags line up with the title */
  .v-block { grid-template-columns: minmax(0, 1fr); margin-top: 6px; }
  .v-block > span:first-child { display: none; }
  .v-block .bline { gap: 6px 10px; }
  .v-block .bmeta { font-size: 14px; white-space: nowrap; }
  .v-row { grid-template-columns: 34px 44px minmax(0, 1fr) auto; column-gap: 10px; min-height: 60px; }
  .v-rail .hold { transform: scale(.72); }
  .v-row .thumb { width: 44px; height: 44px; }
  .v-row .name { font-size: 16px; }
  .v-row .sub { font-size: 13px; }
  .v-row .dose { font-size: 22px; }
  .v-row .dose small { font-size: 14px; }
  .v-block .tag { font-size: 14px; height: 26px; padding: 0 10px; }

  /* forms, lists */
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .list-row { flex-wrap: wrap; gap: 12px; min-height: 64px; }
  .list-row .title { font-size: 17px; }
  .group-title { font-size: 24px; margin-top: 36px; }
  .stepper button { width: 48px; height: 50px; }
  .stepper input { width: 48px; height: 50px; font-size: 22px; }
  .segmented span { min-height: 46px; min-width: 46px; padding: 0 12px; font-size: 16px; }
  .pick span { min-height: 44px; padding: 0 10px; font-size: 16px; }

  /* logbook */
  .log-row { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; }
  /* the text spans both rows so delete sits under the stat, beside the notes, not in its own band */
  .log-row > div:nth-child(2) { grid-column: 2; grid-row: 1 / span 2; }
  .log-row .stat { grid-column: 3; grid-row: 1; }
  .log-row .btn-icon { grid-column: 3; grid-row: 2; justify-self: end; align-self: end; margin-right: -12px; }
  .log-date b { font-size: 30px; }
  .log-row .name { font-size: 20px; }
  .log-row .stat b { font-size: 20px; }

  /* exercises */
  .searchbar .row { flex-wrap: wrap; }
  .search-input { flex-basis: 100%; }
  .ex-row { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; }
  .ex-row .thumb { width: 72px; height: 54px; }
  .ex-frames { grid-template-columns: minmax(0, 1fr); }
  .howto li { font-size: 16px; }

  /* editor */
  .editor .topbar h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .editor .topbar .estimate { margin-left: auto; }
  .estimate { font-size: 22px; }
  .ed-block-head { flex-wrap: wrap; }
  .ed-block-name { flex-basis: 60%; font-size: 22px; }
  .ed-step { margin-left: 6px; padding-left: 14px; }
  .ed-tools .btn { min-width: 44px; width: 44px; min-height: 44px; }
  .ed-kg { width: 84px; }

  .sheet-head { padding: 12px var(--gutter) 6px; }
  .sheet-head h2 { font-size: 28px; }
  .login .wordmark { font-size: 56px; }
}

/* ---------- In the iOS app (html.native) ----------
   The app draws the tab bar, the navigation bar and back. The page keeps its big
   title, which scrolls away under the bar (the bar then shows it), and its actions. */

.native .topbar { position: static; min-height: 0; padding-top: 4px; }
.native .main { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }

/* The editor is a modal without the app's bar: its own bar stays, Cancel and Save. */
.native .editor .topbar { position: sticky; padding-top: 16px; }
