/*==============================================*\
|| TerraLoc – Live Tracking Layout (Web)       ||
\*==============================================*/

:root {
  --tl-live-sidebar-w: 420px;
  --tl-live-sidebar-w-md: 320px;
  --tl-live-handle-w: 20px;
  --tl-live-handle-h: 76px;
  --tl-live-top-offset: 0px;
}

.tl-live-page {
  margin: 0;
  padding: 0;
}

#tl-live-main {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--tl-live-top-offset, 0px));
  height: calc(100svh - var(--tl-live-top-offset, 0px));
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.06) 0%, rgba(15, 23, 42, 0) 28%),
    var(--bs-body-bg, #fff);
}

/* Overall layout */
.tl-live-layout {
  position: relative;
  display: flex;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Map */
.tl-live-map {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  background: var(--bs-tertiary-bg, #d7e3ef);
}

/* ------------------------------------------------------------------
   The sidebar

   IT WAS A PANEL FLOATING OVER THE LEFT OF THE MAP.

   Which put it exactly where MapLibre parks its own top-left controls, so
   the basemap picker spent its life hidden behind the athlete list. It is a
   real column on the right now: the map is the subject of this page and gets
   the left, the way the mockup draws it and the way every other map page on
   the site reads.
   ------------------------------------------------------------------ */
.tl-live-sidebar {
  order: 2;
  position: relative;
  flex: 0 0 var(--tl-live-sidebar-w);
  width: var(--tl-live-sidebar-w);
  max-width: min(92vw, var(--tl-live-sidebar-w));
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: none;
  border-left: 1px solid var(--tl-hairline, #DFDCCB);
  background: var(--tl-panel, #FAF9F4);
  transform: translateX(0);
  opacity: 1;
  transition: flex-basis 220ms ease, width 220ms ease, transform 220ms ease, opacity 220ms ease;
  z-index: 4;
}

/*
   Collapsed means no column at all, which takes more than flex-basis: 0.

   A flex item's min-width is auto, so it will not shrink below its content's
   min-content width: the three buttons in the panel header held the column
   open at 241px of empty panel beside a map that had stopped growing. The
   sidebar slid away and left its own footprint behind, which reads as a map
   that failed to load rather than a panel that closed.

   min-width: 0 is the part that actually collapses it. The rest keeps the
   hairline and the content from showing in a zero-width box.
*/
#tl-live-main.tl-live-sidebar-collapsed .tl-live-sidebar {
  flex-basis: 0;
  width: 0;
  min-width: 0;
  border-left-width: 0;
  overflow: hidden;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.tl-live-sidebar-header {
  padding: 1.1rem 1.25rem 0.9rem;
  padding-right: calc(1.25rem + env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--tl-hairline, #DFDCCB);
  background: var(--tl-panel, #FAF9F4);
}

/* The panel's own headline, not a caption on a floating box. */
.tl-live-title {
  font-family: var(--tl-font-display, 'Bricolage Grotesque', system-ui, sans-serif);
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.15;
  color: var(--tl-ink, #23281F);
}

.tl-live-subtitle {
  font-size: 0.8rem;
}

.tl-live-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.tl-live-header-copy {
  min-width: 0;
}

.tl-live-header-status {
  flex: 0 0 auto;
}

.tl-live-conn-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}

#tl-live-conn-last {
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tl-dim, #8B8F80);
}

/* ------------------------------------------------------------------
   The connection badge

   Three Bootstrap alert colours before: green, red and cyan, none of which
   mean anything on this site. --tl-live is reserved for "this athlete is out
   there right now", so the live state is the only chip that carries it and
   the only one that pulses. The other two are quiet, because "connected,
   polling" is not an alarm and a dropped socket is a degradation the page
   recovers from on its own.
   ------------------------------------------------------------------ */
.tl-live-conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--tl-font-mono, ui-monospace, monospace);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  text-transform: uppercase;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  color: var(--tl-muted, #5C6253);
  background: var(--tl-paper, #F3F2EC);
}

/* The dot, drawn before the word. It only pulses on the live state. */
.tl-live-conn-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.tl-live-conn-live {
  color: var(--tl-live, #C86B3F);
  background: var(--tl-live-bg, #F4E2D6);
  border-color: color-mix(in srgb, var(--tl-live, #C86B3F) 45%, transparent);
}

.tl-live-conn-live::before {
  background: var(--tl-live, #C86B3F);
  animation: tl-live-conn-pulse 2s ease-out infinite;
}

@keyframes tl-live-conn-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tl-live, #C86B3F) 55%, transparent); }
  70%  { box-shadow: 0 0 0 6px color-mix(in srgb, var(--tl-live, #C86B3F) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tl-live, #C86B3F) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .tl-live-conn-live::before { animation: none; }
}

.tl-live-conn-degraded,
.tl-live-conn-polling {
  color: var(--tl-muted, #5C6253);
}

/* ------------------------------------------------------------------
   The refresh control

   It used to be one of three full-width buttons in a row under the title:
   hide list, recenter, refresh. That row cost an athlete card's worth of
   height on every screen, the panel's own handle already hides the list,
   and recenter had no wired job left. What is left is the one action with
   something to do, drawn against the age it refreshes so the pair reads as
   "updated 12s, again?".
   ------------------------------------------------------------------ */
.tl-live-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--tl-dim, #8B8F80);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.tl-live-refresh-btn i {
  pointer-events: none;
  font-size: 0.78rem;
}

.tl-live-refresh-btn:hover,
.tl-live-refresh-btn:focus-visible {
  color: var(--tl-accent, #46603C);
  border-color: var(--tl-hairline, #DFDCCB);
  background: var(--tl-paper, #F3F2EC);
  outline: none;
}

/* A fetch that returns in 80ms looks like a dead button. The icon turns for
   as long as the request is in flight, and at least one full turn. */
.tl-live-refresh-btn[disabled] {
  cursor: default;
  color: var(--tl-dim, #8B8F80);
  background: transparent;
  border-color: transparent;
}

.tl-live-refresh-btn.is-busy i {
  animation: tl-live-refresh-spin 700ms linear infinite;
}

@keyframes tl-live-refresh-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .tl-live-refresh-btn.is-busy i { animation: none; }
}

@media (max-width: 991.98px) {
  .tl-live-header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .tl-live-header-status {
    width: 100%;
  }

  .tl-live-conn-wrap {
    justify-content: flex-start;
  }
}

.tl-live-sidebar-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tl-live-group-wrap {
  flex: 0 0 auto;
  padding: 0.8rem 0.75rem 0;
  margin: 0 !important;
}

/* Sidebar tabs: Athletes | Live Ops | Buddies (built by livetracking.js).
   The hidden attribute must always win, panes are toggled with it. */
.tl-live-sidebar-body [hidden] {
  display: none !important;
}

/* One track, one live tab: the same segmented control the basemap picker
   uses, so the panel and the map speak with one voice. */
.tl-live-tabs {
  flex: 0 0 auto;
  display: flex;
  align-self: flex-start;
  gap: 2px;
  margin: 0.75rem 1.25rem 0.25rem;
  padding: 3px;
  border-radius: 999px;
  background: var(--tl-paper, #F3F2EC);
}

.tl-live-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  background: none;
  height: 28px;
  padding: 0 0.85rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--tl-muted, #5C6253);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tl-live-tab-btn:hover {
  color: var(--tl-ink, #23281F);
}

.tl-live-tab-btn.active {
  background: var(--tl-ink, #23281F);
  color: var(--tl-paper, #F3F2EC);
}

.tl-live-tab-badge {
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--tl-cta, #C86B3F);
  color: var(--tl-cta-ink, #fff);
  font-size: 0.66rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: tl-live-ops-pulse 1.6s ease-in-out infinite;
}

@keyframes tl-live-ops-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Buddy groups pane (own tab, fills the sidebar body) */
.tl-live-buddies-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.75rem 0.75rem;
}

/* Live Ops pane (staff-only athlete status messages, own tab) */
.tl-live-ops-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.6rem 0.75rem 0.75rem;
}

/* The race board on a competition's live map (Race tab). Times mono and
   tabular so the column reads down; the racing rows carry the live colour. */
.tl-live-race-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.6rem 0.75rem 0.75rem;
}

.tl-live-race-head {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 0.5rem;
}

/* Several races that day: one chip each, the shown one filled. */
.tl-live-race-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.tl-live-race-chip {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--tl-hairline-strong);
  background: var(--tl-panel);
  color: var(--tl-ink);
  cursor: pointer;
}

.tl-live-race-chip[aria-pressed="true"] {
  background: var(--tl-accent);
  border-color: var(--tl-accent);
  color: var(--tl-accent-ink);
}

.tl-live-race-chip:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 2px;
}

.tl-live-race-note {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--tl-muted);
}

.tl-live-race-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tl-live-race-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.25rem;
  border-top: 1px solid var(--tl-hairline);
  font-size: 0.85rem;
}

.tl-live-race-row.is-on-map {
  cursor: pointer;
}

.tl-live-race-row.is-on-map:hover,
.tl-live-race-row.is-on-map:focus-visible {
  background: var(--tl-panel);
  outline: none;
}

.tl-live-race-pos,
.tl-live-race-fig {
  font-family: var(--tl-font-mono);
  font-variant-numeric: tabular-nums;
}

.tl-live-race-pos {
  font-weight: 600;
  color: var(--tl-ink);
}

.tl-live-race-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tl-ink);
}

.tl-live-race-name small {
  color: var(--tl-dim);
}

.tl-live-race-fig {
  font-size: 0.78rem;
  color: var(--tl-muted);
  text-align: right;
}

.tl-live-race-row.is-racing .tl-live-race-fig {
  color: var(--tl-live);
}

.tl-live-race-row.is-dsq .tl-live-race-fig,
.tl-live-race-row.is-missed .tl-live-race-fig {
  color: var(--tl-warning);
}

.tl-live-ops-alertbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #c62828;
  color: #fff;
  border-radius: 0.5rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.tl-live-ops-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* One message = one card with a severity color bar. Open (unacknowledged)
   alerts get a tinted background and a soft pulse so they cannot be missed. */
.tl-live-ops-row {
  display: block;
  padding: 0.5rem 0.6rem 0.5rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.1);
  border-left: 4px solid var(--tl-ops-color, #6c757d);
  background: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.02);
}

.tl-live-ops-row.is-open {
  border-color: color-mix(in srgb, var(--tl-ops-color, #c62828) 45%, transparent);
  border-left-color: var(--tl-ops-color, #c62828);
  background: color-mix(in srgb, var(--tl-ops-color, #c62828) 9%, transparent);
  animation: tl-live-ops-open-pulse 2s ease-in-out infinite;
}

@keyframes tl-live-ops-open-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tl-ops-color, #c62828) 35%, transparent); }
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--tl-ops-color, #c62828) 12%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .tl-live-ops-row.is-open,
  .tl-live-tab-badge {
    animation: none;
  }
}

.tl-live-ops-row.is-acked {
  opacity: 0.82;
}

.tl-live-ops-row.is-canceled {
  opacity: 0.7;
}

.tl-live-ops-canceled {
  font-size: 0.8rem;
  color: var(--bs-secondary-color, #6c757d);
}

.tl-live-ops-row-clickable {
  cursor: pointer;
}

.tl-live-ops-row-clickable:hover {
  background: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.06);
}

.tl-live-ops-row-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.tl-live-ops-chip {
  flex: 0 0 auto;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  white-space: nowrap;
}

.tl-live-ops-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-live-ops-time {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--bs-secondary-color);
  white-space: nowrap;
}

.tl-live-ops-locate {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: var(--bs-secondary-color);
}

.tl-live-ops-note {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--bs-body-color);
}

.tl-live-ops-acked {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  color: #2e7d32;
  font-weight: 600;
  font-size: 0.74rem;
}

.tl-live-ops-ack-btn {
  display: block;
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
}

.tl-live-ops-driver {
  margin-top: 0.35rem;
}

.tl-live-ops-driver-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--bs-body-color);
  font-weight: 600;
  font-size: 0.74rem;
}

.tl-live-ops-driver-line .fa-car-side {
  color: var(--bs-secondary-color);
}

.tl-live-ops-driver-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-live-ops-driver-change {
  flex: 0 0 auto;
  padding: 0.12rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
}

.tl-live-ops-driver-form {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tl-live-ops-driver-select {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.74rem;
}

.tl-live-ops-driver-assign {
  flex: 0 0 auto;
  padding: 0.3rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
}

.tl-live-ops-picked-up {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  color: #2e7d32;
  font-weight: 600;
  font-size: 0.74rem;
}

.tl-live-ops-pickup-btn {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
}

/* The buddies pane lives in its own sidebar tab now; the old <details>
   accordion header is redundant there, so it is hidden and the fold is kept
   open by the tab controller in livetracking.js. */
.tl-live-buddies-details > summary {
  display: none;
}

.tl-live-buddies-details > summary::-webkit-details-marker {
  display: none;
}

.tl-live-buddies-search {
  margin: 0.4rem 0 0.5rem !important;
}

.tl-live-buddies-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tl-live-buddies-section-label {
  padding: 0.35rem 0.25rem 0.1rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.tl-live-buddies-row-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tl-live-buddies-row {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.4rem 0.5rem;
  border-radius: 0.4rem;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s ease;
}

.tl-live-buddies-analyze {
  flex: 0 0 auto;
}

.tl-live-buddies-row:hover {
  background-color: rgba(13, 110, 253, 0.06);
  text-decoration: none;
  color: inherit;
}

.tl-live-buddies-row-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-weight: 600;
  font-size: 0.85rem;
}

.tl-live-buddies-row-meta {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  margin-top: 0.15rem;
}

.tl-live-buddies-empty {
  padding: 0.5rem 0.25rem;
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}

.tl-live-buddies-banner {
  margin: 0.4rem 0 0.25rem !important;
}

/* Athlete list */
.tl-live-athlete-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 0.75rem 0.5rem;
}

.tl-live-empty {
  padding: 0.75rem;
}

/* Athlete item */
/* ------------------------------------------------------------------
   An athlete in the list

   A borderless row on a tinted hover, with Bootstrap blue for the selected
   one. They are cards now, the way the mockup draws them: each athlete is a
   separate thing out on a hillside, and a stack of tinted rows reads as one
   table of rows instead.
   ------------------------------------------------------------------ */
.tl-live-in-view {
  margin: 0.5rem 0.75rem 0.55rem;
}

.tl-live-athlete-item {
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  border-radius: 10px;
  background: var(--tl-paper, #F3F2EC);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.05s ease;
}

.tl-live-athlete-item:hover {
  border-color: var(--tl-accent, #46603C);
}

/* The selected athlete keeps the accent edge, not a wash: the card behind it
   already separates it from the map. */
.tl-live-athlete-item.active {
  border-color: var(--tl-accent, #46603C);
  box-shadow: inset 3px 0 0 var(--tl-accent, #46603C);
}

.tl-live-athlete-item.tl-live-stopped .badge.bg-success-subtle {
  background-color: rgba(var(--bs-secondary-rgb, 108, 117, 125), 0.12) !important;
  color: var(--bs-secondary-color) !important;
}

.tl-live-athlete-item:active {
  transform: translateY(1px);
}

/* Athlete item layout */
.tl-live-athlete-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto; /* avatar | meta | right */
  gap: 0.4rem 0.6rem;
  align-items: center;
}

/* New: avatar column */
.tl-live-athlete-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

/* Bootstrap-ish small avatar */
.tl-live-athlete-avatar img {
  width: 35px;
  height: 35px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.tl-live-athlete-meta {
  min-width: 0;
}

.tl-live-athlete-name {
  font-weight: 600;
  font-size: 0.94rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.tl-live-athlete-name-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.tl-live-athlete-name-row .tl-live-athlete-name {
  flex: 1 1 auto;
  min-width: 0;
}

.tl-live-athlete-name-row .tl-live-follow-toggle,
.tl-live-athlete-name-row .tl-live-trail-toggle {
  margin-left: 0.15rem;
}

.tl-live-athlete-sub span + span {
  margin-left: 0.35rem;
}

.tl-live-athlete-right {
  min-width: 4.5rem;
}

/* Detail panel */
.tl-live-athlete-detail {
  flex: 0 0 auto;
  padding: 0.5rem;
  border-top: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.04));
  background-color: rgba(var(--bs-secondary-bg-rgb, 248, 249, 250), 0.95);
}

.tl-live-detail-card {
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.06));
  padding: 0.6rem 0.7rem;
  background-color: var(--bs-body-bg);
  box-shadow: var(--bs-box-shadow-sm);
}

.tl-live-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.tl-live-detail-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.tl-live-detail-avatar img {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.1));
}

/* Detail metrics grid */
.tl-live-detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem 0.6rem;
  font-size: 0.8rem;
}

.tl-live-detail-metrics > div {
  padding: 0.2rem 0.1rem;
}

.tl-live-detail-metrics .label {
  color: var(--bs-secondary-color);
}

.tl-live-detail-metrics .value {
  font-weight: 600;
}

/* Scrollbar tweaks for list */
.tl-live-athlete-list::-webkit-scrollbar {
  width: 6px;
}

.tl-live-athlete-list::-webkit-scrollbar-track {
  background: transparent;
}

.tl-live-athlete-list::-webkit-scrollbar-thumb {
  background-color: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.25);
  border-radius: 999px;
}

/* Follow button inside athlete list item */
.tl-live-follow-toggle,
.tl-live-trail-toggle {
  border: none;
  background: transparent;
  padding: 0.1rem 0.2rem;
  margin-left: 0.25rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--bs-secondary-color);
  flex: 0 0 auto;
}

.tl-live-follow-toggle.is-followed {
  color: var(--bs-warning); /* golden-ish */
}

.tl-live-trail-toggle.is-active {
  color: var(--bs-primary, #0d6efd);
}

.tl-live-trail-toggle.is-active.tl-live-trail-color-0 {
  color: #ff1744;
}

.tl-live-trail-toggle.is-active.tl-live-trail-color-1 {
  color: #ff9100;
}

.tl-live-trail-toggle.is-active.tl-live-trail-color-2 {
  color: #ffea00;
}

.tl-live-trail-toggle.is-active.tl-live-trail-color-3 {
  color: #76ff03;
}

.tl-live-trail-toggle.is-active.tl-live-trail-color-4 {
  color: #00c853;
}

.tl-live-trail-toggle.is-active.tl-live-trail-color-5 {
  color: #00e5ff;
}

.tl-live-trail-toggle.is-active.tl-live-trail-color-6 {
  color: #2979ff;
}

.tl-live-trail-toggle.is-active.tl-live-trail-color-7 {
  color: #d500f9;
}

/* External source chips (Garmin InReach, SPOT). Color applies always so users
 * can recognise the provider whether the chip is active or not. */
.tl-live-extra-sources {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.1rem;
}

.tl-live-trail-toggle-ext {
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.18rem 0.36rem;
  border-radius: 0.5rem;
  border: 1px solid currentColor;
  background: transparent;
  cursor: pointer;
}

.tl-live-trail-toggle-ext.is-active {
  color: #fff !important;
}

.tl-live-trail-color-ext-garmin {
  color: #00a4a6;
}
.tl-live-trail-toggle-ext.tl-live-trail-color-ext-garmin.is-active {
  background-color: #00a4a6;
  border-color: #00a4a6;
}

.tl-live-trail-color-ext-spot {
  color: #d35400;
}
.tl-live-trail-toggle-ext.tl-live-trail-color-ext-spot.is-active {
  background-color: #d35400;
  border-color: #d35400;
}

/* A followed athlete: a warm edge on their card, not a wash. The wash was
   Bootstrap amber at 4% opacity, which on cream is not a colour. */
.tl-live-followed {
  border-color: color-mix(in srgb, var(--tl-cta, #C86B3F) 45%, transparent);
}

/* The tab that pulls the sidebar back out. It rides the panel's left edge,
   and slides to the window edge when the panel is away. */
.tl-live-sidebar-handle {
  position: absolute;
  top: 50%;
  right: calc(var(--tl-live-sidebar-w) - 1px);
  transform: translateY(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tl-live-handle-w);
  height: var(--tl-live-handle-h);
  padding: 0;
  margin: 0;
  border: 1px solid var(--tl-hairline, #DFDCCB);
  border-right: none;
  border-radius: 16px 0 0 16px;
  background: var(--tl-panel, #FAF9F4);
  color: var(--tl-muted, #5C6253);
  box-shadow: -8px 0 20px -12px rgba(35, 40, 31, 0.4);
  cursor: pointer;
  transition: right 220ms ease, color 220ms ease, border-color 220ms ease;
}

#tl-live-main.tl-live-sidebar-collapsed .tl-live-sidebar-handle {
  right: env(safe-area-inset-right, 0px);
}

.tl-live-sidebar-handle:hover,
.tl-live-sidebar-handle:focus-visible {
  border-color: var(--tl-accent, #46603C);
  color: var(--tl-accent, #46603C);
  outline: none;
}

/* No rotation: updateSidebarHandleUi swaps fa-chevron-left / -right, and a
   180deg turn on top of that cancelled it out. */
.tl-live-sidebar-handle i {
  pointer-events: none;
  font-size: 0.95rem;
}

@media (max-width: 991.98px) {
  #tl-live-main {
    height: calc(100vh - var(--tl-live-top-offset, 0px));
    height: calc(100svh - var(--tl-live-top-offset, 0px));
  }

  .tl-live-sidebar {
    width: var(--tl-live-sidebar-w-md);
    max-width: min(92vw, var(--tl-live-sidebar-w-md));
  }

  /* On a phone the map has no width to spare, so the panel goes back to
     being an overlay: over the map, but still on the right. */
  .tl-live-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    flex-basis: auto;
    box-shadow: -18px 0 40px -24px rgba(35, 40, 31, 0.5);
  }

  /* The overlay keeps its width when it is closed: it slides off the right
     edge rather than collapsing a column, so the zero-width collapse the
     desktop layout needs would make it fold up instead of leave. */
  #tl-live-main:not(.tl-live-sidebar-ready) .tl-live-sidebar,
  #tl-live-main.tl-live-sidebar-collapsed .tl-live-sidebar {
    width: var(--tl-live-sidebar-w-md);
    min-width: 0;
    flex-basis: auto;
    border-left-width: 1px;
    transform: translateX(calc(100% + 1rem));
    opacity: 0;
    box-shadow: none;
    pointer-events: none;
  }

  .tl-live-sidebar-handle {
    right: calc(var(--tl-live-sidebar-w-md) - 1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tl-live-sidebar,
  .tl-live-sidebar-handle {
    transition: none;
  }
}

/* ==================================================
 * TerraLoc Live, on the site's own tokens
 *
 * THIS SECTION USED TO RE-DECLARE THE PANEL.
 *
 * It restated the sidebar, its handle, its header and all three connection
 * badges in Bootstrap variables, unscoped, several hundred lines after the
 * rules it was restating. Every one of them therefore won: the panel above
 * could say what it liked about the badge and this block painted it back to
 * Bootstrap's green, red and cyan. What is left here is the parts that have
 * no declaration further up.
 * ================================================== */

#tl-live-main {
  background-color: var(--tl-paper, #F3F2EC);
  color: var(--tl-ink, #23281F);
}

.tl-live-athlete-detail {
  background-color: rgba(var(--bs-secondary-bg-rgb, 248,249,250), 0.95);
  border-top-color: var(--bs-border-color);
}

/* Cards */
.tl-live-detail-card {
  background-color: var(--bs-body-bg);
  border-color: var(--bs-border-color);
  box-shadow: var(--bs-box-shadow-sm);
}

/* Text */
.tl-live-detail-metrics .label {
  color: var(--bs-secondary-color);
}

/* Avatars */
.tl-live-athlete-avatar img,
.tl-live-detail-avatar img {
  border-color: var(--bs-border-color);
}

/* Scrollbar */
.tl-live-athlete-list::-webkit-scrollbar-thumb {
  background-color: rgba(var(--bs-body-color-rgb, 33,37,41), 0.25);
}

/* ---------- DARK THEME TUNING ---------- */

[data-bs-theme="dark"] {

  #tl-live-main {
    background-color: var(--bs-body-bg);
  }

  .tl-live-sidebar,
  .tl-live-sidebar-header,
  .tl-live-sidebar-handle,
  .tl-live-athlete-detail,
  .tl-live-detail-card {
    background-image: none;
    backdrop-filter: none;
  }

  .tl-live-sidebar,
  .tl-live-sidebar-handle {
    background-color: var(--bs-body-bg);
  }

  .tl-live-sidebar-header {
    background-color: var(--bs-secondary-bg);
  }

  .tl-live-athlete-detail,
  .tl-live-detail-card {
    background-color: var(--bs-secondary-bg);
  }

  .tl-live-follow-toggle,
  .tl-live-trail-toggle {
    color: var(--bs-secondary-color);
  }

  .tl-live-follow-toggle.is-followed {
    color: var(--bs-warning);
  }

  .tl-live-trail-toggle.is-active {
    color: var(--bs-primary);
  }

  .tl-live-detail-card {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.45);
  }

}

/* MapLibre popup uses its own markup; align with Bootstrap theme vars */
.maplibregl-popup-content {
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #111);
  border: 1px solid var(--bs-border-color, rgba(0,0,0,.15));
  border-radius: .5rem;
  box-shadow: 0 .5rem 1rem rgba(0,0,0,.25);
  padding: .6rem .75rem;
  width: max-content;
  max-width: min(96vw, 52rem);
}

.maplibregl-popup-tip {
  border-top-color: var(--bs-body-bg, #fff) !important;
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-top-color: var(--bs-body-bg, #fff) !important;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-bottom-color: var(--bs-body-bg, #fff) !important;
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-left-color: var(--bs-body-bg, #fff) !important;
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-right-color: var(--bs-body-bg, #fff) !important;
}

/* Make the close button readable in dark mode too */
.maplibregl-popup-close-button {
  color: var(--bs-body-color, #111);
  opacity: .8;
}
.maplibregl-popup-close-button:hover {
  opacity: 1;
}

.tl-live-athlete-popup-title {
  font-weight: 600;
}

.tl-live-athlete-popup-title {
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.tl-live-athlete-popup-source {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  font-size: 0.75rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: transparent;
}

.tl-live-athlete-popup-subtitle {
  margin-bottom: 0.65rem;
}

.tl-live-athlete-popup-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(max-content, 1fr));
  gap: 0.65rem 1rem;
}

.tl-live-athlete-popup-metric {
  display: block;
  min-width: 0;
}

.tl-live-athlete-popup-label {
  display: block;
  white-space: nowrap;
}

.tl-live-athlete-popup-value {
  display: block;
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 767.98px) {
  .maplibregl-popup-content {
    width: auto;
  }

  .tl-live-athlete-popup-metrics {
    grid-template-columns: repeat(2, minmax(max-content, 1fr));
  }
}

@media (max-width: 575.98px) {
  .maplibregl-popup-content {
    width: auto;
    max-width: min(94vw, 24rem);
    padding: 0.55rem 0.65rem;
  }

  .tl-live-athlete-popup-metrics {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.4rem 0.75rem;
  }

  .tl-live-athlete-popup-subtitle {
    margin-bottom: 0.45rem;
  }

  .tl-live-athlete-popup-metric {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.65rem;
  }

  .tl-live-athlete-popup-label {
    white-space: normal;
    line-height: 1.2;
  }

  .tl-live-athlete-popup-value {
    text-align: right;
  }
}

/* Ground shadow under each athlete. A DOM marker (not a GPU circle layer) so it
 * stays locked to the athlete icon and label during motion: GPU layers update
 * MapLibre's async worker and visibly trail the synchronous DOM marker moves.
 * pointer-events:none so it never intercepts clicks meant for the marker. */
.tl-live-athlete-shadow {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  filter: blur(2.5px);
  pointer-events: none;
}

/* --- Per-athlete label marker (sibling DOM marker, above the athlete) ---
 * Glassy floating chip that hovers a few pixels above the athlete icon and
 * never rotates with map or heading, so name + altitude stay unambiguously
 * linked to their athlete even when several athletes cluster together.
 */
.tl-live-athlete-marker-label {
  font-family: inherit;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 9px 5px;
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.78);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-align: center;
  letter-spacing: -0.005em;
  opacity: 1;
  /* Slow opacity for fade-on-move; quicker for the hover/active styling. */
  transition:
    opacity 0.22s ease,
    transform 0.14s ease,
    box-shadow 0.14s ease,
    background-color 0.14s ease;
}

/* Map gesture in progress (pan/zoom/rotate): fade labels out so the names
 * don't jitter against their athletes while positions settle. */
#tl-live-main.is-map-moving .tl-live-athlete-marker-label {
  opacity: 0;
  pointer-events: none;
  /* Faster fade-out so the labels disappear the moment the gesture starts. */
  transition-duration: 0.08s, 0.14s, 0.14s, 0.14s;
}

/* Popup open: hide the floating name boxes; the popup already shows the
 * athlete's name + altitude in its title. Labels come back when it closes. */
#tl-live-main.is-popup-open .tl-live-athlete-marker-label {
  opacity: 0;
  pointer-events: none;
}

.tl-live-athlete-marker-label:hover {
  background: rgba(17, 24, 39, 0.88);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.tl-live-athlete-marker-label-name {
  color: rgba(255, 255, 255, 0.98);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.tl-live-athlete-marker-label-metrics {
  color: rgba(255, 255, 255, 0.66);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.tl-live-athlete-marker-label.is-hidden {
  display: none;
}

/* Followed athlete — warm amber accent on the name. */
.tl-live-athlete-marker-label.is-followed .tl-live-athlete-marker-label-name {
  color: #ffd166;
}

/* Selected athlete — subtle bright outline so it stands out in a cluster
 * without changing the colour-coding of the metrics. */
.tl-live-athlete-marker-label.is-selected {
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.tl-live-athlete-marker-label.is-offline {
  opacity: 0.55;
}

@media (prefers-color-scheme: light) {
  .tl-live-athlete-marker-label {
    /* Lighter chip variant; same hierarchy but plays nicer with light
     * basemaps. */
    background: rgba(255, 255, 255, 0.86);
    box-shadow:
      0 4px 14px rgba(15, 23, 42, 0.18),
      inset 0 0 0 1px rgba(15, 23, 42, 0.06);
  }
  .tl-live-athlete-marker-label:hover {
    background: rgba(255, 255, 255, 0.96);
  }
  .tl-live-athlete-marker-label-name {
    color: #0f172a;
  }
  .tl-live-athlete-marker-label-metrics {
    color: rgba(15, 23, 42, 0.62);
  }
  .tl-live-athlete-marker-label.is-followed .tl-live-athlete-marker-label-name {
    color: #b45309;
  }
}
/* ---------- Measure tool label ---------- */
.tl-measure-label-wrap {
  position: relative;
  width: 0;
  height: 0;
  pointer-events: none;
  will-change: transform;
}

.tl-measure-label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -100%);
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 4px 10px;
  line-height: 1.1;
  font: 500 12px/1.1 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  color: #111;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #cfcfcf;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

.tl-measure-label::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(255, 255, 255, 0.95);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.1));
}

/* Climb-rate tone. Going up is the accent, going down is the ochre TerraLoc
   already uses for descent; flat keeps the body colour rather than flickering
   between the two. The dead band is ±180 m/h, set in livetracking.js: it was
   -1.0 to +0.2 m/s, a paraglider's glide, which every sport here sits inside. */
.tl-live-climb-up {
  color: var(--tl-accent, #46603C);
}

.tl-live-climb-down {
  color: var(--tl-cta-hover, #A8512E);
}

.tl-live-climb-flat {
  color: var(--tl-ink, #23281F);
}

/* ------------------------------------------------------------------
 * Photos athletes share while live (modules/live-photos.js).
 * A thumbnail where it was taken, ringed in the athlete's colour; the
 * script sets --tl-live-photo-ring per athlete, paper when they have none.
 * ------------------------------------------------------------------ */
.tl-live-photo {
  --tl-live-photo-ring: var(--tl-paper);
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid var(--tl-live-photo-ring);
  border-radius: 10px;
  background-color: var(--tl-hairline);
  background-size: cover;
  background-position: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.tl-live-photo:hover {
  transform: scale(1.08);
}

.tl-live-photo:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 2px;
}

/* Athletes over photos, always: a photo must never hide who is out there,
 * nor the name and figures beside them. MapLibre draws every marker in one
 * layer in the order they were added, and photos arrive after athletes. */
.maplibregl-marker.tl-live-photo {
  z-index: 0;
}

/* By their own classes, not MapLibre's: the athlete marker repaints its
 * className when its look changes, which drops maplibregl-marker. */
#tl-live-map .tl-live-athlete-shadow,
#tl-live-map .tl-athlete-marker,
#tl-live-map .tl-live-athlete-marker-label {
  z-index: 2;
}

.maplibregl-marker.tl-live-photo.is-active {
  z-index: 1;
  width: 52px;
  height: 52px;
  border-width: 3px;
  box-shadow: 0 0 0 3px var(--tl-paper), 0 3px 10px rgba(0, 0, 0, 0.45);
}

/* Photos that would overlap are one stack: the newest on top, a second edge
 * behind it, and how many are in it. */
.tl-live-photo.is-stack {
  box-shadow:
    4px -4px 0 -1px var(--tl-paper),
    4px -4px 0 1px var(--tl-live-photo-ring),
    0 1px 4px rgba(0, 0, 0, 0.35);
}

/* A video: its still frame, with a play mark in the middle. */
.tl-live-photo-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(15, 15, 10, 0.6);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.tl-live-photo-play::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 55%;
  border-style: solid;
  border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent #fff;
  transform: translate(-50%, -50%);
}

.tl-live-photo-badge {
  position: absolute;
  top: -9px;
  right: -9px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--tl-ink);
  color: var(--tl-paper);
  font-family: var(--tl-font-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--tl-paper);
}

/* The open photo: a card docked in the one corner the map leaves free,
 * bottom left (the style picker has top left, the zoom and layer buttons top
 * right, the attribution bottom right). On a phone it is a sheet across the
 * bottom of the map. Over the map, under the sidebar drawer. */
.tl-live-photo-card {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 3;
  width: min(340px, calc(100% - 24px));
  overflow: hidden;
  border: 1px solid var(--tl-hairline);
  border-top: 3px solid var(--tl-live-photo-ring, var(--tl-hairline));
  border-radius: 12px;
  background: var(--tl-panel, var(--tl-paper));
  color: var(--tl-ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  animation: tl-live-photo-in 0.18s ease-out;
}

@keyframes tl-live-photo-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.tl-live-photo-media {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--tl-hairline);
  cursor: zoom-in;
}

.tl-live-photo-media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(44vh, 320px);
  object-fit: cover;
}

/* A clip plays in the card, on black so a portrait clip is not stretched. */
.tl-live-photo-media.is-video {
  position: relative;
  cursor: default;
  background: #000;
}

.tl-live-photo-media video {
  display: block;
  width: 100%;
  height: min(44vh, 320px);
  object-fit: contain;
  background: #000;
}

.tl-live-photo-expand {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 15, 10, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}

.tl-live-photo-expand:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 2px;
}

.tl-live-photo-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem 0.65rem;
}

.tl-live-photo-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tl-live-photo-who strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-live-photo-who span,
.tl-live-photo-count {
  color: var(--tl-muted);
  font-family: var(--tl-font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.tl-live-photo-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}

.tl-live-photo-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--tl-hairline);
  border-radius: 50%;
  background: transparent;
  color: var(--tl-ink);
  font-size: 0.8rem;
}

.tl-live-photo-step:hover:not(:disabled) {
  border-color: var(--tl-accent);
  color: var(--tl-accent);
}

.tl-live-photo-step:disabled {
  opacity: 0.35;
  cursor: default;
}

.tl-live-photo-step:focus-visible,
.tl-live-photo-media:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 2px;
}

@media (max-width: 767.98px) {
  .tl-live-photo-card {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
  }

  .tl-live-photo-media img {
    max-height: 38vh;
  }

  .tl-live-photo-media video {
    height: 38vh;
  }

  /* The drawer tab rides at half height, which on a phone is inside the
   * sheet and on top of its close button. Above the sheet it meets the map
   * buttons, and on a small phone there is no room between the two, so it
   * steps out while a sheet is open and comes back when the sheet closes. */
  .tl-live-page:has(.tl-live-photo-card) .tl-live-sidebar-handle {
    display: none;
  }
}

/* Moderation: Report for anyone signed in, Remove on their own and for
 * staff on anything, and for staff on a hidden item why, with Restore. */
.tl-live-photo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0 0.75rem 0.65rem;
}

.tl-live-photo-action {
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--tl-hairline);
  border-radius: 999px;
  background: transparent;
  color: var(--tl-muted);
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
}

.tl-live-photo-action:hover:not(:disabled) {
  border-color: var(--tl-ink);
  color: var(--tl-ink);
}

.tl-live-photo-action.is-remove:hover:not(:disabled) {
  border-color: var(--tl-danger);
  color: var(--tl-danger);
}

.tl-live-photo-action:disabled {
  opacity: 0.6;
  cursor: default;
}

.tl-live-photo-action:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 2px;
}

.tl-live-photo-hidden-note {
  margin-right: auto;
  color: var(--tl-danger);
  font-size: 0.8rem;
}

/* What staff see of an item the reports hid: still on their map, marked. */
.tl-live-photo.is-hidden {
  opacity: 0.55;
  border-style: dashed;
  border-color: var(--tl-danger);
}

/* Close, over a photo: a frosted dark disc, because a photo can be any
 * colour and white on a dark scrim reads on snow and on forest alike. The
 * cross is drawn rather than a "×" character, which sits off centre in most
 * faces. */
.tl-live-photo-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 15, 10, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2), 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.tl-live-photo-x::before,
.tl-live-photo-x::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  border-radius: 1px;
  background: #fff;
}

.tl-live-photo-x::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.tl-live-photo-x::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.tl-live-photo-x:hover {
  background: rgba(15, 15, 10, 0.78);
  transform: scale(1.06);
}

.tl-live-photo-x:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 2px;
}

