/*
 * Blankpace: one stylesheet for the server pages and the editor island.
 * Tokens come from docs/BRAND.md. Light mode is the whiteboard, dark mode the chalkboard.
 * Ballpoint blue (--color-ink) is for blanks only: never buttons, links, headings, icons or focus rings.
 */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-hyperlegible-next.ef2dde78.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Shantell Sans";
  src: url("../fonts/shantell-sans.7f75ec66.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  /* Color */
  --color-board:   light-dark(#FFFFFF, #1E2725);
  --color-surface: light-dark(#F3F6F7, #26302D);
  --color-line:    light-dark(#D8DFE2, #35423E);
  --color-text:    light-dark(#1B1F23, #EEF1EB);
  --color-muted:   light-dark(#5E6970, #A6B0AB);
  --color-ink:     light-dark(#2346D3, #93B6FF);
  --color-ok:      light-dark(#1E7F4F, #7BD8A3);
  --color-error:   light-dark(#B42318, #FF8E84);
  --color-warn:    light-dark(#9A6700, #F2C14E);

  /* Type */
  --font-ui:   "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand: "Shantell Sans", "Chalkboard SE", "Comic Sans MS", cursive;

  /* Scale: 16px base, ratio 1.25 */
  --text-xs: 0.8125rem;  /* 13 */
  --text-sm: 0.875rem;   /* 14 */
  --text-md: 1rem;       /* 16 */
  --text-lg: 1.25rem;    /* 20 */
  --text-xl: 1.5625rem;  /* 25 */
  --text-2xl: 1.9375rem; /* 31 */
  --text-3xl: 2.4375rem; /* 39 */

  /* Space and shape */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --radius: 0.5rem;
  --content-width: 46rem;
}

/* The workout page and the editor put the preview beside the form on a desktop (docs/steps/fill-in-and-send.md and docs/steps/names-and-editor.md), so the
   whole page widens: header, main and footer together, so their edges line up (#36). */
@media (min-width: 52rem) {
  body:has(.fill-in, .editor) { --content-width: 64rem; }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-board);
  color: var(--color-text);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
p { margin: 0; }

a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Paces and times line up */
.num, time { font-variant-numeric: tabular-nums; }

/* Layout */
.container {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.site-header { border-bottom: 1px solid var(--color-line); }

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding-block: var(--space-3);
}

/* Four links when logged in (docs/steps/small-library.md): on a narrow phone they wrap below the logo instead of running off. */
.site-nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }

.site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-block: var(--space-8);
}

.lead { font-size: var(--text-lg); color: var(--color-muted); max-width: 38em; }

.site-footer {
  border-top: 1px solid var(--color-line);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-4);
}

.site-footer a { color: inherit; }
.footer-links { display: flex; gap: var(--space-3); }

.language-switcher__form { display: flex; gap: var(--space-3); }
.language-switcher .link-button { color: var(--color-muted); }
.language-switcher__current { color: var(--color-text); font-weight: 700; }

/* Logo lockup: the empty pace _:__ followed by the name (BRAND.md, Logo) */
.logo {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
}
.logo-mark { display: inline-block; margin-right: 0.28em; }
.logo-mark i {
  display: inline-block;
  width: 0.42em;
  height: 0.12em;
  border-radius: 0.06em;
  background: var(--color-ink);
  vertical-align: -0.12em;
}
.logo-mark i + i { margin-left: 0.07em; }
.logo-mark b { display: inline-block; margin: 0 0.08em; }

/* Buttons: marker black on the whiteboard, chalk white on the chalkboard. Never ink. */
.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-text);
  color: var(--color-board);
  font: inherit;
  font-weight: 700;
  line-height: 1.5;
  /* The same whether it's a <button>, an <a> or a <summary>: no link underline, no text to select or drag,
     no disclosure marker. A button should look and feel like a button (#17). */
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  list-style: none;
  cursor: pointer;
}
.button::-webkit-details-marker { display: none; }
.button:hover { opacity: 0.88; }
.button:active { transform: translateY(1px); }
a.button:visited { color: var(--color-board); }
a.button--secondary:visited { color: var(--color-text); }

.button--secondary {
  background: transparent;
  color: var(--color-text);
  box-shadow: inset 0 0 0 1px var(--color-text);
}

/* A button that looks like a link, for forms that sit in running text (the language switcher). */
.link-button {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  max-width: 24rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
}
.field label { font-weight: 700; }

.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
}
.input[aria-invalid="true"] { border-color: var(--color-error); }
.input[readonly] { background: transparent; color: var(--color-muted); }

/* The six-digit code: big, spaced and with digits that line up */
.input--code {
  max-width: 9ch;
  font-size: var(--text-xl);
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: 0;
  border: 0;
}
.choices legend { width: 100%; padding: 0; margin-bottom: var(--space-1); font-weight: 700; }
.choice { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; }

/* State colors always come with text, never alone (BRAND.md) */
.message--error { color: var(--color-error); }
.message--warn { color: var(--color-warn); }

.hint { color: var(--color-muted); font-size: var(--text-sm); }

/* The privacy policy and the terms (docs/steps/production.md): long text, so a readable measure. */
.legal { max-width: 40em; }
.legal h2 { margin-block-start: var(--space-8); }
.legal li + li { margin-block-start: var(--space-1); }

/* Settings: one card per thing a runner comes to do, deleting the account last and set apart (#18) */
.settings-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-line);
  border-radius: calc(var(--radius) * 2);
  scroll-margin-top: var(--space-4);
}
@media (min-width: 40rem) { .settings-section { padding: var(--space-6); } }
.settings-section h2 { font-size: var(--text-lg); }
.settings-section__head { display: flex; flex-direction: column; gap: var(--space-1); max-width: 38em; }
.settings-section .form { width: 100%; }
.settings-row { display: flex; flex-direction: column; gap: var(--space-1); }
.settings-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.settings-section--danger { border-color: var(--color-error); }
.settings-section--danger h2 { color: var(--color-error); }
.button--danger { color: var(--color-error); box-shadow: inset 0 0 0 1px currentColor; }

/* Radio buttons as one row of pills (Settings: language, units). The radio stays in place, transparent,
   so it keeps working with a keyboard and a screen reader. */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-1);
  border-radius: var(--radius);
  background: var(--color-surface);
}
.segmented__option {
  position: relative;
  padding: var(--space-1) var(--space-4);
  border-radius: calc(var(--radius) - 0.125rem);
  color: var(--color-muted);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.segmented__option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.segmented__option:hover { color: var(--color-text); }
.segmented__option:has(input:checked) { background: var(--color-board); color: var(--color-text); box-shadow: 0 0 0 1px var(--color-line); }
.segmented__option:has(input:focus-visible) { outline: 2px solid var(--color-text); outline-offset: 2px; }

/* Garmin Connect: Garmin's own tile next to the full name (Garmin's API Brand Guidelines) */
.garmin__title { display: flex; align-items: center; gap: var(--space-3); }
.garmin__tile { flex: none; width: 48px; height: 48px; }
.garmin__notice { display: flex; flex-direction: column; gap: var(--space-2); max-width: 38em; padding-left: 1.25em; }

/* /dev pages */
.dev-section { display: flex; flex-direction: column; gap: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-line); }
.dev-card { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); border: 1px solid var(--color-line); border-radius: var(--radius); }
.dev-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.dev-pre { margin: 0; padding: var(--space-2); background: var(--color-surface); font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.input--date { width: auto; }

/* Editor island mount point */
.island {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px dashed var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
}

/* Hidden from sight, still read out */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

/* ---------------------------------------------------------------------------------------------------------------
 * The workout page (docs/steps/fill-in-and-send.md)
 * ------------------------------------------------------------------------------------------------------------- */

/* The watch's screen is black whatever the theme, so the preview is too. */
:root {
  --color-watch: #0b0d0e;
  --color-watch-text: #f5f7f8;
  --color-watch-muted: #b9c2c7;
  --color-watch-bezel: #2a2f33;
}

.workout { display: flex; flex-direction: column; gap: var(--space-8); }
.workout__head { display: flex; flex-direction: column; gap: var(--space-2); }
.workout__author { color: var(--color-muted); }
.workout__description { color: var(--color-muted); white-space: pre-line; max-width: 38em; }

.summary { font-variant-numeric: tabular-nums; }

/* A blank: the runner's number, in ballpoint blue and handwriting, on a marker underline (BRAND.md) */
.blank {
  font-family: var(--font-hand);
  font-weight: 600;
  color: var(--color-ink);
  text-decoration: underline;
  text-decoration-color: var(--color-text);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}
.blank--derived { text-decoration-style: dashed; text-decoration-color: var(--color-ink); }

/* The form: fields, preview, date, Send. One column on a phone; the preview beside the form on a wide screen. */
.fill-in {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "fields" "preview" "date" "send";
  gap: var(--space-8);
}
.fill-in__fields { grid-area: fields; display: flex; flex-direction: column; gap: var(--space-6); }
.fill-in__values { display: flex; flex-direction: column; gap: var(--space-4); }
/* Only here: in the editor's grid, a named area that doesn't exist pushed the preview into an extra column (#36). */
.fill-in > .preview { grid-area: preview; }
.date-choice { grid-area: date; }
.fill-in__send { grid-area: send; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); }

