/*===============================================*\
|| # JAKWEB.CH / TerraLoc Leagues / Version 1.1     # ||
|| # XC route planner workspace.               # ||
|| # Layout, sidebar, action buttons and stat  # ||
|| # chips come from the shared edit-task.css; # ||
|| # this file only replicates the #taskView   # ||
|| # scoped rules for #tleagues-planner-main and   # ||
|| # adds the planner specific pieces.         # ||
\*===============================================*/

/* The planner page itself. It fills the viewport below the site header and
   never scrolls: the map is the page, and the sidebar scrolls inside it. */
.tleagues-planner-page {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* View root                                                            */
/* ------------------------------------------------------------------ */

/*
 * The sizing, the sidebar variables, the collapse transitions and the night
 * background all live in terraloc's edit-route.css, which this page loads
 * and which owns the .tl-route-edit-* layer. They used to be duplicated here
 * under .tl-task-edit-*, a name the markup has never carried: every one of
 * those rules was dead, and the profile panel below read a sidebar width that
 * nothing declared, so it fell back to 0 and slid a quarter of the terrain
 * under the sidebar.
 *
 * What stays is the one variable that belongs to this plugin: how tall the
 * profile strip is. The chip and hint offsets further down follow it.
 */
.tl-route-edit-page #tleagues-planner-main {
  --tleagues-profile-h: 180px;
}

/* ------------------------------------------------------------------ */
/* Terrain profile panel                                               */
/* ------------------------------------------------------------------ */

/* ------------------------------------------------------------------
   THE PROFILE DOCK'S PLACE ON THIS PAGE.

   The card, the strip, the chart, the colour buttons and the open toggle all
   come from tl-ui.css, which owns them for both pages. What is left here is
   where it sits: the planner's map has a card floating over its left, so the
   dock starts clear of that and follows it when it opens and shuts.
   ------------------------------------------------------------------ */

/*
  IT DOES NOT MOVE FOR THE CARD.

  The dock used to start at the card's right edge and slide when the card
  opened and shut, so opening Route or TerraVita took a bite out of the chart
  and gave it back again. The activity page's panels open straight over its
  dock and the dock does nothing, which is right: the chart is about the whole
  route, and a card is a thing you opened for a moment on top of it.
*/
.tleagues-profile-dock {
  z-index: 6;
}

/* Open, the chart takes the whole card and the controls drop below it, which
   is what the activity page does with the same markup. */
.tleagues-profile-dock.is-chart-open .tl-track-dock-row {
  flex-wrap: wrap;
  row-gap: 0.35rem;
}

.tleagues-profile-dock.is-chart-open .tl-track-profile {
  order: -1;
  flex: 1 1 100%;
  width: 100%;
  /*
    MIN-HEIGHT, NOT HEIGHT.
    
    height did nothing here. Not a cascade problem: the CSS engine reported
    this rule as matching and more specific than the strip's 44px, and even
    `style.setProperty('height', '220px', 'important')` left offsetHeight at
    44, while min-height took effect immediately. Whatever the flex row does
    to this item's height, it leaves its minimum alone, so the minimum is
    what opens it. auto height lets the minimum govern.
  */
  height: auto;
  min-height: var(--tl-track-chart-h, clamp(160px, 24vh, 220px));
}

/*
  THE CONTROLS STAY ON THE RIGHT WHEN IT OPENS.

  Closed, the chart is flex: 1 1 auto and absorbs the room, so the buttons sit
  at the end of the line on their own. Open, the chart takes a line of its own
  and the buttons had nothing pushing them, so they packed left and the row
  ended in a metre of nothing.

  The activity page does this with margin-left: auto on its clock, which is
  the first of its right hand group. Here the distance and the heights moved
  to the foot row, so the first of that group is the colour buttons.
*/
.tleagues-profile-dock.is-chart-open .tl-track-colour-modes {
  margin-left: auto;
}

/* Below the desktop breakpoint the card is a sheet over the map, so the dock
   keeps the full width underneath it. */
@media (max-width: 991.98px) {
  .tleagues-profile-dock {
    left: 0.75rem !important;
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }
}

