/* Mobile-first viewer styles. */
:root {
  --bg: #0f1720;
  --card: #17212b;
  --fg: #e8eef4;
  --muted: #8aa0b4;
  --accent: #3fb950;
  --accent-2: #2f81f7;
  --err: #f85149;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden; /* nic nie wypycha strony w poziomie */
}
#app { max-width: 720px; margin: 0 auto; padding: env(safe-area-inset-top) 12px 24px; }

#topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; padding: 12px 4px 8px;
}
#topbar h1 { font-size: 1.2rem; margin: 0; }
.status { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.status.live { color: var(--accent); }
.status.err { color: var(--err); }

#map-wrap { position: relative; }
#map {
  height: 55vh; min-height: 300px; max-height: 640px; width: 100%;
  border-radius: var(--radius); overflow: hidden; background: #0b1017;
}

/* Zawsze widoczny kafelek info na mapie (nie blokuje przesuwania mapy). */
#map-info {
  position: absolute; top: 10px; right: 10px; z-index: 500;
  background: rgba(11, 16, 23, .82); backdrop-filter: blur(4px);
  border: 1px solid #26333f; border-radius: 10px; padding: 7px 11px;
  pointer-events: none; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); max-width: 60%;
}
#map-info .mi-main { display: flex; align-items: baseline; gap: 4px; }
#map-info .mi-main b { font-size: 1.5rem; font-weight: 700; line-height: 1; }
#map-info .mi-main .unit { font-size: .72rem; color: var(--muted); }
#map-info .mi-sub {
  display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px;
  font-size: .72rem; color: var(--muted);
}
#map-info .mi-sub b { color: var(--fg); font-weight: 600; }

/* Trwała etykieta prędkości nad kropką. */
.leaflet-tooltip.live-tt {
  background: #2f81f7; color: #fff; border: 0; font-weight: 700;
  font-size: .72rem; padding: 2px 7px; border-radius: 8px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .4);
}
.leaflet-tooltip.live-tt::before { border-top-color: #2f81f7; }

/* Follow-position button on the map. */
.map-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 500;
  width: 42px; height: 42px; min-height: 42px; border-radius: 50%; padding: 0;
  background: rgba(11, 16, 23, .82); border: 1px solid #26333f; color: var(--muted);
  font-size: 1.1rem; box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  display: flex; align-items: center; justify-content: center;
}
.map-btn.on { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }

/* Speed legend (matches speedColor() in app.js). */
#legend {
  position: absolute; left: 10px; bottom: 10px; z-index: 500; pointer-events: none;
  display: flex; align-items: center; gap: 6px; font-size: .68rem; color: var(--muted);
  background: rgba(11, 16, 23, .82); border: 1px solid #26333f; border-radius: 8px; padding: 4px 8px;
}
#legend .legend-bar {
  width: 56px; height: 8px; border-radius: 99px; display: inline-block;
  background: linear-gradient(90deg, hsl(0, 85%, 48%), hsl(60, 85%, 48%), hsl(120, 85%, 48%));
}

/* Stats line + summary button under progress. */
.meta-line { margin-top: 12px; text-align: center; color: var(--muted); font-size: .82rem; }
.ghost-btn {
  margin-top: 12px; width: 100%; background: #0b1017; border: 1px solid #26333f; color: var(--fg);
}

/* Ride summary card. */
.sum-head { display: flex; align-items: center; justify-content: space-between; }
.sum-head h2 { margin: 0; color: var(--fg); font-size: 1.05rem; }
.x-btn { background: #26333f; min-height: 34px; padding: 4px 10px; }
.sum-grid { margin-top: 10px; display: grid; gap: 1px; background: #26333f; border-radius: 10px; overflow: hidden; }
.sum-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--card); }
.sum-row span { color: var(--muted); }
.sum-row b { font-variant-numeric: tabular-nums; }
.dl-btn {
  display: block; text-align: center; margin-top: 12px; padding: 11px; border-radius: 8px;
  background: var(--accent); color: #04210c; font-weight: 700; text-decoration: none;
}

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-top: 12px;
}
.card h2 { font-size: .95rem; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.hidden { display: none; }

.bar { height: 12px; background: #0b1017; border-radius: 99px; overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width .6s ease;
}
.stats {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 8px; margin-top: 12px; text-align: center;
}
.stats b { display: block; font-size: 1rem; }
.stats span { font-size: .7rem; color: var(--muted); }
@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(3, 1fr); row-gap: 12px; }
}