@media (min-width: 52rem) {
  .fill-in {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "fields preview" "date preview" "send preview";
    grid-template-rows: auto auto 1fr;
    column-gap: var(--space-12);
  }
  .preview { position: sticky; top: var(--space-4); align-self: start; max-height: calc(100vh - 2 * var(--space-4)); overflow-y: auto; }
}

.fill-in__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.fill-in__head h2 { font-size: var(--text-lg); }

/* km / mi */
.units-switch { display: inline-flex; border: 1px solid var(--color-text); border-radius: var(--radius); overflow: hidden; margin-left: auto; }
.units-switch__option {
  appearance: none;
  min-width: 3rem;
  min-height: 2.25rem;
  padding: var(--space-1) var(--space-3);
  border: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
}
.units-switch__option[aria-pressed="true"] { background: var(--color-text); color: var(--color-board); }

/* A field the runner fills in looks like a blank: no box, their value in blue handwriting on an underline. */
.field__row { display: flex; align-items: baseline; gap: var(--space-2); }
.input--blank {
  width: 7rem;
  padding: var(--space-1) 2px;
  border: 0;
  border-bottom: 2px solid var(--color-text);
  border-radius: 0;
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-hand);
  font-size: var(--text-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.input--blank:focus-visible { outline-offset: 4px; }
.field:has(.field__error:not(:empty)) .input--blank { border-bottom-color: var(--color-error); }
.field__unit { color: var(--color-muted); }
.field__error { color: var(--color-error); font-size: var(--text-sm); }
.field__error:empty { display: none; }

/* The watch preview: every step as a small, always-dark screen like the watch's step screen. */
.preview { display: flex; flex-direction: column; gap: var(--space-3); scroll-margin-top: var(--space-4); }
.preview__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); }
.preview__head h2 { font-size: var(--text-lg); }
.preview__name { font-weight: 700; }
.preview__status { color: var(--color-error); font-size: var(--text-sm); }
.preview__status:empty { display: none; }
.preview:has(.preview__status--stale) :is(.preview__steps, .preview__more, .preview__name) { opacity: 0.45; }

