/* Koeru — the live page.
 *
 * Dark chrome, light map. Surfaces come from app.css (`--surface-*`, mixed from
 * `night` towards `snow`); nothing here adds a colour that is not a token.
 *
 * `signal` yellow is the live dot, the runner's position, progress — and, on
 * this page, the accent for the actions that matter: Send, Cheer, the active
 * tab, milestone banners. Yellow on `night` passes for large text and fills.
 */

/* --- layout ------------------------------------------------------------- */

.live-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  height: calc(100dvh - var(--topbar-h));
  min-height: 560px;
}

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface-1); border-left: 1px solid var(--hairline);
}

/* --- map ---------------------------------------------------------------- */

.map-wrap { position: relative; flex: 1; min-height: 260px; background: var(--surface-2); overflow: hidden; }
#map { position: absolute; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 10px; }

.map-top {
  position: absolute; left: 14px; top: 14px; z-index: 3;
  display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none;
}
.badge, .watching {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px;
  border-radius: var(--k-radius); font-size: 13px; white-space: nowrap;
}
.badge { background: var(--k-night); color: var(--k-snow); }
.badge.live::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--k-signal);
  box-shadow: 0 0 0 0 rgb(255 212 0 / .6); animation: live-pulse 2.2s var(--k-ease) infinite;
}
.badge.stale { color: var(--k-glacier); }
.watching { background: rgb(19 28 46 / .78); color: var(--k-glacier); backdrop-filter: blur(6px); }
.watching svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.watching b {
  color: var(--k-snow); font-variation-settings: 'wdth' 88, 'wght' 700;
  font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums;
}

.map-notes { position: absolute; left: 14px; bottom: 34px; z-index: 3; display: grid; gap: 6px; }
.map-note {
  margin: 0; padding: 6px 10px; border-radius: var(--k-radius);
  background: rgb(19 28 46 / .85); color: var(--k-glacier); font-size: 13px;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgb(255 212 0 / .55); }
  70%, 100% { box-shadow: 0 0 0 8px rgb(255 212 0 / 0); }
}

/* --- reactions and celebrations over the map ---------------------------- */

.floats { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }

.float {
  position: absolute; font-size: 30px; line-height: 1;
  transform: translate(-50%, -50%);
  animation: float-up 2.4s cubic-bezier(.2, .7, .3, 1) forwards;
  filter: drop-shadow(0 2px 3px rgb(19 28 46 / .35));
}
@keyframes float-up {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  12%  { opacity: 1; transform: translate(-50%, -80%) scale(1.15); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), -900%) scale(.9) rotate(var(--rot)); }
}

.float-label {
  position: absolute; transform: translate(-50%, 18px);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--k-signal); color: var(--k-night);
  font-size: 13px; font-variation-settings: 'wdth' 100, 'wght' 650;
  animation: label-pop 2.4s var(--k-ease) forwards;
}
@keyframes label-pop {
  0% { opacity: 0; transform: translate(-50%, 28px); }
  15%, 70% { opacity: 1; transform: translate(-50%, 18px); }
  100% { opacity: 0; transform: translate(-50%, 6px); }
}

.confetti {
  position: absolute; width: 8px; height: 12px; border-radius: 2px;
  animation: confetti 1.8s cubic-bezier(.15, .6, .35, 1) forwards;
}
.confetti.c0 { background: var(--k-signal); }
.confetti.c1 { background: var(--k-snow); }
.confetti.c2 { background: var(--k-glacier); }
@keyframes confetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

.celebrate {
  position: absolute; left: 50%; top: 18px; z-index: 5;
  transform: translate(-50%, -140%); opacity: 0; pointer-events: none;
}
.celebrate.is-on { animation: banner 4.2s var(--k-ease) forwards; }
.celebrate .banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px 12px 12px;
  border-radius: 12px; background: var(--k-night); color: var(--k-snow);
  border: 1px solid var(--k-signal); box-shadow: 0 14px 40px rgb(19 28 46 / .45);
  white-space: nowrap;
}
.banner-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--k-signal); color: var(--k-night);
}
.banner-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.banner-text {
  display: grid; font-size: 20px; line-height: 1.15;
  font-variation-settings: 'wdth' 125, 'wght' 800; letter-spacing: -.01em;
}
.banner-text small {
  font-size: 13px; color: var(--k-glacier); letter-spacing: 0;
  font-variation-settings: 'wdth' 100, 'wght' 400; font-variant-numeric: tabular-nums;
}
.banner.is-finish .banner-text, .banner.is-halfway .banner-text { font-size: 26px; }
@keyframes banner {
  0%   { opacity: 0; transform: translate(-50%, -140%); }
  10%  { opacity: 1; transform: translate(-50%, 6%); }
  14%  { transform: translate(-50%, 0); }
  86%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -140%); }
}