.tl-live-photo-x-lg {
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
}

.tl-live-photo-x-lg::before,
.tl-live-photo-x-lg::after {
  width: 16px;
}

/* Full screen, over everything the site draws, header included. */
.tl-live-photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 64px 72px 24px;
  background: rgba(10, 10, 7, 0.92);
  animation: tl-live-photo-fade 0.15s ease-out;
}

@keyframes tl-live-photo-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tl-live-photo-full {
  max-width: 100%;
  max-height: calc(100% - 3rem);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.tl-live-photo-caption {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  color: #fff;
}

.tl-live-photo-caption span {
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--tl-font-mono);
  font-size: 0.85rem;
}

.tl-live-photo-side {
  position: absolute;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateY(-50%);
  cursor: pointer;
}

.tl-live-photo-side:hover {
  background: rgba(255, 255, 255, 0.24);
}

.tl-live-photo-side:focus-visible {
  outline: 2px solid var(--tl-accent);
  outline-offset: 2px;
}

.tl-live-photo-side.is-prev {
  left: 16px;
}

.tl-live-photo-side.is-next {
  right: 16px;
}

@media (max-width: 575.98px) {
  .tl-live-photo-viewer {
    padding: 64px 12px 24px;
  }

  .tl-live-photo-side {
    top: auto;
    bottom: 20px;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tl-live-photo-card,
  .tl-live-photo-viewer {
    animation: none;
  }
}