.preview__steps, .preview__repeat-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.preview__item { display: flex; align-items: flex-start; gap: var(--space-2); }
.preview__n {
  flex: none;
  width: 1.5rem;
  padding-top: var(--space-3);
  text-align: right;
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}
.tile {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-radius: 0.875rem;
  background: var(--color-watch);
  color: var(--color-watch-text);
  text-decoration: none;
}
.tile:hover { outline: 2px solid var(--color-line); }
.tile__top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.tile__label { color: var(--color-watch-muted); font-size: var(--text-sm); font-weight: 700; }
.tile__amount { font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.tile__note { font-family: var(--font-hand); overflow-wrap: anywhere; }

/* Over 100 steps, Garmin's own repeat: the watch counts its reps. */
.preview__item--repeat { flex-direction: column; align-items: stretch; }
/* A named part's heading in the preview, its steps marked off below it. The watch shows one plain list. */
.preview__part { margin-top: var(--space-2); font-size: var(--text-sm); font-weight: 700; color: var(--color-muted); }
.preview__part:first-child { margin-top: 0; }
.preview__item--in-part { padding-left: var(--space-3); border-left: 3px solid var(--color-line); }
.preview__repeat { display: flex; align-items: baseline; gap: var(--space-2); }
.preview__repeat-label { font-weight: 700; }
.preview__repeat-steps { padding-left: var(--space-6); }

.preview__more summary { cursor: pointer; padding: var(--space-2) 0; font-weight: 700; text-decoration: underline; text-underline-offset: 0.15em; }
.preview__more > .preview__steps { margin-top: var(--space-2); }
.preview__more[open] .when-closed, .preview__more:not([open]) .when-open { display: none; }

/* A tapped step as the round watch face. js/faces.js opens it with a class; without script, its #step-n address does. */
.face { display: none; }
html:not(.faces-js) .face:target,
.face--open {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-board) 85%, transparent);
}
.face__inner { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); }
.face__screen {
  width: min(18rem, 80vw);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-8);
  border: 0.6rem solid var(--color-watch-bezel);
  border-radius: 50%;
  background: var(--color-watch);
  color: var(--color-watch-text);
  text-align: center;
}
.face__position { color: var(--color-watch-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.face__label { color: var(--color-watch-muted); font-weight: 700; }
.face__amount { font-size: var(--text-2xl); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.face__note { font-family: var(--font-hand); overflow-wrap: anywhere; max-height: 5.5em; overflow-y: auto; }
.face__nav { display: flex; align-items: center; gap: var(--space-4); }
.face__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--color-text);
  color: var(--color-text);
  font-size: var(--text-xl);
  text-decoration: none;
}
.face__arrow--off { opacity: 0.3; }

/* The date: four buttons, then the phone's own date picker for "Pick a date" */
.date-choice { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; border: 0; min-width: 0; }
.date-choice legend { padding: 0; margin-bottom: var(--space-3); font-size: var(--text-lg); font-weight: 700; }
.date-choice__options { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip-radio { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--color-text);
  font-weight: 700;
  cursor: pointer;
}
.chip-radio:checked + .chip { background: var(--color-text); color: var(--color-board); }
.chip-radio:focus-visible + .chip { outline: 2px solid var(--color-text); outline-offset: 2px; }
/* Where you run (step 6): the same chips, above the fields */
.place-choice { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; padding: 0; border: 0; min-width: 0; }
.place-choice legend { padding: 0; margin-bottom: var(--space-3); font-size: var(--text-lg); font-weight: 700; }
.place-choice__options { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.place-choice__hint:empty { display: none; }
.date-choice__pick { display: none; }
.date-choice:has(#when-pick:checked) .date-choice__pick { display: block; }
.date-choice:has(#when-none:checked) .cleanup--dated,
.date-choice:not(:has(#when-none:checked)) .cleanup--undated { display: none; }

/* Next to Send: what happened, or what to do */
.panel { padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 2px solid currentColor; max-width: 32rem; scroll-margin-top: var(--space-4); }
.panel p + p { margin-top: var(--space-2); }
.panel--ready { border-color: var(--color-text); font-weight: 700; }
.panel--ok { color: var(--color-ok); }
.panel--ok a { color: inherit; }
.panel--error { color: var(--color-error); }
.button--send { min-height: 3rem; padding: var(--space-3) var(--space-6); font-size: var(--text-lg); }
.button:disabled { opacity: 0.4; cursor: not-allowed; }

/* The Sent list */
.sent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sent-row { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4) 0; border-top: 1px solid var(--color-line); scroll-margin-top: var(--space-4); }
.sent-row__name { font-size: var(--text-lg); }
.sent-row__actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2); margin-top: var(--space-2); }
.confirm > summary { list-style: none; }
.confirm > summary::-webkit-details-marker { display: none; }
.confirm__body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); margin-top: var(--space-2); }

/* Your workouts: the rows share the Sent list's look, and the whole row opens the workout */
.workout-row { position: relative; }
.workout-row__link { color: inherit; text-decoration: none; }
.workout-row__link::after { content: ""; position: absolute; inset: 0; }
.workout-row:hover .workout-row__link, .workout-row__link:focus-visible { text-decoration: underline; }
.workout-row__edit { position: relative; z-index: 1; align-self: flex-start; }

/* The front page's workout (step 8f): written like the coach's board, one row per part under a marker line, then its blanks,
   the one-line watch preview and Send. The library follows under its own heading. */
.hero { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-4); }
.hero__head { display: flex; flex-direction: column; gap: var(--space-1); }
.hero__name { font-size: var(--text-xl); }
.hero__name a { color: inherit; text-decoration: none; }
.hero__name a:hover, .hero__name a:focus-visible { text-decoration: underline; }
.hero__parts { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--color-text); }
.hero__parts li { padding: var(--space-3) 0; border-bottom: 1px solid var(--color-line); font-size: var(--text-lg); }
.hero__form { display: flex; flex-direction: column; gap: var(--space-4); }
.hero__fields { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-8); }
.hero__watch { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--color-surface); }
.hero__watch-label { color: var(--color-muted); font-size: var(--text-sm); font-weight: 700; }
.hero__watch-stale { color: var(--color-error); font-size: var(--text-sm); }
.hero__tile { flex: none; }
.hero__tile:hover { outline: 0; }
.hero__send { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); }
.library { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-8); }
.library h2 { font-size: var(--text-xl); }
.build-own { color: var(--color-muted); }
.build-own a { color: var(--color-text); }