#elevation { width: 100%; display: block; }

/* Weather card. */
#weather-card .wx-main { display: flex; align-items: center; gap: 12px; }
#weather-card .wx-icon { font-size: 2.4rem; line-height: 1; }
#weather-card .wx-temp b { font-size: 1.7rem; }
#weather-card .wx-temp span { display: block; color: var(--muted); font-size: .85rem; }
#weather-card .wx-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  margin-top: 12px; text-align: center;
}
#weather-card .wx-grid span { display: block; color: var(--muted); font-size: .68rem; }
#weather-card .wx-grid b { font-size: .95rem; }
@media (max-width: 420px) {
  #weather-card .wx-grid { grid-template-columns: repeat(3, 1fr); row-gap: 12px; }
}
.wx-rel {
  margin-top: 10px; font-size: .9rem; font-weight: 600;
  padding: 7px 11px; border-radius: 8px; display: inline-block;
}
.wx-rel.tailwind { background: rgba(63, 185, 80, .15); color: var(--accent); }
.wx-rel.headwind { background: rgba(248, 81, 73, .15); color: var(--err); }
.wx-rel.crosswind, .wx-rel.calm { background: #0b1017; color: var(--muted); }

#comment-form { display: flex; flex-direction: column; gap: 8px; }
#comment-form input {
  background: #0b1017; border: 1px solid #26333f; color: var(--fg);
  border-radius: 8px; padding: 11px; font-size: 16px; width: 100%; /* 16px: iOS nie zoomuje pola */
}
#comment-form .row { display: flex; gap: 8px; }
#comment-form .row input { flex: 1; min-width: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
button {
  background: var(--accent-2); color: #fff; border: 0; border-radius: 8px;
  padding: 11px 16px; font-size: 15px; cursor: pointer;
  min-height: 44px; touch-action: manipulation; /* wygodny cel dotyku */
}
#cheer { background: #26333f; }
button:active { transform: translateY(1px); }
.err { color: var(--err); font-size: .8rem; min-height: 1em; }

#comment-feed { list-style: none; margin: 12px 0 0; padding: 0; }
#comment-feed .c {
  padding: 9px 0; border-top: 1px solid #26333f; line-height: 1.45;
  overflow-wrap: anywhere; /* długie słowa/linki nie rozpychają panelu */
}
#comment-feed .c:first-child { border-top: 0; }
#comment-feed .nick { font-weight: 600; color: var(--accent-2); }
#comment-feed .cheer { color: var(--accent); }
#comment-feed time { color: var(--muted); font-size: .72rem; margin-left: 6px; }

/* Replies nested under a supporter's comment. */
#comment-feed .replies {
  list-style: none; margin: 0 0 4px 10px; padding: 0 0 0 12px;
  border-left: 2px solid #26333f;
}
#comment-feed .replies .c { border-top: 0; padding: 6px 0; }

/* Quote of the comment a reply answers. */
#comment-feed .reply-quote {
  display: block; font-size: .72rem; color: var(--muted);
  border-left: 2px solid var(--accent-2); padding-left: 7px; margin-bottom: 3px;
}
#comment-feed .reply-quote b { color: var(--fg); font-weight: 600; }

/* Automatic system events — highlighted banner in the feed. */
#comment-feed .c.system {
  border-top: 0; margin: 10px 0; padding: 10px 12px; border-radius: 10px;
  background: linear-gradient(90deg, rgba(47,129,247,.16), rgba(63,185,80,.16));
  border: 1px solid #2f4257; text-align: center; font-weight: 600;
}
#comment-feed .c.system .sys-body { display: block; }
#comment-feed .c.system time { display: block; margin: 4px 0 0; font-weight: 400; }

/* The rider's own messages stand out. */
#comment-feed .c.owner {
  background: rgba(63, 185, 80, .09);
  border-top: 0; border-left: 3px solid var(--accent);
  padding: 9px 10px; margin: 8px 0; border-radius: 0 8px 8px 0;
}
#comment-feed .c.owner .nick { color: var(--accent); }
.badge-owner {
  display: inline-block; font-size: .62rem; font-weight: 700; letter-spacing: .05em;
  background: var(--accent); color: #04210c;
  padding: 1px 6px; border-radius: 99px; margin-right: 6px; vertical-align: 1px;
}

footer { text-align: center; color: var(--muted); font-size: .75rem; margin-top: 16px; }

.leaflet-popup-content { font: 13px/1.35 system-ui, sans-serif; }
