/* Phit stylesheet, part 4 of 8. Switches, split alignment and decoupling, the header buttons, list controls and filters, run cards and their menu, settings and adjusted-pace controls.
   The parts are one stylesheet cut into files: they must load in this order (index.html and the plain pages list them), because a later rule can override an earlier one. */

/* ----- on/off switch (e.g. "Show splits") ----- */
.toggle {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 34px; padding: 0.25rem 0.7rem;
  background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: 500;
}
.toggle .track { position: relative; width: 28px; height: 16px; border-radius: var(--r-pill); background: var(--border); transition: background 0.15s; }
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); transition: left 0.15s, background 0.15s;
}
.toggle[aria-checked="true"] { color: var(--text); }
.toggle[aria-checked="true"] .track { background: var(--accent); }
.toggle[aria-checked="true"] .track::after { left: 14px; background: var(--on-accent); }
.toggle:disabled { opacity: 0.4; cursor: not-allowed; }
.chart-svg .split-line { stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.8; pointer-events: none; }

/* ----- the notes under a chart ----- */
.chart-note { margin-bottom: 0.4rem; font-size: var(--fs-sm); color: var(--muted); }

/* ----- aerobic decoupling highlight ----- */
.decoupling-note {
  margin: 0 0 0.6rem; padding: 0.55rem 0.75rem; font-size: var(--fs-md);
  border: 1px solid rgb(var(--warn-rgb) / 0.5); border-left-width: 3px; border-radius: var(--r-md); background: rgb(var(--warn-rgb) / 0.07);
}
.decoupling-title { font-weight: 600; color: var(--warn); margin-bottom: 0.25rem; }
.decoupling-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.15rem 0; }
.decoupling-note .hint { margin-top: 0.3rem; font-size: var(--fs-sm); }
.chart-svg .dec-bar { stroke: var(--muted); stroke-width: 3; opacity: 0.6; }
.chart-svg .dec-drop { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 2 3; opacity: 0.6; }
.chart-svg .decoupling.some .dec-bar, .chart-svg .decoupling.some .dec-drop { stroke: var(--warn); opacity: 0.95; }
.chart-svg .decoupling.high .dec-bar, .chart-svg .decoupling.high .dec-drop { stroke: var(--bad); opacity: 0.95; }
.chip.warn { color: var(--warn-ink); border-color: rgb(var(--warn-rgb) / 0.6); background: rgb(var(--warn-rgb) / 0.08); }
.group-line.warn { color: var(--warn); }
.compare-grid .cell-warn { color: var(--warn); font-weight: 600; }
/* alignment: pick a split per run */

.chart-svg .ref-line { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.7; pointer-events: none; }
.chart-svg .ref-label { fill: var(--warn); font-size: 11px; pointer-events: none; }

/* ----- header: theme toggle and quick buttons ----- */
.theme .seg { min-height: 28px; padding: 0.1rem 0.6rem; font-size: var(--fs-sm); }
.header-btn { min-height: 28px; padding: 0.1rem 0.7rem; font-size: var(--fs-sm); }
.header-right { flex-wrap: wrap; justify-content: flex-end; }