/* The workout page's credit line, Edit and Copy, and History (step 8b) */
.workout__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.history { margin-top: var(--space-6); }
.history__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* The editor (step 8b): phone first, one column; on a desktop the workout page's two columns, the preview in view.
   Save stays at the bottom of the screen. */
.editor__layout { display: flex; flex-direction: column; gap: var(--space-8); padding-bottom: var(--space-12); }
/* On a phone the watch preview folds under the parts: a tinted row, its step count in view, opening to the tiles */
.preview--folds {
  gap: var(--space-3);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-text) 6%, transparent);
}
.preview--folds:has([aria-expanded="true"]) { padding-bottom: var(--space-3); }
.preview__fold-head { font-size: var(--text-md); font-weight: 700; }
.preview__fold-head .hint { font-weight: 400; }
.preview__watch {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='6' y='6' width='12' height='12' rx='3'/%3E%3Cpath d='M9 6V3h6v3M9 18v3h6v-3M12 10v2l1.5 1'/%3E%3C/svg%3E") center / contain no-repeat;
}
.editor__form { display: flex; flex-direction: column; gap: var(--space-6); position: relative; }
@media (min-width: 52rem) {
  .editor__layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--space-12); align-items: start; }
  /* It ends where the Save bar starts, so its steps run up to the bar like the form's do (#42). */
  .editor__preview { position: sticky; top: var(--space-4); max-height: calc(100vh - var(--space-4) - var(--save-bar-height)); overflow-y: auto; }
}
.editor .label { font-weight: 700; }
.chips-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.field--inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.field--inline > label { min-width: 6rem; }
.field-problem { color: var(--color-error); font-size: var(--text-sm); width: 100%; }
.problems { display: flex; flex-direction: column; gap: var(--space-1); }

