/* Powder - dark alpine theme */
:root {
  --bg: #0b1016;
  --panel: #131b24;
  --panel2: #182230;
  --line: #1f2b3a;
  --text: #e8eef5;
  --muted: #8fa2b5;
  --accent: #4dc3ff;
  --accent-dim: #1b6d99;
  --danger: #ff6b6b;
  --ok: #7ee787;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: 74px;
}
header {
  position: sticky; top: 0; z-index: 500;
  background: rgba(11, 16, 22, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.4px; }
main { max-width: 860px; margin: 0 auto; padding: 12px; }
a { color: var(--accent); text-decoration: none; }

nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 500;
  display: flex;
  background: rgba(15, 21, 29, 0.97);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav a {
  flex: 1; text-align: center; padding: 8px 2px 10px;
  color: var(--muted); font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
nav a svg { width: 22px; height: 22px; fill: currentColor; }
nav a.active { color: var(--accent); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.card.center { text-align: center; }
h2 { margin: 0 0 10px; font-size: 18px; }
h3 { margin: 4px 0 8px; font-size: 15px; }
.muted { color: var(--muted); }
.sm { font-size: 12px; }
.err { color: var(--danger); }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 14px; }
.code { letter-spacing: 2px; font-family: ui-monospace, monospace; color: var(--accent); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

/* buttons */
.btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent-dim); }
.btn.primary { background: var(--accent); color: #04141f; border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 15px 22px; font-size: 17px; border-radius: 12px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin: 14px auto 0; max-width: 340px; }
.file-btn { display: inline-block; }

/* live record: full-bleed map with overlaid stats panel */
.rec-wrap {
  position: relative;
  height: calc(100vh - 215px);
  min-height: 430px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0e141c;
}
#livemap { position: absolute; inset: 0; }
.rec-top {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; justify-content: flex-start; gap: 8px; flex-wrap: wrap;
  z-index: 1000; pointer-events: none;
}
/* keep OSM attribution readable above the overlaid stats panel */
.rec-wrap .leaflet-control-attribution { margin-top: 44px; }
.chip {
  background: rgba(11, 16, 22, 0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip.accent { color: var(--accent); border-color: var(--accent-dim); }
.chip.recenter {
  position: absolute; right: 10px; bottom: 215px; z-index: 1000;
  cursor: pointer; color: var(--accent);
}
.gps-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.gps-bars .bar { width: 3px; background: #2c3a4a; border-radius: 1px; display: inline-block; }
.gps-bars .bar.on { background: var(--ok); }
.gps-bars .b1 { height: 4px; } .gps-bars .b2 { height: 7px; }
.gps-bars .b3 { height: 10px; } .gps-bars .b4 { height: 12px; }
.rec-panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1000;
  padding: 34px 12px 12px;
  background: linear-gradient(transparent, rgba(11, 16, 22, 0.55) 18%, rgba(11, 16, 22, 0.94) 55%);
  text-align: center;
}
.rec-speed {
  font-size: 66px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
.rec-speed small { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 6px; }
.rec-tiles {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  margin: 12px 0;
}
.rec-tiles > div {
  background: rgba(24, 34, 48, 0.85);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 2px;
}
.rec-tiles b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.rec-tiles span { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; }
.btn-row { display: flex; gap: 10px; justify-content: center; }
.btn-row .btn.big { flex: 1; max-width: 220px; }
.banner {
  background: var(--panel2); border: 1px solid var(--accent-dim);
  padding: 10px; border-radius: 10px; margin-bottom: 12px; font-size: 14px;
  display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap;
}

/* stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.stat-grid > div {
  background: var(--panel2);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.stat-grid b { display: block; font-size: 17px; }
.stat-grid span { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; }

/* day rows */
.day-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 6px;
  border-top: 1px solid var(--line);
  color: var(--text);
  flex-wrap: wrap;
}
.day-row:hover { background: var(--panel2); }
.day-date { min-width: 150px; }
.day-stats { display: flex; gap: 14px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.day-stats b { color: var(--text); font-weight: 600; }

/* map + charts */
#map { height: 380px; background: #0e141c; }
.alt-chart { width: 100%; height: auto; display: block; }
.legend {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 18px; height: 0; border-top: 3px solid; border-radius: 2px; display: inline-block; }
.legend .sw.run { border-color: var(--accent); }
.legend .sw.lift { border-top-style: dashed; border-color: #8892a0; }
.legend .sw.idle { border-color: #3a4654; }
.legend .btn { margin-left: auto; }
.run-badge {
  background: var(--accent); color: #04141f;
  border: 2px solid #04141f; border-radius: 50%;
  font: 700 11px/18px system-ui; text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.run-badge.sel { background: #f10094; color: #fff; }
.run-badge.dim { opacity: 0.25; }
.run-num {
  display: inline-block; min-width: 20px; height: 20px;
  background: var(--panel2); border-radius: 50%;
  text-align: center; line-height: 20px; font-size: 11.5px; font-weight: 700;
}
table.runs tbody tr { cursor: pointer; }
table.runs tbody tr:hover td { background: var(--panel2); }
table.runs tr.selected td { background: var(--panel2); }
table.runs tr.selected .run-num { background: #f10094; color: #fff; }

/* runs table */
table.runs { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.runs th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 6px 8px; border-bottom: 1px solid var(--line);
}
table.runs td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.runs tr.me td { color: var(--accent); font-weight: 600; }
.card { overflow-x: auto; }

/* import */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
}
.dropzone.over { border-color: var(--accent); color: var(--accent); }
.imp-log { margin-top: 10px; font-size: 13px; color: var(--muted); }
.imp-log div { padding: 3px 0; }

/* friends */
.auth-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.auth-box { background: var(--panel2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 9px; }
.auth-box input, .row-form input, select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font: inherit;
}
.row-form { display: flex; gap: 8px; margin: 10px 0; }
.row-form input { flex: 1; text-transform: uppercase; }
.frow {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 4px; border-top: 1px solid var(--line);
}
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--accent-dim);
  padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all 0.25s;
  z-index: 900; max-width: 88vw; text-align: center; font-size: 14px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .live-num { font-size: 64px; }
  #map { height: 300px; }
  .day-row { flex-direction: column; align-items: flex-start; gap: 4px; }
}