@media (prefers-reduced-motion: reduce) {
  .float, .confetti, .float-label { display: none; }
  .celebrate.is-on { animation: none; opacity: 1; transform: translate(-50%, 0); }
  .badge.live::before { animation: none; }
}

/* --- stats, progress, elevation ------------------------------------------ */

.stats {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface-1); border-top: 1px solid var(--hairline);
}
.stat { display: grid; gap: 3px; padding: 11px 18px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--hairline); }
.stat .label { font-size: 13px; color: var(--k-glacier); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .value {
  font-size: clamp(20px, 2vw, 27px); line-height: 1.1; white-space: nowrap;
  font-variation-settings: 'wdth' 88, 'wght' 700;
  font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums;
}
.stat .value small {
  margin-left: 3px; font-size: 13px; color: var(--k-glacier);
  font-variation-settings: 'wdth' 100, 'wght' 400;
}

.progress { padding: 8px 18px 10px; background: var(--surface-1); border-top: 1px solid var(--hairline); }
.progress .bar { position: relative; height: 4px; border-radius: 2px; background: rgb(175 196 208 / .22); overflow: hidden; }
.progress .bar::before { content: none; }
.progress .bar .fill { position: static; margin: 0; height: 100%; background: var(--k-signal); border-radius: 2px; transition: width .6s var(--k-ease); }
.progress-meta {
  display: flex; justify-content: space-between; gap: 8px; margin-top: 6px;
  font-size: 13px; color: var(--k-glacier); font-variant-numeric: tabular-nums;
}

.strip-el {
  position: relative; height: 64px; cursor: ew-resize; touch-action: none;
  background: var(--surface-1); border-top: 1px solid var(--hairline);
}
.strip-el:focus-visible { outline: 2px solid var(--k-glacier); outline-offset: -2px; }
.strip-el:hover .el-line { stroke: var(--k-snow); }
.strip-el svg { width: 100%; height: 100%; display: block; }
.strip-el .el-area { fill: var(--surface-3); }
.strip-el .el-line { stroke: var(--k-glacier); }
.strip-el .el-done { fill: rgb(19 28 46 / .45); }
.strip-el .el-cursor { stroke: var(--k-signal); }
.strip-el .labels {
  position: absolute; inset: 4px 10px auto auto; display: flex; flex-direction: column;
  align-items: flex-end; gap: 2px; font-size: 11px; color: var(--k-glacier);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.strip-el .labels span:last-child { order: -1; }

/* --- media on the map ------------------------------------------------------ */

/* A photo is the most interesting thing on a map, so it is the marker: the
 * picture itself, on a pin. The old 7px dot was invisible and unclickable. */
/* The map owns this one's transform. Nothing here may set it. */
.mpin-anchor { line-height: 0; }

.mpin {
  position: relative; padding: 0; border: 0; background: none; cursor: pointer;
  display: block; line-height: 0; transform-origin: bottom center;
  transition: transform .16s var(--k-ease), opacity .3s var(--k-ease);
}
.mpin-frame {
  position: relative; z-index: 1; display: block; width: 34px; height: 34px;
  border-radius: 50%; overflow: hidden;
  background: var(--k-granite); border: 2px solid var(--k-snow);
  box-shadow: 0 4px 14px rgb(19 28 46 / .45);
}
.mpin img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mpin-blank { display: block; width: 100%; height: 100%; background: var(--k-granite); }
/* The pin's point: the same snow border, turned 45°. */
/* The tail, tucked UNDER the photo so only its point shows: a square edge
 * crossing the circle is what made the marker look like a sticker. */
.mpin::after {
  content: ''; position: absolute; z-index: 0; left: 50%; bottom: -3px;
  width: 12px; height: 12px; margin-left: -6px; border-radius: 0 0 3px 0;
  background: var(--k-snow); transform: rotate(45deg);
  box-shadow: 3px 3px 6px rgb(19 28 46 / .3);
}
.mpin-play {
  position: absolute; right: -3px; bottom: -3px;
  display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  background: var(--k-night); color: var(--k-snow); border: 2px solid var(--k-snow);
}
.mpin-play svg { width: 8px; height: 8px; fill: currentColor; }
.mpin-label {
  position: absolute; bottom: calc(100% + 8px); left: 50%; translate: -50% 0;
  max-width: 180px; padding: 5px 9px; border-radius: 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; line-height: 1.2;
  background: var(--k-night); color: var(--k-snow); font-size: 12px;
  opacity: 0; transition: opacity .16s var(--k-ease); pointer-events: none;
}
.mpin:hover, .mpin:focus-visible { transform: scale(1.18) translateY(-2px); }
.mpin:hover .mpin-label, .mpin:focus-visible .mpin-label { opacity: 1; }
.mpin:hover .mpin-frame, .mpin:focus-visible .mpin-frame { border-color: var(--k-signal); }

/* Two shots a minute apart land on the same spot: the later one steps aside
 * rather than shrinking — every marker is the same size, so none of them reads
 * as more important than another. */
.mpin.is-tucked { transform: translate(12px, -4px); }
.mpin.is-tucked:hover { transform: translate(12px, -6px) scale(1.18); }

/* Replay: not yet taken. */
.mpin.is-future { opacity: .28; filter: grayscale(1); }
.mpin.is-arriving { animation: mpin-pop .7s var(--k-ease); }
@keyframes mpin-pop {
  0% { transform: scale(.4); }
  55% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@media (max-width: 640px) {
  .mpin-frame { width: 30px; height: 30px; }
  .mpin.is-tucked { transform: translate(10px, -3px); }
}

/* --- replay timeline ------------------------------------------------------ */

.timeline { padding: 10px 14px 8px; background: var(--surface-1); border-top: 1px solid var(--hairline); }

.row { display: flex; align-items: center; gap: 10px; }
.play {
  flex: none; width: 34px; height: 34px; font-size: 13px; color: var(--k-night);
  background: var(--k-snow); border: none; border-radius: 50%; cursor: pointer;
}
.play.on { background: var(--k-glacier); }
.bar { position: relative; flex: 1; height: 34px; min-width: 0; }
.bar::before {
  content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 6px; margin-top: -3px;
  border-radius: 999px; background: rgb(175 196 208 / .22);
}
.bar .fill {
  position: absolute; top: 50%; left: 0; height: 6px; margin-top: -3px;
  border-radius: 999px; background: var(--k-snow); pointer-events: none;
}
/* The handle IS the current position, which is exactly what signal means. */
.knob {
  position: absolute; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%; background: var(--k-signal); border: 3px solid var(--k-night);
  box-shadow: 0 1px 6px rgb(0 0 0 / .5); pointer-events: none; z-index: 5;
}
.bar:focus-within .knob { box-shadow: 0 1px 6px rgb(0 0 0 / .5), 0 0 0 4px rgb(255 212 0 / .35); }
.tick {
  position: absolute; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  padding: 0; overflow: hidden; border: 2px solid var(--k-snow); border-radius: 50%;
  background: var(--k-granite); box-shadow: 0 1px 4px rgb(0 0 0 / .45);
  cursor: pointer; z-index: 4; transition: transform .12s var(--k-ease);
}
.tick img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A clip whose poster frame never arrived still says it is a clip. */
.tick-icon { width: 10px; height: 10px; margin: 3px; fill: var(--k-snow); }
/* The picture is small; the target is not. */
.tick::after { content: ''; position: absolute; inset: -10px; border-radius: 50%; }
.tick:hover, .tick:focus-visible { transform: scale(1.35); border-color: var(--k-signal); z-index: 6; }
.tick.video { border-color: var(--k-glacier); }
.tick.is-now { border-color: var(--k-signal); transform: scale(1.3); }
.tick-label {
  position: absolute; bottom: calc(100% + 10px); left: 50%; translate: -50% 0;
  max-width: 220px; padding: 5px 9px; border-radius: 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  background: var(--k-night); color: var(--k-snow); font-size: 12px; line-height: 1.2;
  font-variant-numeric: tabular-nums; opacity: 0; pointer-events: none;
  transition: opacity .14s var(--k-ease);
}
.tick:hover .tick-label, .tick:focus-visible .tick-label { opacity: 1; }
.tick.video { background: var(--k-glacier); }
.bubble {
  position: absolute; top: 30px; transform: translateX(-50%); display: flex; gap: 6px;
  align-items: baseline; padding: 4px 9px; white-space: nowrap; font-size: 11px;
  color: var(--k-glacier); background: var(--k-night); border: 1px solid var(--hairline);
  border-radius: var(--k-radius); pointer-events: none; font-variant-numeric: tabular-nums; z-index: 4;
}
.bubble strong { color: var(--k-snow); font-size: 12px; font-variation-settings: 'wdth' 88, 'wght' 700; }
.bar input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.bar input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 34px; }
.back {
  flex: none; padding: 4px 10px; font: inherit; font-size: 12px;
  color: var(--k-night); background: var(--k-glacier); border: 0; border-radius: 999px; cursor: pointer;
}
.back.is-idle { visibility: hidden; pointer-events: none; }
.ends {
  display: flex; justify-content: space-between; gap: 8px; min-height: 14px; padding-left: 44px;
  font-size: 11px; color: var(--k-glacier); font-variant-numeric: tabular-nums;
}
.hint { color: var(--k-granite); }

/* --- runner row ------------------------------------------------------------ */

.runner-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  border-top: 1px solid var(--hairline);
}
.avatar.ring { box-shadow: 0 0 0 2px var(--k-signal); width: 52px; height: 52px; font-size: 19px; }
.live-page .stage .avatar-lg { flex: none; }
.who { flex: 1; min-width: 0; }
.who h1 { margin: 0; font-size: 20px; line-height: 1.15; font-variation-settings: 'wdth' 108, 'wght' 650; }
.who p { margin: 2px 0 0; font-size: 14px; color: var(--k-glacier); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; flex: none; }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- side: tabs and panels ------------------------------------------------ */

.tabs { display: flex; height: 48px; flex: none; border-bottom: 1px solid var(--hairline); }
.tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; color: var(--k-glacier);
  background: none; border: 0; cursor: pointer;
}
.tab:hover { color: var(--k-snow); }
.tab.is-active {
  color: var(--k-snow); box-shadow: inset 0 -2px 0 var(--k-signal);
  font-variation-settings: 'wdth' 100, 'wght' 600;
}
.tab-n {
  min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; line-height: 18px;
  background: var(--surface-3); color: var(--k-snow); font-variant-numeric: tabular-nums;
}
.tab-n:empty { display: none; }