/* ----- run list controls, filters ----- */
.list-controls { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0.4rem 0 0.5rem; }
.list-controls .seg { min-height: 30px; padding: 0.1rem 0.8rem; font-size: var(--fs-sm); }
#filters-toggle { min-height: 30px; padding: 0.1rem 0.7rem; font-size: var(--fs-sm); }
.filters { margin-bottom: 0.6rem; padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: var(--r-lg); font-size: var(--fs-md); }
.filters.locked { opacity: 0.85; }
.filters-lock { margin-bottom: 0.4rem; color: var(--warn); font-size: var(--fs-sm); font-weight: 600; }
.date-range { margin-bottom: 0.5rem; }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--fs-sm); margin-bottom: 0.15rem; }
.range-sliders { position: relative; height: 26px; }
.range-sliders input[type=range] {
  position: absolute; left: 0; right: 0; width: 100%; margin: 0; top: 4px; height: 18px;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none; accent-color: var(--accent);
}
.range-sliders input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--border); }
.range-sliders input[type=range] + input[type=range]::-webkit-slider-runnable-track { background: transparent; }
.range-sliders input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border); }
.range-sliders input[type=range] + input[type=range]::-moz-range-track { background: transparent; }
.range-sliders input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); cursor: pointer; }
.range-sliders input[type=range]::-moz-range-thumb { pointer-events: auto; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); cursor: pointer; }
.pills { display: flex; flex-direction: column; gap: 0.35rem; }
.pill-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.pill-label { width: 4.2rem; color: var(--muted); font-size: var(--fs-xs); }
.pill {
  min-height: 0; padding: 0.15rem 0.6rem; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 500;
  background: none; color: var(--muted); border: 1px solid var(--border);
}
.pill:hover { color: var(--text); border-color: var(--muted); }
.pill[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.pill-n { opacity: 0.7; font-size: var(--fs-xs); margin-left: 0.1rem; }
.filters-foot { margin-top: 0.5rem; text-align: right; }
.filters-foot .ghost { min-height: 28px; padding: 0.1rem 0.7rem; font-size: var(--fs-sm); }
#filters-count { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

/* ----- run cards: extras, drag and drop, menu ----- */
.run, .train-run { position: relative; }
.run-menu-btn { position: absolute; top: 0.25rem; right: 0.3rem; }
.runs-flat { display: flex; flex-direction: column; gap: 0.5rem; }
.chip.pr { color: var(--good-ink); border-color: var(--good); }
.chip.manual { color: var(--accent); border-color: rgb(var(--accent-rgb) / 0.5); }
.chip.warmup { color: var(--muted); border-style: dashed; }
.chip.effort.rel { text-transform: none; }
.chip.effort.rel.harder { color: var(--text); border-color: var(--warn); }
.chip.effort.rel.easier { color: var(--text); border-color: var(--good); }
.chip.session { color: var(--text); border-color: var(--muted); }
.chip.session.tag { color: var(--muted); border-style: dashed; }
.chip.group-chip { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.run.dragging { opacity: 0.45; }
.dragging-run details.group { outline: 1px dashed var(--border); outline-offset: 2px; }
details.group.drop-target { outline: 2px solid var(--accent); outline-offset: 2px; background: rgb(var(--accent-rgb) / 0.07); }
label.run[draggable=true] { cursor: grab; }
.run-menu {
  position: fixed; z-index: 45; width: 300px; max-height: 70vh; overflow: auto; padding: 0.5rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-2xl); box-shadow: 0 12px 36px rgb(0 0 0 / 0.3);
}

/* ----- settings dialog ----- */
.dialog { max-width: 520px; width: calc(100% - 2rem); max-height: calc(100vh - 2rem); overflow-y: auto; padding: 0; border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--panel); color: var(--text); }
.dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.settings-form { display: block; margin: 0; padding: 1.1rem; }
.settings-form :is(h1, h2) { margin-bottom: 0.4rem; }
.field { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin: 0.8rem 0; }
.field select { min-height: 38px; max-width: 100%; padding: 0.3rem 2rem 0.3rem 0.7rem; border-radius: var(--r-md); border: 1px solid var(--border); background-color: var(--bg); color: var(--text); font: inherit; font-size: var(--fs-lg); cursor: pointer; }
.field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field > label { flex-basis: 100%; font-size: var(--fs-md); font-weight: 600; }
.field input[type=number] { flex: 0 0 120px; min-width: 0; min-height: 38px; padding: 0.3rem 0.6rem; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 1rem; }
.bounds { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.bounds input { flex: 0 0 74px !important; }
.zone-table { width: 100%; margin-top: 0.4rem; border-collapse: collapse; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.zone-table td { padding: 0.15rem 0.3rem; border-bottom: 1px solid var(--border); }
.zone-table td:last-child { text-align: right; color: var(--muted); }
.zone-table caption { text-align: left; padding-top: 0.3rem; caption-side: bottom; }
.check { display: flex; gap: 0.5rem; align-items: center; font-size: var(--fs-md); margin: 0.6rem 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
/* Settings, Adjusted pace: a choice, then what it does in small print under it */
#set-panel-adjust .check { align-items: flex-start; font-size: var(--fs-base); margin: 0.8rem 0; }
#set-panel-adjust .check input { margin-top: 0.15rem; flex: none; }
#set-panel-adjust .check small { display: block; font-weight: 400; margin-top: 0.1rem; }
#set-panel-adjust .check.locked { opacity: 0.6; }
#set-panel-adjust .adjust-checks { padding-left: 0.2rem; }
#set-adjust-parts.is-off .adjust-checks { opacity: 0.6; }            /* the parts only matter while adjusted pace is on, but can still be chosen */
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.8rem; }
#settings-form .dialog-actions { position: sticky; bottom: -1.1rem; margin: 0.8rem -1.1rem -1.1rem; padding: 0.7rem 1.1rem; background: var(--panel); border-top: 1px solid var(--border); }

/* ----- records ----- */
.records-table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); font-variant-numeric: tabular-nums; }
.records-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: var(--fs-sm); padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--border); }
.records-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); }
.rec-dist { font-weight: 600; }
.records-table td:nth-child(4) { white-space: nowrap; }
.records-table .rec-row { cursor: pointer; }
.records-table .rec-row:hover td { background: rgb(var(--accent-rgb) / 0.05); }
.records-table .rec-row.is-picked td { background: rgb(var(--accent-rgb) / 0.09); } .records-table .rec-row.is-picked td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.rec-pick { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; cursor: pointer; text-align: left; } .rec-pick:hover, .rec-pick:focus-visible { color: var(--accent); }          /* a date stays on one line */
.rec-time { font-weight: 600; color: var(--good); }
button.link.rec-open { text-align: left; }
/* the table, and beside it how a best has fallen over time (records.js); stacked on a narrow screen */
.rec-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 25rem); gap: 1.5rem; align-items: start; }
.rec-trend { border-left: 1px solid var(--border); padding-left: 1.5rem; min-width: 0; }
.rec-trend-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 0.8rem; flex-wrap: wrap; margin: 0 0 0.5rem; }
.rec-trend-title { margin: 0; font-size: var(--fs-lg); }
.rec-trend .hint { margin: 0 0 0.6rem; }
.records-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.records-head h1 { margin: 0; }
.info-btn { width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--muted); display: inline-grid; place-items: center; cursor: help; }
.info-btn:hover, .info-btn:focus-visible { color: var(--text); border-color: var(--muted); }
.info-btn[hidden] { display: none; }
.rec-figure { margin: 0; }
.rec-svg { display: block; width: 100%; height: auto; overflow: visible; }
.rec-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.rec-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 4; stroke-linecap: round; stroke-linejoin: round; }
.rec-dot { fill: var(--series-1); stroke: var(--panel); stroke-width: 1.5; }
.rec-dot-last { fill: var(--good); }
.rec-hit { fill: transparent; }
.rec-pt { cursor: pointer; outline: none; }
.rec-pt:hover .rec-dot, .rec-pt:focus-visible .rec-dot { stroke: var(--text); stroke-width: 2; }
.rec-value { fill: var(--text); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-tick { fill: var(--muted); font-size: 10.5px; }
.rec-note { margin: 0.4rem 0 0; color: var(--good); font-weight: 600; font-size: var(--fs-md); }
/* your PRs in context: the figure beside the list of PRs with room to improve */
.pc { margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.pc-head { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.6rem; }
.pc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 17rem); gap: 1.5rem; align-items: start; }
.pc-figure { margin: 0; min-width: 0; }
.pc-svg { display: block; width: 100%; height: auto; overflow: visible; }
.pc-gl { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.pc-tick { fill: var(--muted); font-size: 11px; }
.pc-band { fill: rgb(var(--accent-rgb) / 0.12); }
.pc-short { fill: rgb(var(--ink-rgb) / 0.05); }
.pc-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pc-dot { fill: var(--series-1); stroke: var(--panel); stroke-width: 2; }
.pc-dot-high { fill: var(--series-2); }
.pc-ring { fill: none; stroke: var(--series-2); stroke-width: 1.5; }
.pc-drop { stroke: var(--series-2); stroke-width: 1.5; stroke-dasharray: 2 3; }
.pc-hit { fill: transparent; }
.pc-pt { cursor: pointer; outline: none; }
.pc-pt:hover .pc-dot, .pc-pt:focus-visible .pc-dot { stroke: var(--text); }
.pc-lead { stroke: var(--series-2); stroke-width: 1; opacity: 0.55; } .pc-lead-good { stroke: var(--good); }
.pc-tag { fill: var(--series-2); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pc-tag-quiet { font-weight: 600; opacity: 0.8; }
.pc-room-title { margin: 0 0 0.5rem; font-size: var(--fs-lg); }
.pc-list { list-style: none; margin: 0 0 0.6rem; padding: 0; display: grid; gap: 0.7rem; }
.pc-item { display: grid; grid-template-columns: 0.9rem 1fr; column-gap: 0.5rem; font-size: var(--fs-md); }
.pc-item .pc-mark { grid-row: 1 / span 3; margin-top: 0.4rem; }
.pc-item > :not(.pc-mark) { grid-column: 2; }
.pc-mark { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--series-2); }
.pc-mark-close { background: var(--series-1); vertical-align: baseline; margin-right: 0.3rem; }
button.link.pc-open { text-align: left; font-weight: 700; color: var(--text); }
.pc-line-text { color: var(--muted); }
.pc-gain { color: var(--series-2); font-weight: 700; }
.pc-item-quiet .pc-gain, .pc-item-quiet .pc-open { opacity: 0.8; }
.pc-none { margin: 0 0 0.6rem; color: var(--good); font-weight: 600; font-size: var(--fs-md); }
.pc-close { margin: 0; color: var(--muted); font-size: var(--fs-md); }
@media (max-width: 1100px) {
  .pc-grid { grid-template-columns: minmax(0, 1fr); }
  .rec-layout { grid-template-columns: minmax(0, 1fr); }
  .rec-trend { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 1rem; }
}

/* ----- adjusted pace controls ----- */
.adjust-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: -0.2rem 0 0.7rem; }
.adjust-label { color: var(--muted); font-size: var(--fs-sm); margin-right: 0.2rem; }
.chip-toggle {
  min-height: 0; padding: 0.2rem 0.7rem; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 500;
  background: none; color: var(--muted); border: 1px solid var(--border);
}
.chip-toggle:hover { color: var(--text); border-color: var(--muted); }
.chip-toggle[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.chip-toggle .badge { margin-left: 0.35rem; }
.badge[hidden], .chip[hidden] { display: none; }

/* ----- personal workload correction box ----- */
.personal-box { margin: 0 0 0.7rem; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: var(--r-md); font-size: var(--fs-sm); }
.personal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.personal-head strong { margin-right: auto; }
.personal-head .ghost { min-height: 28px; padding: 0.1rem 0.7rem; font-size: var(--fs-sm); }
.personal-status { margin: 0.35rem 0 0.2rem; font-size: var(--fs-sm); }
.personal-foot { font-size: var(--fs-xs); }
.altitude-note, .weather-note { margin-bottom: 0.4rem; }


/* the hand on the charts: pick it, then drag a run's line left or right to line the runs up (chart.js) */
.hand-btn { display: inline-flex; align-items: center; gap: 0.35rem; background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 0.25rem 0.7rem 0.25rem 0.55rem; cursor: pointer; font: inherit; font-size: var(--fs-md); }
.hand-btn:hover { color: var(--text); border-color: var(--muted); }
.hand-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: rgb(var(--accent-rgb) / 0.1); }
.hand-ico { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.hand-note { font-size: var(--fs-sm); }
.chart-svg.hand { touch-action: none; }
.chart-svg.hand.over-line { cursor: grab; }
.chart-svg.hand.grabbing, .chart-svg.hand.grabbing.over-line { cursor: grabbing; }
.chart-svg.hand .run-layer.hot .series-line { stroke-width: 3.4; }
.chart-svg.hand .run-layer.cool { opacity: 0.3; }
