* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 "Albert Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
/* The header is in header.css; it spans the page, so the side and bottom padding is .layout's and
   the heading's, which keep the content in the 80rem column. */
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
#plan-heading, #file-name { overflow-wrap: anywhere; }
h3 { font-size: 1rem; margin: 1rem 0 0.25rem; }
.layout { display: block; max-width: calc(80rem + 32px); margin: 0 auto; padding: 0 16px 16px; }
.layout > * { min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
@media (min-width: 960px) {
  .layout { display: grid; grid-template-columns: 22rem 1fr; gap: 24px; align-items: start; }
}
.field { margin: 0.75rem 0; }
.field label, legend { display: block; font-weight: 600; margin-bottom: 2px; }
fieldset { border: 0; padding: 0; margin: 0; }
fieldset label { display: block; font-weight: normal; }
input[type="number"], input[type="text"], select {
  width: 100%; padding: 6px 8px; font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--control-border); border-radius: 4px;
}
input[type="range"] { width: 100%; }
input:disabled { opacity: 0.7; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); }
output { font-weight: normal; color: var(--muted); }
/* The flat-ground speed sits at the right edge, so the text beside the slider does not shift as its
   value changes; on a narrow screen it wraps to its own line, still on the right. */
.field label.pace-label { display: flex; flex-wrap: wrap; column-gap: 0.4em; }
.pace-flat { margin-left: auto; font-weight: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
#out-pace_factor { font-variant-numeric: tabular-nums; }
summary { cursor: pointer; font-weight: 600; margin: 1rem 0 0.5rem; }
button {
  font: inherit; padding: 6px 12px; border-radius: 4px; cursor: pointer;
  color: var(--fg); background: var(--bg); border: 1px solid var(--control-border);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.error { color: var(--error); margin: 4px 0 0; }
.general { padding: 8px 12px; border: 1px solid var(--error); border-radius: 4px; }
.note { padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px; }
.dropzone { border: 2px dashed var(--border); border-radius: 8px; padding: 12px; }
.dropzone.over { border-color: var(--accent); }
/* balance: a two-line label splits evenly, so no language or width leaves one word alone on the second line. */
.dropzone label { display: block; font-weight: 600; text-wrap: balance; }
/* Six cards: two columns on a phone, three from 480 px, so the last row is never a single orphan. */
.metrics { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 480px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
/* A label that wraps to two lines must not push its value out of line with the next tile's. */
.metrics li { display: flex; flex-direction: column; justify-content: space-between; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; }
.metric-label { display: block; font-size: 0.85rem; color: var(--muted); }
.metric-value { font-size: 1.25rem; }
/* The water note sits tight under the cards it explains; it wraps like any paragraph. */
.water-note { margin: -8px 0 16px; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
section > h2 + .water-note { margin: 0 0 8px; }
.banner { border: 2px solid var(--error); border-radius: 6px; padding: 4px 12px; margin: 16px 0; }
.banner h2 { margin: 0.25rem 0; color: var(--error); }
.banner ul { margin: 0.25rem 0 0.5rem; padding-left: 1.25rem; }
/* The report button sits at the card's top right, on show open or closed; the summary leaves it room. */
.stage-card { position: relative; margin: 8px 0; }
details.stage { border: 1px solid var(--border); border-radius: 6px; padding: 0 12px 8px; background: var(--panel); }
details.stage > summary { margin: 0; padding: 8px 70px 8px 0; }
.report-stage {
  position: absolute; top: 6px; right: 6px; width: 62px; min-height: 44px; padding: 3px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 0.7rem; line-height: 1.1; color: var(--fg); background: var(--bg);
  border: 1px solid var(--control-border); border-radius: 6px; cursor: pointer;
}
details.stage > summary > span { display: block; font-weight: 400; }
details.stage > summary > .stage-warning { color: var(--error); font-weight: 600; }
.stage-warning svg { vertical-align: -2px; }
details.stage > p { margin: 2px 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 16px; margin: 4px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
details.stage h3 { margin: 0.75rem 0 0.25rem; }
.stage-warnings { color: var(--error); padding-left: 1.25rem; }
/* Scrolls sideways inside itself. The two inset gradients that follow the content are the CSS-only
   scroll shadow: "local" ones cover the "scroll" ones (fixed to the edges) until there is more. */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--bg) 30%, transparent) left center / 24px 100% no-repeat local,
    linear-gradient(to left, var(--bg) 30%, transparent) right center / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.3), transparent) left center / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.45), transparent) right center / 14px 100% no-repeat scroll;
}
/* The first column stays put. Each cell draws its own right and bottom line ("separate" borders),
   so the line beside the sticky column moves with it. With collapsed borders the grid line scrolls
   under a sticky cell and the content shows through the seam: flicker in Safari. */