.panel { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel[hidden] { display: none; }

/* --- chat ------------------------------------------------------------------ */

.chat-log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; padding: 14px 8px 10px;
}
.chat-log > :first-child { margin-top: auto; }

.msg { position: relative; display: flex; gap: 10px; padding: 2px 8px; border-radius: 6px; font-size: 14px; line-height: 1.45; }
.msg.is-new { animation: msg-in .3s var(--k-ease); }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg:hover { background: rgb(244 247 249 / .03); }

.avatar.sm { width: 28px; height: 28px; font-size: 11px; flex: none; }
.msg-body { min-width: 0; flex: 1; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.msg-meta b { font-variation-settings: 'wdth' 100, 'wght' 650; color: var(--k-snow); }
.msg-meta time, .msg time { font-size: 11px; color: var(--k-granite); font-variant-numeric: tabular-nums; }
/* Names are not unique. The handle tells two "Tom"s apart; the Runner mark
   is the one nobody can take on someone else's run. */
.msg-handle { font-size: 12px; color: var(--k-granite); }
.msg-runner {
  padding: 0 6px; border-radius: 999px; font-size: 11px; line-height: 17px;
  background: var(--k-signal); color: var(--k-night); font-variation-settings: 'wdth' 100, 'wght' 650;
}
.msg-content { color: var(--k-snow); overflow-wrap: anywhere; }
.msg.is-mine .msg-meta b { color: var(--k-signal); }

.msg-icon { display: grid; place-items: center; flex: none; width: 28px; height: 28px; color: var(--k-signal); }
.msg-icon svg, .voice-icon svg, .heard svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.msg-cheer { align-items: center; color: var(--k-glacier); font-size: 13px; }
.msg-cheer b { color: var(--k-snow); font-variation-settings: 'wdth' 100, 'wght' 600; }

.msg-milestone {
  align-items: center; margin: 2px 0; padding: 7px 10px 7px 6px;
  background: var(--surface-2); color: var(--k-snow); font-size: 13px;
}
.msg-milestone .msg-text { flex: 1; }
.msg-milestone.is-finish, .msg-milestone.is-halfway, .msg-milestone.is-fastest-km {
  background: color-mix(in oklab, var(--k-signal) 14%, var(--surface-2));
}
.msg-system { justify-content: center; color: var(--k-glacier); font-size: 13px; text-align: center; }

.voice-note { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.voice-icon {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--k-signal); color: var(--k-night);
}
.heard { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--k-signal); }
.heard.is-waiting { color: var(--k-granite); }