/* The name and notes: one line, values in it as the blank chip (BRAND.md: handwriting, ink underline) */
.chip-field { min-height: 2.5rem; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; }
.chip-field:focus-visible { outline: 2px solid var(--color-text); outline-offset: 2px; }
/* Not .chip: that's the workout page's date and place buttons, and the two took each other's look. */
.value-chip {
  display: inline-block;
  margin: 0 0.15em;
  font-family: var(--font-hand);
  font-weight: 600;
  color: var(--color-ink);
  text-decoration: underline;
  text-decoration-color: var(--color-ink);
  text-decoration-thickness: 2px;
  user-select: all;
}
.insert-value { width: auto; align-self: flex-start; font-size: var(--text-sm); }

/* Steps and repeats as cards; a repeat holds its steps, indented */
.editor-blocks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.editor-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-board);
  scroll-margin-top: var(--space-4);
}
.editor-repeat { background: var(--color-surface); }
.editor-repeat > .editor-blocks,
.editor-repeat > .editor-part__body > .editor-blocks { padding-left: var(--space-3); border-left: 3px solid var(--color-line); }

/* A top-level step or repeat is a part: one line saying what it is, its fields only while open */
.editor-part__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.editor-part__summary { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
/* "+ Add part": a muted pill on a dashed line between two parts, full width at an open end. Each opens its menu. */
.editor-part-slot { display: flex; flex-direction: column; gap: var(--space-3); }
.editor-add-part,
.editor-add-part--wide { position: relative; display: flex; }
.editor-add-part { justify-content: center; }
.editor-add-part::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px dashed var(--color-line);
}
.editor-add-part__pill {
  position: relative;
  min-height: 2.75rem;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-board);
  color: var(--color-muted);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}
.editor-add-part--wide > .button { flex: 1; justify-content: center; min-height: 2.75rem; }
.editor-add-part > .menu { left: 50%; right: auto; transform: translateX(-50%); }
.editor-add-part--wide > .menu { left: 0; right: auto; }

/* The part's line and its ⋯ menu, which works while the part is closed */
.editor-part__head { display: flex; align-items: center; gap: var(--space-2); }
.editor-part__head > .editor-part__toggle { flex: 1; width: auto; min-width: 0; }
.editor-part__toggle::after {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: var(--space-1);
  border-right: 2px solid var(--color-muted);
  border-bottom: 2px solid var(--color-muted);
  transform: translateY(-25%) rotate(45deg);
}
.editor-part__toggle[aria-expanded="true"]::after { transform: translateY(25%) rotate(-135deg); }
.editor-part__body { display: flex; flex-direction: column; gap: var(--space-3); }
/* Links in a card sit at its left edge, tall enough to tap, rather than stretched and centred across it */
.editor-block > .link-button,
.editor-part__body > .link-button,
.editor-more__body > .link-button { align-self: flex-start; min-height: 2.75rem; text-align: left; }
/* More options folds like a part, below a line; open, the row and its fields share one tinted panel inside the card.
   A tint of the text colour, so it shows on a step's card and on a repeat's alike. */