.table-wrap table { border-collapse: separate; border-spacing: 0; }
.table-wrap th, .table-wrap td { border-width: 0 1px 1px 0; }
.table-wrap thead tr:first-child th { border-top-width: 1px; }
.table-wrap th:first-child, .table-wrap td:first-child { border-left-width: 1px; }
.table-wrap th:first-child {
  position: sticky;
  left: 0;
  background: var(--bg);
}
@media (max-width: 599.98px) {
  .col-macro { display: none; }
}
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { border: 1px solid var(--border); padding: 4px 8px; text-align: right; white-space: nowrap; }
thead th, tbody th, tfoot th { text-align: left; }
tfoot { font-weight: 600; }
.chart-wrap { width: 100%; position: relative; }
.profile-tip { position: absolute; z-index: 1; padding: 4px 8px; border-radius: 4px; background: var(--fg); color: var(--bg); font-size: 0.9rem; white-space: nowrap; pointer-events: none; }
.profile-chart .overnight-stop { cursor: pointer; }
.profile-chart .overnight-hit { fill: transparent; }
.profile-chart .overnight-stop:focus { outline: none; }
.profile-chart .overnight-stop:focus-visible .overnight { stroke-width: 4px; }
.profile-chart { width: 100%; height: auto; display: block; }
.profile-chart .grid { stroke: var(--border); stroke-width: 1; }
.profile-chart .tick { fill: var(--muted); font-size: 11px; }
.profile-chart .boundary { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; }
.profile-chart .line { stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.profile-chart .line.flat { stroke: var(--grade-flat); }
.profile-chart .line.gentle { stroke: var(--grade-gentle); }
.profile-chart .line.steep { stroke: var(--grade-steep); }
.profile-chart .overnight { fill: var(--bg); stroke: var(--fg); stroke-width: 2.5px; vector-effect: non-scaling-stroke; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0 8px; padding: 0; font-size: 0.9rem; }
.swatch { display: inline-block; width: 1.5rem; height: 0.35rem; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.swatch.flat { background: var(--grade-flat); }
.swatch.gentle { background: var(--grade-gentle); }
.swatch.steep { background: var(--grade-steep); }
.swatch.overnight { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--bg); border: 2px solid var(--fg); box-sizing: border-box; }
.profile-table > summary { margin: 0.5rem 0; }
.export-bar { margin: 16px 0; }
#mapbook-widget { margin-top: 12px; }
#mapbook-widget p { margin: 0 0 6px; }
#mapbook-widget [hidden] { display: none; }
.print-options { margin-top: 12px; }
.print-options > summary { cursor: pointer; }
.print-options .field { margin: 0.5rem 0; }
.print-options select, .print-options input[type="range"] { max-width: 100%; box-sizing: border-box; }
@media (min-width: 480px) {
  .print-options[open] { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .print-options > summary { grid-column: 1 / -1; }
}
#mapbook-progress { width: 100%; max-width: 24rem; display: block; margin-bottom: 6px; }
.demos { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
/* A demo card: a panel like the other cards, the name on its own line, then the distance and the
   button with room between them. The button is an ordinary one: the page colour and the control
   edge on the panel, like "Start over". */
.demos li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: var(--panel);
}
.demos .name { font-weight: 600; flex: 1 1 100%; }
.demo-credit { font-size: 0.85rem; margin: 8px 0 0; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
/* First view (ux-review §2-§4): a plain h1, the upload as the main action, the welcome area as
   the empty result, and the plan header (heading, stage count, mapbook widget). */
.page-heading { max-width: calc(80rem + 32px); padding: 16px 16px 0; margin: 0 auto 12px; font-size: 1.5rem; line-height: 1.25; overflow-wrap: anywhere; }
.dropzone { padding: 16px; background: var(--bg); }
.dropzone label { font-size: 1.1rem; margin-bottom: 8px; }
.dropzone input[type="file"] { display: block; max-width: 100%; }
.dropzone #file-name { margin: 8px 0 0; }
#welcome > h2:first-child, #plan-heading { margin-top: 0; }
html[data-planned] #welcome { display: none; }
.welcome-more > summary { margin: 1rem 0 0.5rem; }
@media (min-width: 720px) {
  .welcome-more > summary { display: none; }
  .welcome-more { margin-top: 16px; }
}
.welcome-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.welcome-cards li { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; color: var(--fg); }
.welcome-cards svg { display: block; color: var(--accent); }
.welcome-cards h3 { font-size: 1.05rem; margin: 0.5rem 0 0.25rem; }
.welcome-cards p { margin: 0; }
.plan-meta { margin: 0 0 8px; }
#plan-heading { margin-bottom: 0.25rem; scroll-margin-top: 12px; }
#dashboard .export-bar { margin: 8px 0 16px; }
@media (max-width: 479.98px) {
  .page-heading { font-size: 1.3rem; margin-bottom: 8px; }
}
/* Adjust plan (ux-review §6, §7): the stage controls in a disclosure whose summary reads as the
   section's heading; "Adjust plan" pinned to the bottom on stacked layouts while a plan is shown. */
.adjust-plan { margin-top: 1rem; border-top: 1px solid var(--border); }
.adjust-plan > summary { font-size: 1.1rem; margin: 0; padding: 0.75rem 0 0.25rem; }
.edit-plan {
  position: fixed; left: 0; right: 0; bottom: 0;
  /* No z-index: the feedback dialog is in the top layer and the survey panel comes later in the
     document, so both paint above it. */
  min-height: calc(44px + env(safe-area-inset-bottom, 0px));
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  border: 0; border-top: 1px solid var(--border); border-radius: 0;
  background: var(--panel); color: var(--accent); font-weight: 600;
}
.edit-plan[hidden] { display: none; }
.edit-plan:focus-visible { outline-offset: -4px; }
/* 76 px below the content with the bar shown, of which .layout's bottom padding gives 16. */
body:has(#edit-plan:not([hidden])) { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 960px) {
  .edit-plan { display: none; }
  body:has(#edit-plan:not([hidden])) { padding-bottom: 0; }
}