.msg-more {
  position: absolute; right: 4px; top: 2px; width: 28px; height: 24px; padding: 0;
  display: none; place-items: center; color: var(--k-glacier);
  background: var(--surface-3); border: 0; border-radius: 4px; cursor: pointer;
}
.msg-more svg { width: 16px; height: 16px; fill: currentColor; }
.msg:hover .msg-more, .msg-more:focus-visible { display: grid; }
.mod-menu {
  position: absolute; right: 4px; top: 28px; z-index: 10; min-width: 180px; padding: 4px;
  background: var(--k-snow); border-radius: 6px; box-shadow: 0 10px 30px rgb(0 0 0 / .4);
}
.mod-menu button {
  display: block; width: 100%; padding: 9px 10px; text-align: left; font: inherit; font-size: 14px;
  color: var(--k-night); background: none; border: 0; border-radius: 4px; cursor: pointer;
}
.mod-menu button:hover { background: var(--k-rule); }
.mod-menu .danger { color: var(--k-alert); }

.unseen {
  position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); z-index: 5;
  padding: 6px 12px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--k-snow); color: var(--k-night); font: inherit; font-size: 13px;
  box-shadow: 0 6px 18px rgb(0 0 0 / .35);
}

/* --- composer -------------------------------------------------------------- */