.tleagues-profile-readout {
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--bs-body-color, #16233f);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Manual recompute button; highlighted when the route changed since the last
   sample so the strip never silently shows a stale profile. */
.tleagues-profile-refresh {
  flex-shrink: 0;
  border: 0;
  background: none;
  color: var(--bs-secondary-color, #6c757d);
  padding: 2px 4px;
  border-radius: 0.5rem;
  cursor: pointer;
  line-height: 1;
}
.tleagues-profile-refresh:hover { color: var(--bs-primary, #1D5BD8); }
.tleagues-profile-dock.is-stale .tleagues-profile-refresh {
  color: var(--bs-primary, #1D5BD8);
  animation: tleagues-refresh-pulse 1.6s ease-in-out infinite;
}
@keyframes tleagues-refresh-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@media (prefers-reduced-motion: reduce) {
  .tleagues-profile-dock.is-stale .tleagues-profile-refresh { animation: none; }
}

.tleagues-profile-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/*
  The map's chips and its hint clear the dock, which is always on screen now.
  They used to be pushed up only while the old panel was open, by a class that
  is never set any more.
*/
.tl-route-edit-map-stats {
  bottom: calc(var(--tl-alt-dock-h, 92px) + 10px + env(safe-area-inset-bottom, 0px));
}
.tleagues-map-hint {
  bottom: calc(var(--tl-alt-dock-h, 92px) + 10px + env(safe-area-inset-bottom, 0px));
}

/* Scrub position marker on the map */
.tleagues-scrub-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e8a13a;
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Turnpoint markers */
.tleagues-wp {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bs-primary, #2e5bff);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: grab;
}
.tleagues-wp-start { border-color: #1f9d55; }

/* The point being dragged out of the line: it is not a waypoint yet, and it
   stops being anything at all if the drag is abandoned. */
.tleagues-wp-ghost {
  opacity: 0.75;
  border-style: dashed;
  cursor: grabbing;
  pointer-events: none;
}

/* Coarse pointers (touch): a 14px dot is too small to grab or long press, so
   grow the dot and extend an invisible ring around it for a finger-sized hit
   target without a bulky marker. */
@media (pointer: coarse) {
  .tleagues-wp { width: 24px; height: 24px; }
  .tleagues-wp::before {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
  }

  /* Free draw captures a mouse press and the Elevation readout follows the
     mouse, neither of which touch fires, so hide both rather than offer dead
     controls. */
  #tleagues-btn-freedraw,
  #tleagues-btn-elev { display: none; }
}

/* ------------------------------------------------------------------ */
/* Sidebar body: stacked panels                                        */
/* ------------------------------------------------------------------ */

.tleagues-panel-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Panels must keep their natural height and let the sidebar body scroll;
   without this, flex shrinks them to fit and clips the metric values. */
.tleagues-panel-body > * {
  flex-shrink: 0;
}

/* The panel of numbers is .tl-stat-* from tl-ui.css now, the same component
 * the activity page's statistics panel is built from, in its .tl-stat-rows
 * variant because 370px is too narrow for tiles. What is left here is what is
 * true of the planner and nothing else: two figures that carry a meaning in
 * their colour, and the width of the sections in this sidebar. */

/* Ascent is the headline number for half the sports here, and ochre is its
 * colour throughout TerraLoc. Amber is reserved for live and nothing else. */
.tleagues-value-ascent { color: var(--tl-terra, #A9743E); }
.tleagues-value-points { color: var(--tl-accent, #46603C); }

/* The sections are the panels in this sidebar, so they take the panel's own
 * corner radius rather than the smaller one a section uses when it is nested
 * inside a card on the activity page. */
.tleagues-panel-body > .tl-stat-section {
  border-radius: var(--tl-route-edit-radius, 1.15rem);
}

/* Steppers + speed slider */
.tleagues-stepper-grid { display: flex; flex-direction: column; gap: 0.55rem; }
.tleagues-slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0.15rem;
}
.tleagues-slider .form-range { margin: 0; }

/* The Bootstrap range track is nearly invisible on the dark face; give it a
   readable rail in both themes and a thumb in the theme's own primary, which
   terraloc-theme.css points at --tl-cta. The literal is only the fallback for
   a page that somehow loads this without the theme.

   EVERY RANGE IN THE PLANNER, not only the ones inside .tleagues-slider. The
   loop panel's distance slider is a form-range in a field of its own, so it
   sat outside this rule and wore Bootstrap's default green thumb next to a
   panel that has no green in it. */
.tleagues-slider .form-range::-webkit-slider-runnable-track,
.tleagues-loop-field .form-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 4px;
  background: rgba(var(--bs-emphasis-color-rgb, 33, 37, 41), .18);
}
.tleagues-slider .form-range::-moz-range-track,
.tleagues-loop-field .form-range::-moz-range-track {
  height: 6px; border-radius: 4px;
  background: rgba(var(--bs-emphasis-color-rgb, 33, 37, 41), .18);
}
.tleagues-slider .form-range::-webkit-slider-thumb,
.tleagues-loop-field .form-range::-webkit-slider-thumb {
  margin-top: -4px;
  background: var(--bs-primary, #1D5BD8);
}
.tleagues-slider .form-range::-moz-range-thumb,
.tleagues-loop-field .form-range::-moz-range-thumb {
  background: var(--bs-primary, #1D5BD8);
}
.tleagues-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tleagues-step-mid { text-align: center; }
.tleagues-step-value {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tleagues-step-btn {
  border: 0;
  background: none;
  font-size: 1.5rem;
  color: var(--bs-primary, #2e5bff);
  padding: 4px 6px;
  cursor: pointer;
  line-height: 1;
}
.tleagues-step-btn:hover { opacity: 0.8; }

/* Tools */
.tleagues-actions { display: flex; flex-direction: column; gap: 2px; }
.tleagues-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 0.65rem;
  background: none;
  padding: 8px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bs-body-color, #16233f);
  cursor: pointer;
  text-align: left;
}
.tleagues-action i {
  width: 18px;
  text-align: center;
  color: var(--bs-primary, #2e5bff);
}
.tleagues-action:hover { background: rgba(var(--bs-primary-rgb, 46, 91, 255), 0.08); }
.tleagues-action[aria-pressed="true"] { background: rgba(var(--bs-primary-rgb, 46, 91, 255), 0.14); }
.tleagues-action-danger i { color: #c04343; }
.tleagues-action-danger:hover { background: rgba(192, 67, 67, 0.08); }

/* ------------------------------------------------------------------ */
/* Map hint                                                             */
/* ------------------------------------------------------------------ */

/*
 * The line of text the map speaks with: the click guidance, the Elevation
 * tool's readout, and any toast the page has no toaster for.
 *
 * These two rules were lost when the dead .tl-task-edit-* block above them was
 * removed and the cut ran past its end. Nothing broke loudly. The element kept
 * being filled with the right text, and with no position it fell to the bottom
 * of the map wrap, 900px down a 900px viewport, one pixel below the fold: the
 * Elevation tool read the DEM correctly and printed the answer off screen.
 */
.tleagues-map-hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(3.6rem + env(safe-area-inset-bottom, 0px));
  z-index: 6;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(12, 20, 38, 0.72);
  color: #fff;
  font-size: 0.78rem;
  pointer-events: none;
  max-width: 70%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* An empty hint must take no room, or it is a floating grey smudge. */
.tleagues-map-hint:empty { display: none; }

/* ------------------------------------------------------------------ */
/* Free plan notice                                                     */
/* ------------------------------------------------------------------ */

/* Warm rather than loud: this is an explanation of where the edges are, not
   an advert shouting over the tool the athlete came to use. */
.tleagues-upsell .tl-route-edit-panel-body {
  border-left: 3px solid var(--tl-cta, #C86B3F);
}
.tleagues-upsell-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--bs-body-color, #16233f);
}
.tleagues-upsell-head i { color: var(--tl-cta, #C86B3F); }
.tleagues-upsell-body {
  margin: 6px 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--bs-secondary-color, #5b677d);
}
.tleagues-upsell-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--tl-cta, #C86B3F);
  text-decoration: none;
}
.tleagues-upsell-link:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ */
/* Routing loader                                                       */
/* ------------------------------------------------------------------ */

/* Sits over the middle of the map while a routable leg has no line yet. */
.tleagues-route-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 7;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.08));
  background: var(--tl-route-edit-overlay-bg-strong, rgba(255, 255, 255, 0.92));
  backdrop-filter: blur(10px);
  box-shadow: var(--tl-route-edit-shadow-sm, 0 10px 26px rgba(15, 23, 42, 0.12));
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--bs-body-color, #16233f);
  pointer-events: none;
}
.tleagues-route-loading.is-on { display: flex; }

.tleagues-route-loading-spinner {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid rgba(var(--bs-primary-rgb, 46, 91, 255), 0.25);
  border-top-color: var(--bs-primary, #2e5bff);
  animation: tleagues-route-spin 700ms linear infinite;
}
@keyframes tleagues-route-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .tleagues-route-loading-spinner { animation-duration: 2s; }
}

/* ------------------------------------------------------------------ */
/* Alternative routes                                                   */
/* ------------------------------------------------------------------ */

.tleagues-alts-head,
.tleagues-nogo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bs-secondary-color, #5b677d);
  margin-bottom: 8px;
}

.tleagues-alts-find,
.tleagues-nogo-clear {
  flex-shrink: 0;
  border: 0;
  border-radius: 0.5rem;
  background: rgba(var(--bs-primary-rgb, 46, 91, 255), 0.1);
  color: var(--bs-primary, #2e5bff);
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  cursor: pointer;
}
.tleagues-alts-find:hover,
.tleagues-nogo-clear:hover { background: rgba(var(--bs-primary-rgb, 46, 91, 255), 0.18); }
.tleagues-alts-find:disabled { opacity: 0.55; cursor: default; }

.tleagues-alts-list { display: flex; flex-direction: column; gap: 3px; }

/* One row per way round. The figures are right aligned so four options read
   as a column of distances rather than four sentences. */
.tleagues-alt-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0.6rem;
  background: none;
  padding: 7px 9px;
  cursor: pointer;
  text-align: left;
}
.tleagues-alt-row:hover { background: rgba(var(--bs-primary-rgb, 46, 91, 255), 0.07); }
.tleagues-alt-row.is-active {
  border-color: rgba(var(--bs-primary-rgb, 46, 91, 255), 0.45);
  background: rgba(var(--bs-primary-rgb, 46, 91, 255), 0.1);
}
.tleagues-alt-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--bs-body-color, #16233f);
}
.tleagues-alt-figs {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--bs-secondary-color, #5b677d);
  white-space: nowrap;
}
.tleagues-alts-empty,
.tleagues-nogo-empty {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--bs-secondary-color, #5b677d);
}

/* ------------------------------------------------------------------ */
/* No-go areas                                                          */
/* ------------------------------------------------------------------ */

/* The tool and its Clear all share a row: one button until there is
   something to clear. */
.tleagues-action-row { display: flex; align-items: center; gap: 4px; }
.tleagues-action-row .tleagues-action { flex: 1 1 auto; min-width: 0; }

.tleagues-nogo-clear {
  flex-shrink: 0;
  border: 0;
  border-radius: 0.5rem;
  background: rgba(192, 67, 67, 0.1);
  color: #c04343;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.tleagues-nogo-clear:hover { background: rgba(192, 67, 67, 0.18); }

/*
 * The four dots on the rim, the same grab handle the waypoint editor uses for
 * a radius. The wrapper is transparent and padded so only the dot shows while
 * the marker keeps a finger sized hit area around it.
 */
.tleagues-nogo-handle {
  background: transparent;
  border: 0;
  cursor: grab;
  padding: 6px;
}
.tleagues-nogo-handle:active { cursor: grabbing; }
.tleagues-nogo-handle-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid #C0392B;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

@media (pointer: coarse) {
  .tleagues-nogo-handle { padding: 10px; }
  .tleagues-nogo-handle-dot { width: 16px; height: 16px; }
}

/* The no-go tool is a restriction, so its icon is the warning colour rather
   than the primary one every other tool uses. Amber is reserved for live. */
#tleagues-btn-nogo i { color: #c04343; }
#tleagues-btn-nogo[aria-pressed="true"] { background: rgba(192, 67, 67, 0.14); }

/* Weather panel */
.tleagues-weather-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}
.tleagues-weather-body { display: flex; flex-direction: column; gap: 10px; }
.tleagues-weather-loading, .tleagues-weather-empty { color: var(--bs-secondary-color, #6c757d); font-size: 0.85rem; }
/* One forecast point: the card the head, conditions and levels sit in. */
.tleagues-wxp {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.08));
  border-radius: 0.65rem;
}
.tleagues-wxp-head {
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.tleagues-wxp-valid { font-weight: 500; color: var(--bs-secondary-color, #6c757d); font-size: 0.75rem; }
.tleagues-wxp-conditions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.8rem;
  margin: 4px 0;
}
.tleagues-wxp-conditions i { color: var(--bs-primary, #2e5bff); margin-right: 3px; }
.tleagues-wxp-levels { display: flex; flex-direction: column; gap: 2px; }
.tleagues-wxp-level {
  display: flex;
  gap: 8px;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.tleagues-wxp-alt { width: 62px; color: var(--bs-secondary-color, #6c757d); }
.tleagues-wxp-dir { width: 34px; font-weight: 700; }
/* Wind speed, and the gust in brackets after it. Tabular figures above keep
   the columns lined up down the list. */
.tleagues-wxp-spd { color: var(--bs-body-color, #16233f); }

/* Saved routes */
.tleagues-routes-head {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color, #6c757d);
  margin-bottom: 6px;
}
.tleagues-routes-list { display: flex; flex-direction: column; gap: 2px; }
.tleagues-route-item { display: flex; align-items: stretch; gap: 4px; }
.tleagues-route-load {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border: 0;
  background: none;
  border-radius: 0.65rem;
  padding: 7px 10px;
  cursor: pointer;
  text-align: left;
}
.tleagues-route-load:hover { background: rgba(var(--bs-primary-rgb, 46, 91, 255), 0.08); }
.tleagues-route-title { font-size: 0.85rem; font-weight: 600; color: var(--bs-body-color, #16233f); }
.tleagues-route-meta { font-size: 0.72rem; color: var(--bs-secondary-color, #6c757d); }
.tleagues-route-del,
.tleagues-route-vis {
  border: 0;
  background: none;
  color: var(--bs-secondary-color, #6c757d);
  padding: 0 8px;
  border-radius: 0.65rem;
  cursor: pointer;
}
.tleagues-route-del:hover { color: #c04343; background: rgba(192, 67, 67, 0.08); }
.tleagues-route-vis.is-public { color: var(--bs-primary, #1D5BD8); }
.tleagues-route-vis:hover { color: var(--bs-primary, #1D5BD8); background: rgba(var(--bs-primary-rgb, 29, 91, 216), 0.08); }
.tleagues-routes-empty { font-size: 0.8rem; color: var(--bs-secondary-color, #6c757d); }

/* ------------------------------------------------------------------ */
/* FAI record declaration dialog                                       */
/* ------------------------------------------------------------------ */
.tleagues-fai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1080;
  background: rgba(8, 14, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.tleagues-fai-modal {
  width: 100%;
  max-width: 460px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color);
  border-radius: 1rem;
  box-shadow: 0 24px 60px rgba(8, 14, 24, 0.4);
  overflow: hidden;
}
.tleagues-fai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.08));
}
.tleagues-fai-head i { color: var(--bs-primary, #1D5BD8); margin-right: 6px; }
.tleagues-fai-x {
  border: 0; background: none; font-size: 1.5rem; line-height: 1;
  color: var(--bs-secondary-color, #6c757d); cursor: pointer;
}
.tleagues-fai-body { padding: 16px 18px; overflow-y: auto; }
.tleagues-fai-head, .tleagues-fai-foot { flex-shrink: 0; }
.tleagues-fai-lbl {
  display: block;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--bs-secondary-color, #6c757d);
  margin: 12px 0 4px;
}
.tleagues-fai-lbl:first-child { margin-top: 0; }
.tleagues-fai-select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 0.6rem;
  border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.15));
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: 0.9rem;
}
.tleagues-fai-summary {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 0.7rem;
  background: rgba(var(--bs-primary-rgb, 29, 91, 216), 0.06);
  font-size: 0.86rem;
  line-height: 1.55;
}
.tleagues-fai-strong { font-weight: 700; }
.tleagues-fai-dim { color: var(--bs-secondary-color, #6c757d); }
.tleagues-fai-warn {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 0.6rem;
  background: rgba(245, 163, 0, 0.12);
  color: #8a6100;
  font-size: 0.82rem;
}
.tleagues-fai-warn a { font-weight: 700; }
[data-bs-theme="dark"] .tleagues-fai-warn { color: #f0b64a; }
.tleagues-fai-note { margin: 12px 0 0; font-size: 0.78rem; color: var(--bs-secondary-color, #6c757d); }
.tleagues-fai-done { display: flex; gap: 12px; align-items: flex-start; }
.tleagues-fai-done-icon { color: #1B8A5A; font-size: 1.6rem; line-height: 1.2; flex-shrink: 0; }
.tleagues-fai-done .tleagues-fai-note { margin-top: 4px; }

/* Signature pads (name + date + draw-to-sign) */
.tleagues-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.tleagues-sign-title { font-size: 0.8rem; font-weight: 700; margin-bottom: 5px; }
.tleagues-sign-row { display: flex; gap: 6px; margin-bottom: 6px; }
.tleagues-sign-row input { flex: 1 1 auto; min-width: 0; padding: 6px 8px; font-size: 0.84rem; }
.tleagues-sign-row .tleagues-sign-date { flex: 0 0 auto; width: 138px; }
.tleagues-sign-pad {
  position: relative;
  height: 86px;
  border: 1px dashed var(--bs-border-color, rgba(0, 0, 0, 0.25));
  border-radius: 0.5rem;
  background: var(--bs-body-bg);
  overflow: hidden;
}
.tleagues-sign-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.tleagues-sign-hint {
  position: absolute; left: 10px; bottom: 6px;
  font-size: 0.72rem; color: var(--bs-secondary-color, #9aa6b4); pointer-events: none;
}
.tleagues-sign-pad.has-ink .tleagues-sign-hint { display: none; }
.tleagues-sign-clear {
  position: absolute; top: 4px; right: 4px;
  border: 0; border-radius: 0.4rem; padding: 2px 7px; cursor: pointer;
  font-size: 0.8rem; color: var(--bs-secondary-color, #6c757d);
  background: rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.75);
}
.tleagues-sign-clear:hover { color: #c04343; }
@media (max-width: 520px) {
  .tleagues-sign { grid-template-columns: 1fr; }
}
.tleagues-fai-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.08));
}
.tleagues-fai-btn {
  border: 0;
  border-radius: 0.6rem;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.tleagues-fai-ghost { background: none; color: var(--bs-body-color); }
.tleagues-fai-ghost:hover { background: rgba(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.06); }
.tleagues-fai-primary { background: var(--bs-primary, #1D5BD8); color: #fff; }
.tleagues-fai-primary:hover { filter: brightness(1.05); }
.tleagues-fai-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ------------------------------------------------------------------ */
/* Mobile portrait: give the map more room by shrinking the terrain    */
/* profile strip; the chip/hint offsets above follow --tleagues-profile-h. */
/* ------------------------------------------------------------------ */
@media (max-width: 767.98px) {
  .tl-route-edit-page #tleagues-planner-main { --tleagues-profile-h: 150px; }
  .tleagues-profile-readout { font-size: 0.76rem; }

  /* The stat chips live at the bottom on mobile, so move the guidance hint
     below the top action row where it can wrap instead of overlapping them. */
  .tleagues-map-hint {
    top: calc(5.9rem + env(safe-area-inset-top, 0px));
    bottom: auto;
    max-width: calc(100% - 1.5rem);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    text-align: center;
    line-height: 1.28;
  }
}

@media (max-width: 575.98px) {
  .tl-route-edit-page #tleagues-planner-main { --tleagues-profile-h: 128px; }
  /* The readout can crowd the title on the narrowest phones; let it wrap
     to its own space and shrink rather than overflow. */
  .tleagues-profile-readout {
    text-align: right;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ------------------------------------------------------------------
   Legs

   A route is a chain of legs, each with its own sport. One leg looks like
   a single row and reads as a detail; a triathlon reads as the route.
   ------------------------------------------------------------------ */
.tleagues-legs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.tleagues-leg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.tleagues-leg:hover { background: rgba(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.04); }
.tleagues-leg:focus-visible {
  outline: 2px solid var(--bs-primary, #1D5BD8);
  outline-offset: 1px;
}
/* The leg being edited: the map draws its line thicker, and this is the
   matching signal in the list, so the two never disagree about which. */
.tleagues-leg.is-active {
  background: rgba(var(--bs-primary-rgb, 29, 91, 216), 0.10);
  border-color: rgba(var(--bs-primary-rgb, 29, 91, 216), 0.28);
}
/* The sport's own colour, the same value the map paints the line with. */
.tleagues-leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.tleagues-leg-name {
  font-weight: 600;
  color: var(--bs-body-color, #16233f);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tleagues-leg-km {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--bs-secondary-color, #6c757d);
  font-size: 0.8rem;
  white-space: nowrap;
}
.tleagues-leg-del {
  border: 0;
  background: none;
  padding: 0 2px;
  line-height: 1;
  font-size: 1.1rem;
  color: var(--bs-secondary-color, #6c757d);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease;
}
/* Revealed on hover or focus rather than always shown: a row is for
   selecting, and a delete button on every row invites the wrong click. */
.tleagues-leg:hover .tleagues-leg-del,
.tleagues-leg.is-active .tleagues-leg-del,
.tleagues-leg-del:focus-visible { opacity: 1; }
.tleagues-leg-del:hover { color: #c04343; }

.tleagues-leg-add {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px dashed var(--bs-border-color, rgba(0, 0, 0, 0.25));
  border-radius: 0.65rem;
  background: none;
  padding: 7px 10px;
  margin-bottom: 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--bs-secondary-color, #6c757d);
  cursor: pointer;
}
.tleagues-leg-add:hover {
  border-color: var(--bs-primary, #1D5BD8);
  color: var(--bs-primary, #1D5BD8);
}
.tleagues-leg-add i { font-size: 0.75rem; }

/* ------------------------------------------------------------------
   Sidebar fields
   ------------------------------------------------------------------ */
.tleagues-field { margin-top: 10px; }
.tleagues-field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--bs-secondary-color, #6c757d);
  margin-bottom: 4px;
}
.tleagues-select {
  width: 100%;
  border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.15));
  border-radius: 0.65rem;
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #16233f);
  padding: 7px 10px;
  font-size: 0.85rem;
  font-weight: 600;
}
.tleagues-select:focus-visible {
  outline: 2px solid var(--bs-primary, #1D5BD8);
  outline-offset: 1px;
}

/* The routing engine is working. Not a spinner: the line on the map is
   still the old one and still correct, so this is a hint, not a block. */
.tleagues-action.is-busy i {
  animation: tleagues-pulse 0.9s ease-in-out infinite;
}
@keyframes tleagues-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .tleagues-action.is-busy i { animation: none; opacity: 0.5; }
}

/* ==================================================================
   LOOPS FROM A PIN, A SPORT AND A DISTANCE

   The panel at the top of the sidebar. Almost everything here is
   borrowed: the section head is .tl-stat-*, the stepper and the slider
   are the planner's own, and the surface bar is painted with the same
   --tl-surface-* tokens the activity page uses. What is left is the
   pin row, the sport pills and the result rows.
   ================================================================== */

.tleagues-loop-field + .tleagues-loop-field { margin-top: 0.85rem; }

/* ---- where it starts ---- */

.tleagues-loop-start {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  border-radius: 0.75rem;
  background: var(--tl-white, #fff);
  cursor: pointer;
}

/* Nothing dropped yet: dashed, because it is an invitation. */
.tleagues-loop-start.is-empty {
  border-style: dashed;
  background: transparent;
}

/* Armed: the next map click is the pin, and the map's cursor says so too. */
.tleagues-loop-start.is-picking {
  border-style: solid;
  border-color: var(--tl-cta, #C86B3F);
  background: color-mix(in srgb, var(--tl-cta, #C86B3F) 8%, transparent);
}

.tleagues-loop-pin {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tl-cta, #C86B3F) 14%, transparent);
  color: var(--tl-cta, #C86B3F);
  font-size: 0.8rem;
}

.tleagues-loop-where {
  flex: 1 1 auto;
  min-width: 0;
}

.tleagues-loop-where b {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--tl-ink, #23281F);
}

.tleagues-loop-where span {
  display: block;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  color: var(--tl-dim, #8B8F80);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tleagues-loop-where em {
  font-style: normal;
  font-size: 0.85rem;
  color: var(--tl-muted, #5C6253);
}

/*
 * Use my location.
 *
 * AN UNDERLINED PHRASE HERE WAS TAKING A THIRD OF THE ROW and wrapping the
 * invitation beside it onto two lines, which made the one thing the row is
 * asking for the hardest thing in it to read. As an icon it is a shortcut
 * sitting quietly at the end, and the words live in the tooltip and the
 * aria-label, so nothing is lost to a screen reader.
 *
 * It echoes the pin badge opposite, same circle and same size, but outlined
 * rather than filled: that one reports where the start is, this one does
 * something, and a filled twin would read as a second status light.
 */
.tleagues-loop-here {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--tl-hairline-strong, #C9C5B2);
  border-radius: 999px;
  background: var(--tl-white, #fff);
  color: var(--tl-accent, #46603C);
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

/* The same button, in the colour of undoing rather than of finding. */
.tleagues-loop-clear {
  color: var(--tl-muted, #5C6253);
}

.tleagues-loop-clear:hover {
  border-color: var(--tl-danger, #B23A3A);
  background: color-mix(in srgb, var(--tl-danger, #B23A3A) 10%, var(--tl-white, #fff));
  color: var(--tl-danger, #B23A3A);
}

.tleagues-loop-clear:focus-visible {
  outline: 2px solid var(--tl-danger, #B23A3A);
  outline-offset: 1px;
}

.tleagues-loop-here:hover {
  border-color: var(--tl-accent, #46603C);
  background: color-mix(in srgb, var(--tl-accent, #46603C) 10%, var(--tl-white, #fff));
}

.tleagues-loop-here:focus-visible {
  outline: 2px solid var(--tl-accent, #46603C);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .tleagues-loop-here { transition: none; }
}

/* The pin on the map: what the loops come back to. */
/*
  THE START PIN IS EARTH, NOT ACTION.

  It was in the CTA terracotta, which is the colour of every button on the
  site: a pin the same colour as Save is a pin that reads as something to
  press. Ochre is the ground colour, and the pin is a place.
*/
.tleagues-loop-marker {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--tl-terra, #A9743E);
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

/* ---- which sport, and for biking which bike ---- */

/* Both are plain .tleagues-select controls, the same ones the planner uses
   for the active leg below, so there is nothing to style here. The panel used
   coloured chips of its own until they turned out to be a second way of
   asking the same question. */

/* ---- the promise the panel makes ---- */

.tleagues-loop-promise {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.9rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  font-size: 0.76rem;
  color: var(--tl-muted, #5C6253);
}

.tleagues-loop-promise i {
  flex: 0 0 auto;
  margin-top: 0.15rem;
  color: var(--tl-surface-gravel, #D19A3E);
}

/* ---- the buttons ---- */

.tleagues-loop-go {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.9rem;
  min-height: 42px;
  border: 0;
  border-radius: 0.75rem;
  background: var(--tl-cta, #C86B3F);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.tleagues-loop-go:disabled {
  opacity: 0.55;
  cursor: default;
}

.tleagues-loop-again {
  flex: 0 0 auto;
  min-height: 42px;
  margin-top: 0.9rem;
  padding: 0 0.8rem;
  border-radius: 0.75rem;
  border: 1px solid var(--tl-hairline-strong, #C9C5B2);
  background: none;
  color: var(--tl-ink, #23281F);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/*
  THE FOOT OF A RESULT, WHICH IS NOW THREE BUTTONS WIDE.

  It was a flex row with no wrap holding two buttons, one of them
  width: 100%, and it only ever just fitted. Start again made three and the
  third ran off the right edge of the card, cut in half, while Use this
  parcours broke its label over two lines to make room.

  So the row is deliberate rather than lucky: the primary takes a line of its
  own and the two secondaries share the next one. In route mode the primary is
  hidden, because a parcours on your own route has nothing to adopt, and the
  two that are left sit side by side on one line.

  The buttons' own margin-top belongs to the standalone use under the form.
  Inside the foot it would open a gap between the two rows as well, so the
  foot owns the spacing here.
*/
.tleagues-loop-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.tleagues-loop-foot .tleagues-loop-go {
  flex: 1 1 100%;
  width: auto;
  margin-top: 0;
}

.tleagues-loop-foot .tleagues-loop-again {
  /* 0 rather than auto: two of them split the line evenly whatever their
     labels say, which is what keeps a long translation from pushing its
     neighbour off the edge again. */
  flex: 1 1 0;
  min-width: 0;
  margin-top: 0;
  padding: 0 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- while it is searching ---- */

.tleagues-loop-progress {
  height: 4px;
  margin-top: 0.85rem;
  border-radius: 999px;
  background: var(--tl-hairline, #DFDCCB);
  overflow: hidden;
}

/* Indeterminate on purpose: the search does not know how many tries it
   will need, and a bar that pretends to would jump about. */
.tleagues-loop-progress i {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: var(--tl-cta, #C86B3F);
  animation: tleagues-loop-sweep 1.4s ease-in-out infinite;
}

@keyframes tleagues-loop-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.tleagues-loop-note {
  margin: 0.55rem 0 0;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  color: var(--tl-dim, #8B8F80);
}

.tleagues-loop-error {
  margin: 0.7rem 0 0;
  font-size: 0.78rem;
  color: var(--tl-cta, #C86B3F);
}

/* ---- what it found ---- */

.tleagues-loop-list {
  display: grid;
  gap: 0.5rem;
}

/* Said once, above the rows, when the set is the closest the search could
   find rather than the length that was asked for. */
.tleagues-loop-approx {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--tl-muted, #5C6253);
}

.tleagues-loop-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  border-radius: 0.85rem;
  background: var(--tl-white, #fff);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.tleagues-loop-row.is-on {
  border-color: color-mix(in srgb, var(--tl-cta, #C86B3F) 50%, transparent);
  background: color-mix(in srgb, var(--tl-cta, #C86B3F) 7%, var(--tl-white, #fff));
}

.tleagues-loop-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.tleagues-loop-name {
  font-size: 0.86rem;
  font-weight: 700;
  min-width: 0;
}

.tleagues-loop-km {
  flex: 0 0 auto;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tleagues-loop-figs {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.15rem;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.7rem;
  color: var(--tl-muted, #5C6253);
  font-variant-numeric: tabular-nums;
}

/* Ochre, which is what ascent wears everywhere on this site. */
.tleagues-loop-asc { color: var(--tl-terra, #A9743E); }

.tleagues-loop-unpaved {
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tl-surface-gravel, #D19A3E) 20%, transparent);
  color: var(--tl-ink, #23281F);
  font-size: 0.65rem;
  font-weight: 600;
}

/*
 * Tarmac reads in the surface bar's own paved colour, the way gravel does
 * above: the badge always names the thing the search went looking for, so it
 * should wear that thing's colour rather than gravel's.
 */
.tleagues-loop-unpaved.is-paved {
  background: color-mix(in srgb, var(--tl-surface-paved, #5A6B78) 20%, transparent);
}

/*
 * The caveat, and it is only ever a caveat.
 *
 * A loop that comes back down part of its own way still gets offered, but it
 * should not look like an achievement next to the unpaved pill, so it wears
 * no fill and the dimmest ink on the page. Rows with nothing to admit to
 * carry nothing here at all.
 */
.tleagues-loop-repeat {
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  border-radius: 999px;
  color: var(--tl-dim, #8B8F80);
  font-size: 0.65rem;
}

/* The same three colours the activity page paints its surface bar with. */
.tleagues-loop-bar {
  display: flex;
  height: 6px;
  margin-top: 0.5rem;
  border-radius: 999px;
  overflow: hidden;
  background: var(--tl-paper-deep, #EFEDE2);
}

.tleagues-loop-bar i { display: block; height: 100%; }

[data-bs-theme="dark"] .tleagues-loop-start,
[data-bs-theme="dark"] .tleagues-loop-row {
  background: var(--tl-panel, #1C1C15);
  border-color: var(--tl-hairline, #2F2F26);
}

[data-bs-theme="dark"] .tleagues-loop-start.is-empty { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  .tleagues-loop-progress i { animation: none; width: 100%; }
}


/* ==================================================================
   THE STAGE: A RAIL, A MAP, AND ONE CARD AT A TIME

   The sidebar used to be a column of nine open panels, 2447px of it in a
   370px slot. It is a card host now: the rail says which card is showing and
   the rest are not rendered. .tl-stage and .tl-rail come from tl-ui.css, so
   this file only says how the planner uses them.
   ================================================================== */

/* The rail is a flex child of the stage; the map and the panel share what is
   left, which is what .tl-route-edit-layout already arranged. */
.tl-stage.tl-route-edit-layout {
  min-height: 0;
}

/*
 * A CARD THAT OPENS ON NOTHING SAYS WHY.
 *
 * Other ways holds the alternatives and the weather, and both stay hidden
 * until there is a routed leg to have alternatives for. In a long scrolling
 * column that was invisible; as a rail item it is a button that opens a blank
 * card. The note only appears when every panel inside is hidden, so it goes
 * away on its own the moment there is something to show.
 */
.tleagues-card[data-empty]:not(:has(> :not(.d-none)))::before {
  content: attr(data-empty);
  display: block;
  padding: 0.9rem 0.2rem;
  color: var(--tl-muted, #5C6253);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Only the chosen card is in the flow. `hidden` does the work; this stops a
   stylesheet elsewhere from overriding it, which is the usual way a hidden
   panel comes back. */
.tleagues-card[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------
   The card the rail opens

   IT WAS A DRAWER, AND A DRAWER NEEDS A HANDLE. It slid in from the edge,
   filled the height whatever it held, and left a chevron stranded on its
   outer edge: a second control for the thing the rail already does, pointing
   at a panel the rail had just opened. The activity page opens its panels as
   cards and so does this now. It is as tall as what is in it, it sits beside
   the rail rather than against the window, and it appears rather than slides,
   because the rail button that summoned it is the animation.
   ------------------------------------------------------------------ */

.tl-route-edit-page .tl-stage .tl-route-edit-sidebar {
  /*
   * BELOW THE BASE MAP SWITCH. The switch sits at the top left of the map,
   * which is where this card opens, so it covered the thing completely and
   * changing to Satellite meant shutting the card first. --tl-mapstyle-h is
   * declared in map-controls.css, next to the control it measures.
   */
  top: calc(var(--tl-card-gap, 0.85rem) + var(--tl-mapstyle-h, 38px)
            + var(--tl-card-gap, 0.85rem));
  bottom: auto;
  left: calc(var(--tl-rail-w, 0px) + var(--tl-card-gap, 0.85rem));
  width: 344px;
  max-width: calc(100% - var(--tl-card-gap, 0.85rem) * 2);
  max-height: calc(100% - var(--tl-mapstyle-h, 38px) - var(--tl-card-gap, 0.85rem) * 3);
  height: auto;
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  border-radius: var(--tl-card-radius, 14px);
  box-shadow: 0 18px 44px -20px rgba(15, 23, 42, 0.45);
  overflow: hidden;

  /*
   * IT OPENS THE WAY THE TRACK PAGE'S PANELS OPEN.
   *
   * It used to slide in from the left, because it was a drawer hinged on the
   * edge of the window. It is a floating card now and there is no edge for it
   * to come from, so it appeared instantly while the same card on the track
   * page faded and dropped in: two components, one job, two behaviours.
   *
   * These are Bootstrap's own modal numbers, which is what the track panels
   * animate on: opacity .15s linear and a 50px drop over .3s ease-out.
   */
  opacity: 1;
  transform: none;
  visibility: visible;
  transition: opacity .15s linear, transform .3s ease-out, visibility 0s;
}

/*
  Shut is faded out and lifted, not slid away and not display:none, which
  cannot be transitioned. visibility waits for the fade so the card leaves
  the accessibility tree once it is actually gone.
*/
.tl-route-edit-page #tleagues-planner-main.tl-route-edit-sidebar-collapsed .tl-route-edit-sidebar {
  opacity: 0;
  transform: translateY(-50px);
  visibility: hidden;
  pointer-events: none;
  box-shadow: none;
  transition: opacity .15s linear, transform .3s ease-out, visibility 0s .3s;
}

/* The card is the height of its content, so its body is what scrolls when a
   card has more than the window holds. */
.tl-route-edit-page .tl-stage .tl-route-edit-sidebar-body {
  overflow-y: auto;
  min-height: 0;
}

/* The handle is gone from the markup; anything still reaching for it stops. */
.tl-route-edit-page .tl-route-edit-sidebar-handle {
  display: none;
}


/* ------------------------------------------------------------------
   The figures panel

   Beside the map on a wide screen, along the foot of it on a narrow one. One
   element either way: the stage is a row and becomes a column on a phone, so
   the panel only has to say how it packs.
   ------------------------------------------------------------------ */

/* The strip sits above the stage, so the stage takes what is left. */
.tl-route-edit-page .tl-stage.tl-route-edit-layout {
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.tleagues-figures {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.35rem 1.5rem;
  flex-wrap: wrap;
  padding: 0.45rem clamp(0.8rem, 2vw, 1.25rem);
  border-bottom: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  background: var(--tl-panel, #FAF9F4);
}

/* Label over value, the way the activity page sets a fact. */
.tleagues-fig {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.tleagues-fig .tl-stat-label {
  font-size: 0.58rem;
}

.tleagues-fig-v {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--tl-ink, #23281F);
}

/* Ochre is what ascent wears everywhere on this site. */
.tleagues-fig-v.is-asc { color: var(--tl-terra, #A9743E); }

.tleagues-fig-v small {
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--tl-dim, #8B8F80);
  margin-left: 0.12rem;
}

/*
 * The three route actions, at the far end of the strip.
 *
 * They keep .tl-route-edit-action-btn for their shape and their disabled
 * state, and lose the parts that only made sense floating on a map: the drop
 * shadow that lifted them off the terrain, and the translucency that let the
 * terrain through. In a strip they are just buttons on a panel.
 */
/* NOT .tleagues-actions: that name is taken by the tools list in the Draw
   card, which is a vertical stack, and reusing it stood these three on end. */
.tleagues-route-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  flex: 0 0 auto;
}

.tl-route-edit-page .tleagues-route-actions .tl-route-edit-action-btn {
  height: 30px;
  min-height: 30px;
  padding: 0 0.7rem;
  box-shadow: none;
  backdrop-filter: none;
  font-size: 0.75rem;
}

/* Waiting on the server. Disabled so it cannot be pressed twice, but not
   faded the way Bootstrap fades a disabled button: the spinner is the news. */
.tl-route-edit-page .tleagues-route-actions .tl-route-edit-action-btn[aria-busy="true"] {
  opacity: 1;
  cursor: progress;
}

/* The ground rides at the end of the strip: a bar with the names after it. */
.tleagues-fig-ground {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 200px;
  max-width: 420px;
}

.tleagues-ground-bar {
  display: flex;
  flex: 1 1 auto;
  min-width: 80px;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--tl-paper-deep, #EFEDE2);
}

.tleagues-ground-bar i { display: block; height: 100%; }

.tleagues-ground-list {
  flex: 0 0 auto;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.62rem;
  color: var(--tl-muted, #5C6253);
  white-space: nowrap;
}

/*
 * A NARROW PHONE GETS ONE ROW, NOT THREE.
 *
 * Four figures, a ground bar with its names, and three buttons wrapped to
 * three rows and took over a hundred pixels off the top of the map. None of
 * it was wrong, there was just too much of it for 364px of usable width.
 *
 * So: descent stands down, the ground keeps its bar and loses its words, the
 * type tightens, and the buttons lose their labels. Everything removed is in
 * Route, one tap away.
 */
@media (max-width: 575.98px) {
  .tleagues-figures {
    gap: 0.25rem 0.55rem;
    padding: 0.35rem 0.65rem;
  }

  .tleagues-fig--extra { display: none; }

  .tleagues-fig { gap: 0.25rem; }
  .tleagues-fig .tl-stat-label { font-size: 0.5rem; letter-spacing: 0.08em; }
  .tleagues-fig-v { font-size: 0.85rem; }
  .tleagues-fig-v small { font-size: 0.55rem; }

  /* The bar alone, as a hairline under the row: the shape of the ground
     without a line of text to carry it. */
  .tleagues-fig-ground {
    flex: 1 1 100%;
    max-width: none;
    gap: 0;
  }

  .tleagues-fig-ground .tl-stat-label { display: none; }
  .tleagues-ground-list { display: none; }
  .tleagues-ground-bar { height: 4px; min-width: 0; }

  /* And no room for the words on the buttons either. The title and the
     aria-label carry the name, the same as on the activity page. */
  .tl-route-edit-page .tleagues-route-actions .tl-route-edit-action-btn {
    width: 32px;
    min-width: 32px;
    padding: 0;
  }

  .tl-route-edit-page .tleagues-route-actions .tl-route-edit-action-btn > span {
    display: none;
  }
}

/*
 * THE HELPER LINE STOPS SITTING IN THE MIDDLE OF THE MAP.
 *
 * It was a dark pill pinned above the bottom edge, centred, which put it over
 * the route on a desktop and across a 205px map on a phone. It is guidance,
 * not a notice: it belongs in the corner, quiet, out of the way of the thing
 * it is describing.
 */
/* Nothing to say, nothing drawn. Without this an empty box still paints its
   pill in the corner of the map. */
.tleagues-map-hint:empty {
  display: none;
}

.tleagues-map-hint {
  left: 0.75rem;
  right: auto;
  bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
  transform: none;
  max-width: min(28rem, calc(100% - 1.5rem));
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tl-panel, #FAF9F4) 88%, transparent);
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  color: var(--tl-muted, #5C6253);
  font-size: 0.7rem;
}

/* ------------------------------------------------------------------
   On a phone the drawer is a sheet, not a drawer.

   Sliding in from the left it covered 359 of 390 px and left a useless strip
   of map down the side, which is the wrong answer for a card whose first
   instruction is to click the map. The rail is already along the bottom here
   and already carries order:99, so the panel only has to stop being absolute
   and it falls into the column between the map and the bar: map on top, sheet
   under it, bar at the foot. No height of the rail is written down anywhere,
   which is the point of doing it this way rather than with an offset.
   ------------------------------------------------------------------ */

@media (max-width: 767.98px) {
  .tl-route-edit-page .tl-stage .tl-route-edit-sidebar {
    position: static;
    top: auto;
    left: auto;
    width: auto;
    max-width: none;
    max-height: var(--tl-sheet-h, 58svh);
    border: 0;
    /* Rounded at the top, flat where it meets the bar: the same shape the
       track page's sheets take. */
    border-radius: var(--tl-card-radius, 14px) var(--tl-card-radius, 14px) 0 0;
    flex: 0 0 auto;
    border-right: 0;
    border-top: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
    box-shadow: 0 -14px 34px rgba(15, 23, 42, 0.16);
    transform: none;
  }

  /* Shut means gone, because a translated sheet still takes its row. */
  .tl-route-edit-page #tleagues-planner-main.tl-route-edit-sidebar-collapsed .tl-route-edit-sidebar {
    display: none;
  }

  /*
   * TWO INSTRUCTIONS, ONE OF THEM IN THE WAY.
   *
   * The map keeps a hint pinned near its bottom edge, which is right when the
   * map is the whole screen. With the sheet up the map is 238px and the hint
   * wraps to three lines in the middle of it, under a card that is already
   * telling you what to do. The map is quiet while the sheet is talking.
   */
  .tl-route-edit-page #tleagues-planner-main:not(.tl-route-edit-sidebar-collapsed) .tleagues-map-hint {
    display: none;
  }

  /* And when it is the only voice, give it the width to say it in one line. */
  .tleagues-map-hint {
    max-width: calc(100% - 1.5rem);
    font-size: 0.72rem;
  }

  /*
     THE HEADER STAYS ON A PHONE NOW, and the reason it used to go is worth
     keeping: it read "TERRALOC LEAGUES / Route Planner" in a kicker and an
     h1, 110px of the 490 a sheet has, spent on the name of the page you were
     already on. Hiding it was right for that header and is wrong for this
     one, which is 57px, says which of the six cards is open, and carries the
     button that shuts the sheet. On a phone the rail is a bar of 8px labels
     along the bottom, so the header is the only thing that says it plainly.
  */
  .tl-route-edit-page .tl-stage .tleagues-panel-head {
    padding-right: 0.7rem;
  }
}

/* ------------------------------------------------------------------
   THE CARD HEADER: one row, the card's own name, and the close button.

   Replaces a kicker plus an h1 up to 1.65rem, which spent two lines and
   about 70px of a phone's sidebar repeating the name of the page. These are
   the track panel's numbers, because they are the same component doing the
   same job: 1rem display type, one hairline under it, the button pushed to
   the end of the row.
   ------------------------------------------------------------------ */

.tl-route-edit-page .tleagues-panel-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0.7rem 0.85rem 0.6rem calc(0.85rem + env(safe-area-inset-left, 0px));
}

.tleagues-panel-head-copy { min-width: 0; }

.tl-route-edit-page .tleagues-panel-title {
  margin: 0;
  font-family: var(--tl-font-display, 'Bricolage Grotesque', system-ui, sans-serif);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--tl-ink, #23281F);
}

.tleagues-panel-crumb {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
  margin-top: 0.15rem;
}

.tleagues-panel-x {
  margin-left: auto;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  border-radius: 7px;
  background: var(--tl-white, #fff);
  color: var(--tl-muted, #5C6253);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}

.tleagues-panel-x:hover {
  border-color: var(--tl-hairline-strong, #C9C5B2);
  color: var(--tl-ink, #23281F);
}

.tleagues-panel-x:focus-visible {
  outline: 2px solid var(--tl-accent, #46603C);
  outline-offset: 1px;
}

/*
  THE HEADER IS PART OF THE CARD.

  It used to carry .tl-route-edit-sidebar-header as well, from the days when
  this was a drawer with a bar across the top: its own background, a backdrop
  blur, and a dark theme rule at one specificity class higher than anything
  written here could answer, so on the floating card it read as a second
  surface a shade off the one under it. Overriding four properties and losing
  to the fifth is not the fix; the element simply is not that component any
  more, so it no longer claims to be, and this rule owns it outright.

  The track page's panel header is the card's own colour with one hairline
  under it. These are the same component doing the same job.
*/
.tl-route-edit-page .tleagues-panel-head {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--tl-hairline, #DFDCCB);
}

/* The saved routes card with nothing in it. Was a non-breaking space. */
.tleagues-routes-empty {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin: 0;
  padding: 0.15rem 0.1rem;
  color: var(--tl-muted, #5C6253);
  font-size: 0.82rem;
  line-height: 1.45;
}

.tleagues-routes-empty i {
  color: var(--tl-dim, #8B8F80);
  margin-top: 0.15rem;
}

/* ------------------------------------------------------------------
   A SECTION INSIDE THE CARD IS NOT ANOTHER CARD.

   .tl-route-edit-panel carries a border, a 1rem radius, its own background
   and a shadow, which was right when the sidebar was a full height drawer and
   those panels were the only structure in it. Inside a 344px floating card
   they stack as four rounded boxes within a rounded box, each with its own
   edge a few pixels inside the last.

   The track page's cards divide their groups with a hairline and nothing
   else, so that is what these do. The rule is scoped to .tl-stage, so any
   other page that loads edit-route.css keeps its panels.
   ------------------------------------------------------------------ */

.tl-route-edit-page .tl-stage .tl-route-edit-panel {
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
}

/* The hairline goes between them, never above the first or below the last. */
.tl-route-edit-page .tl-stage .tl-route-edit-panel + .tl-route-edit-panel {
  border-top: 1px solid var(--tl-hairline, #DFDCCB);
}

/*
  The body kept 1rem of padding on all four sides to clear the border it no
  longer has. Vertical only now, so the sections sit in one column against the
  card's own gutter and the hairline runs the full width.
*/
.tl-route-edit-page .tl-stage .tl-route-edit-panel-body {
  padding-inline: 0;
  padding-block: 0.85rem;
}

/* Some cards hold a single section; it should not open with a gap. */
.tl-route-edit-page .tl-stage .tleagues-card > .tl-route-edit-panel:first-child
  > .tl-route-edit-panel-body {
  padding-top: 0.35rem;
}

/* A row that opens something says so, and turns its chevron when it has. */
.tleagues-action-disclose {
  position: relative;
}

.tleagues-action-caret {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--tl-dim, #8B8F80);
  transition: transform .15s ease;
}

.tleagues-action-disclose[aria-expanded="true"] .tleagues-action-caret {
  transform: rotate(180deg);
}

/* ------------------------------------------------------------------
   AND THE SECTIONS INSIDE THE SECTIONS.

   .tl-route-edit-panel stopped being a card in the rule above, but the
   statistics groups inside it are .tl-stat-section out of tl-ui.css, which
   carries its own 1rem radius, border and paper background. So the card still
   held boxes: a bordered box for Route, another for Ground, each with a green
   icon tile beside its heading.

   These are the track panel's own numbers, lifted from
   .tl-track-panel .tl-stat-section in track.css, because that is the page
   this is meant to match: no padding, no border, no background, no shadow,
   and the icon tile gone, so a heading is a heading and the hairline above it
   is the only divider.
   ------------------------------------------------------------------ */

.tl-route-edit-page .tl-stage .tl-stat-sections {
  gap: 0.9rem;
}

.tl-route-edit-page .tl-stage .tl-stat-section {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.tl-route-edit-page .tl-stage .tl-stat-section-head {
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.tl-route-edit-page .tl-stage .tl-stat-section-icon {
  display: none;
}

.tl-route-edit-page .tl-stage .tl-stat-section-title {
  font-size: 0.86rem;
}