.editor-more { padding-top: var(--space-2); border-top: 1px solid var(--color-line); }
.editor-more--open,
.amount__picker {
  padding: var(--space-1) var(--space-3) var(--space-3);
  border-top-color: transparent;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-text) 6%, transparent);
}
.editor-more__body { display: flex; flex-direction: column; gap: var(--space-3); }
.editor-block--problem { border-color: var(--color-error); }
/* Wraps, so a repeat's title, its end and the tools never run out of the card on a phone (#36) */
.editor-block__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.editor-block__head > .input { width: auto; }
.editor-repeat__title { font-size: var(--text-md); }
.editor-block__tools { display: flex; gap: var(--space-1); margin-left: auto; position: relative; }
.editor__add { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.icon-button {
  min-width: 2.25rem;
  min-height: 2.25rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-board);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}
.icon-button:disabled { opacity: 0.4; cursor: not-allowed; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-1));
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 14rem;
  padding: var(--space-2);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-board);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
}
.menu__item { text-align: left; padding: var(--space-2); border: 0; background: none; color: var(--color-text); font: inherit; cursor: pointer; border-radius: var(--radius); }
.menu__item:hover, .menu__item:focus-visible { background: var(--color-surface); }
.editor__menu { position: absolute; top: 0; right: 0; }
/* The Name label's line is as tall as the ⋯ button beside it, so the button doesn't cover the field below (#36). */
.editor__menu + .field > .label { display: flex; align-items: center; min-height: 2.25rem; }

/* An amount: Fixed, Runner fills in, Based on, or a value; the number and its unit; and, in a repeat, per rep */
.amount { display: flex; flex-direction: column; gap: var(--space-1); }
.amount__label { font-weight: 700; font-size: var(--text-sm); }
/* The number itself, tapped to open its picker: a field with the parts' chevron */
.amount__value {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  align-self: flex-start;
  width: auto;
  min-height: 2.75rem;
  text-align: left;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.amount__value::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--color-muted);
  border-bottom: 2px solid var(--color-muted);
  transform: translateY(-25%) rotate(45deg);
}
.amount__value[aria-expanded="true"]::after { transform: translateY(25%) rotate(-135deg); }
.amount__picker { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-3); }
.amount__row, .each { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.amount__row > .input, .each > .input { width: auto; }
.input--number { max-width: 8rem; font-variant-numeric: tabular-nums; }
.amount__unit-label { color: var(--color-muted); }
.each__list { min-width: 12rem; }
.chip-each { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* The runner fills in: each value's label, its suggestion on the right and its range below, read-only */
.editor-fills { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.editor-fill {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0 var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-line);
}
.editor-fill > .hint,
.editor-fill > .problems { grid-column: 1 / -1; }

/* Values */
.editor-values { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.editor-value { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--color-line); border-radius: var(--radius); }
.editor-value > .input,
.editor-value > .editor-part__body > .input { width: auto; align-self: flex-start; }
.editor-value__summary { display: flex; flex-direction: column; }
.editor-value__label { font-weight: 700; }

.editor__names { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border: 2px solid var(--color-text); border-radius: var(--radius); }
.editor__names h2 { font-size: var(--text-lg); }

/* Save at the bottom of the screen, and the undo bar above it. The bar's height is fixed so the desktop preview can end
   exactly at its top: the button (2.5rem), the padding (1.5rem) and the border (#42). */
.editor { --save-bar-height: calc(4rem + 1px); }
.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 3;
  min-height: var(--save-bar-height);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-line);
  background: var(--color-board);
}
.save-bar__status { font-size: var(--text-sm); }
.undo-bar {
  position: sticky;
  bottom: 4.5rem;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: fit-content;
  margin: 0 auto;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  background: var(--color-text);
  color: var(--color-board);
}
.undo-bar .link-button { color: inherit; }
/* A draft from an earlier visit: the same tint as More options, above the name. */
.draft-offer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-text) 6%, transparent);
}