.composer { flex: none; display: grid; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--hairline); }
.composer-note { margin: 0; font-size: 13px; color: var(--k-glacier); text-align: center; }

.compose-row { display: flex; gap: 8px; }
.compose-row input {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px; font: inherit; font-size: 15px;
  color: var(--k-snow); background: var(--surface-0);
  border: 1px solid var(--hairline); border-radius: var(--k-radius);
}
.compose-row input::placeholder { color: var(--k-granite); }
.compose-row input:focus { outline: none; border-color: var(--k-glacier); }
.compose-row input:disabled { cursor: not-allowed; }
.icon-btn.send { width: 42px; height: 42px; background: var(--k-signal); color: var(--k-night); }
.icon-btn.send:hover { background: var(--k-signal); filter: brightness(1.05); color: var(--k-night); }
.icon-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.compose-actions { display: flex; gap: 6px; }
.act {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 12px; flex: 1;
  font: inherit; font-size: 13px; color: var(--k-snow);
  background: var(--surface-2); border: 0; border-radius: var(--k-radius); cursor: pointer;
  font-variation-settings: 'wdth' 100, 'wght' 600;
}
.act:hover:not(:disabled) { background: var(--surface-3); }
.act:disabled { opacity: .45; cursor: not-allowed; }
.act svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.act.cheer svg, .act.is-on svg { color: var(--k-signal); }
.act.signal { background: var(--k-signal); color: var(--k-night); flex: none; }
.act.signal:hover:not(:disabled) { background: var(--k-signal); filter: brightness(1.05); }

.tray { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.react {
  height: 42px; font-size: 22px; background: var(--surface-2); border: 0; border-radius: var(--k-radius);
  cursor: pointer; transition: transform .1s var(--k-ease);
}
.react:hover { background: var(--surface-3); transform: translateY(-2px); }
.react:active { transform: scale(.92); }

.recorder { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.rec-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--k-signal); flex: none;
  animation: live-pulse 1.4s var(--k-ease) infinite;
}
.rec-time {
  font-variation-settings: 'wdth' 88, 'wght' 700; font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap;
}
.rec-level { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.rec-level i {
  display: block; height: 100%; background: var(--k-glacier);
  transform-origin: left; transform: scaleX(0); transition: transform .08s linear;
}
.rec-hint { flex: 1; font-size: 13px; color: var(--k-glacier); }
.recorder .act { flex: none; }
.recorder .icon-btn { background: var(--surface-2); color: var(--k-snow); }

/* --- moments panel ---------------------------------------------------------- */

.moments {
  flex: 1; overflow-y: auto; padding: 12px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-content: start;
}
.moments > .muted { grid-column: 1 / -1; }
.moment-cell { margin: 0; display: grid; gap: 4px; }
.moment-cell figcaption {
  display: grid; font-size: 12px; line-height: 1.3; color: var(--k-glacier);
  overflow: hidden;
}
.moment-cell figcaption b {
  color: var(--k-snow); font-variation-settings: 'wdth' 100, 'wght' 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.moment-cell figcaption span { font-variant-numeric: tabular-nums; }
.moment {
  position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; overflow: hidden; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--k-radius);
}
.moment img { width: 100%; height: 100%; object-fit: cover; display: block; }
.moment:hover { border-color: var(--k-glacier); }
.moment-tag, .moment-at {
  position: absolute; bottom: 6px; display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 6px; border-radius: 4px; font-size: 11px;
  background: rgb(19 28 46 / .85); color: var(--k-snow); font-variant-numeric: tabular-nums;
}
.moment-tag { left: 6px; }
.moment-at { right: 6px; }
.moment-tag svg { width: 10px; height: 10px; fill: currentColor; }

/* --- lightbox -------------------------------------------------------------- */

.backdrop {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center;
  justify-content: center; padding: 16px; background: rgb(19 28 46 / .94);
}
.backdrop[hidden] { display: none; }
.frame { position: relative; display: flex; flex-direction: column; max-width: 100%; max-height: 100%; gap: 8px; }
.frame img, .frame video {
  max-width: 100%; max-height: calc(100dvh - 120px); border-radius: var(--k-radius);
  background: #000; object-fit: contain;
}
.lb-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--k-glacier); font-size: 13px; }
.lb-bar .meta { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.lb-bar .meta strong { font-size: 14px; color: var(--k-snow); }
.nav { display: flex; align-items: center; gap: 4px; flex: none; }
.nav button {
  width: 30px; height: 30px; font-size: 20px; line-height: 1; color: var(--k-snow);
  background: rgb(244 247 249 / .12); border: none; border-radius: var(--k-radius); cursor: pointer;
}
.nav button:disabled { opacity: .3; cursor: default; }
.lb-jump {
  width: auto !important; height: 30px !important; padding: 0 12px; margin-right: 6px;
  font: inherit; font-size: 13px; color: var(--k-night) !important; background: var(--k-signal) !important;
  font-variation-settings: 'wdth' 100, 'wght' 650;
}
.count { color: var(--k-glacier); font-variant-numeric: tabular-nums; min-width: 42px; text-align: center; }
.close {
  position: absolute; top: -6px; right: -6px; width: 32px; height: 32px; font-size: 22px;
  line-height: 1; color: var(--k-night); background: var(--k-snow); border: none;
  border-radius: 50%; cursor: pointer; box-shadow: 0 2px 8px rgb(19 28 46 / .5);
}

/* --- below the fold (runner page while live) ------------------------------ */

.more-runs {
  display: flex; align-items: center; gap: 16px; margin: var(--k-space-4);
  padding: 18px 22px; border: 1px solid var(--hairline); border-radius: 10px;
  background: var(--surface-1); color: var(--k-snow); text-decoration: none;
}
.more-runs:hover { background: var(--surface-2); border-color: var(--k-glacier); }
.more-runs-text { display: grid; gap: 3px; }
.more-runs b { font-size: 17px; font-variation-settings: 'wdth' 108, 'wght' 650; }
.more-runs span span, .more-runs-text > span {
  font-size: 14px; color: var(--k-glacier); font-variant-numeric: tabular-nums;
}
.more-runs svg {
  width: 22px; height: 22px; margin-left: auto; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* --- narrow screens --------------------------------------------------------- */

@media (max-width: 1100px) {
  .live-page { grid-template-columns: minmax(0, 1fr) 300px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat:nth-child(4) { display: none; }
}

@media (max-width: 860px) {
  .live-page { display: block; height: auto; min-height: 0; }
  .map-wrap { flex: none; height: 46vh; min-height: 260px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat { padding: 9px 4px; text-align: center; }
  .stat:nth-child(4) { display: none; }
  .stat .label { font-size: 12px; }
  .stat .value small { display: none; }
  .runner-row { padding: 12px 14px; }
  .runner-row .actions .btn { padding: 0 12px; }
  .who h1 { font-size: 17px; }
  .avatar.ring { width: 42px; height: 42px; font-size: 16px; }

  .side { border-left: 0; border-top: 1px solid var(--hairline); }
  .tabs { position: sticky; top: var(--topbar-h); z-index: 6; background: var(--surface-1); }
  /* Top-anchored here: on a phone the page scrolls, so a log that grows up
     from the bottom of a tall panel starts life below the fold. */
  .chat-log { max-height: 60vh; min-height: 200px; }
  .chat-log > :first-child { margin-top: 0; }
  .composer {
    position: sticky; bottom: 0; z-index: 6; background: var(--surface-1);
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .unseen { bottom: 150px; }

  /* Bigger targets for thumbs. The pictures themselves live in the Moments
     tab, where there is room for them. */
  .tick { width: 24px; height: 24px; margin: -12px 0 0 -12px; }
  .celebrate .banner-text { font-size: 16px; }
  .banner.is-finish .banner-text, .banner.is-halfway .banner-text { font-size: 19px; }
  .celebrate .banner { white-space: normal; max-width: 86vw; }
}

/* --- a finished run's summary tab ---------------------------------------- */

.summary-panel { overflow-y: auto; padding: 4px 16px 20px; gap: 0; }
.sum-block { padding: 16px 0; border-bottom: 1px solid var(--hairline); }
.sum-block:last-child { border-bottom: 0; }
.sum-block h2 {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  margin: 0 0 10px; font-size: 15px; font-variation-settings: 'wdth' 108, 'wght' 650;
}
.sum-block h2 small, .sum-empty { font-size: 12px; color: var(--k-glacier); font-variation-settings: 'wdth' 100, 'wght' 400; }
.sum-empty { margin: 0; font-size: 13px; }

.split-head, .split-list li {
  display: grid; grid-template-columns: 38px 76px minmax(0, 1fr); gap: 10px; align-items: center;
}
.split-head { padding: 0 0 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--k-glacier); }
.split-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.split-list li { height: 24px; font-size: 13px; font-variant-numeric: tabular-nums; }
.split-list .km { color: var(--k-glacier); }
.split-list .pace { font-variation-settings: 'wdth' 88, 'wght' 700; }
.split-list .track { height: 8px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.split-list .track i { display: block; height: 100%; background: var(--surface-3); }
.split-list .is-fastest .track i { background: var(--k-signal); }
.split-list .is-partial { color: var(--k-glacier); }

.sum-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sum-stats div { display: grid; gap: 2px; padding: 10px; border-radius: 6px; background: var(--surface-2); }
.sum-stats span { font-size: 11px; color: var(--k-glacier); }
.sum-stats b { font-size: 18px; font-variation-settings: 'wdth' 88, 'wght' 700; font-variant-numeric: tabular-nums; }
.sum-reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sum-reactions span {
  height: 28px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: 999px;
  background: var(--surface-2); font-size: 13px; font-variant-numeric: tabular-nums;
}
.sum-crew { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.sum-crew li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.sum-crew .crew-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum-crew .crew-bits { color: var(--k-glacier); font-size: 12px; }

/* The runner's own words about the run, under the runner row. */
.run-description {
  padding: 0 18px 16px 84px; margin-top: -6px; background: var(--surface-1);
  font-size: 14px; line-height: 1.55; color: var(--k-snow); max-width: 820px;
}
/* Said to everyone who can see it: this is not a public run. */
.vis-tag {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--k-snow); font-size: 12px; vertical-align: 1px;
}
.vis-tag svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 640px) { .run-description { padding: 0 14px 14px; margin-top: 0; } }
