:root {
  --bg: #0e1216;
  --panel: #151a20;
  --card: #1d242d;
  --card-hover: #242d38;
  --line: #2a333f;
  --txt: #e9edf2;
  --muted: #8b97a6;
  --orange: #fc4c02;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: "Barlow", system-ui, sans-serif; background: var(--bg); color: var(--txt); }

#app { display: flex; height: 100%; }
#map { flex: 1; background: #0e1216; }

#panel {
  width: 390px;
  padding: 16px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

header h1 {
  font-family: "Barlow Condensed", sans-serif;
  font-style: italic;
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 1px;
  margin: 0;
  text-transform: uppercase;
}
header h1 span { color: var(--orange); }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

button {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 10px 14px;
  border: none;
  border-radius: 4px;
  background: var(--orange);
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.12); }
button.strava { width: 100%; font-size: 18px; }
button.secondary { background: var(--card); color: var(--muted); border: 1px solid var(--line); }
button.link {
  background: none; color: var(--muted); padding: 0 4px; border: 0;
  text-decoration: underline; font-size: 12px; text-transform: none; letter-spacing: 0;
}

#logged-in { font-size: 14px; }

#controls { display: flex; flex-direction: column; gap: 10px; }
#controls label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
#controls strong { color: var(--txt); }

input[type=range] { width: 100%; accent-color: var(--orange); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.speed-wrap { font-size: 13px; color: var(--muted); white-space: nowrap; }
#speed-input {
  width: 56px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 4px;
  padding: 5px 6px;
  font-size: 14px;
  text-align: right;
}

#route-select {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 4px;
  padding: 7px 8px;
  font-size: 13px;
  width: 100%;
}
#route-summary {
  font-size: 13px;
  background: var(--card);
  border-radius: 4px;
  padding: 7px 10px;
}

.chk { user-select: none; cursor: pointer; }
.chk input { accent-color: var(--orange); }

#wind-now {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  background: var(--card); border-radius: 4px; padding: 7px 10px;
}
#wind-arrow { display: inline-block; font-size: 18px; color: #5ec8f0; }

#status { font-size: 13px; color: var(--muted); min-height: 18px; }
#status.error { color: #ff6b5e; }

#segment-list { list-style: none; margin: 0; padding: 0; }
#segment-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  margin-bottom: 7px;
  border-radius: 5px;
  background: var(--card);
  border-left: 5px solid #888;
  cursor: pointer;
  font-size: 13px;
}
#segment-list li:hover { background: var(--card-hover); }
#segment-list li .name { font-weight: 600; display: block; font-size: 14px; }
#segment-list li .meta { color: var(--muted); font-size: 12px; }
#segment-list li .li-score {
  text-align: right;
  font-family: "Barlow Condensed", sans-serif;
  white-space: nowrap;
}
#segment-list li .li-score b { font-size: 21px; font-style: italic; }
#segment-list li .li-score small { color: var(--muted); margin-left: 3px; }
#segment-list li .watts { display: block; font-size: 12px; color: var(--muted); }

#wind-canvas { pointer-events: none; }

.legend { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding-top: 8px; }
.scale .bar { height: 8px; border-radius: 4px; }
.scale .seg-bar {
  background: linear-gradient(90deg, hsl(0,75%,50%), hsl(60,75%,48%), hsl(120,75%,45%));
}
.scale .wind-bar {
  background: linear-gradient(90deg, hsla(200,70%,65%,.15), hsla(180,90%,80%,.6), hsla(160,100%,92%,.95));
}
.scale .ticks {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-top: 3px;
}

/* dymek po najechaniu na segment */
.seg-tip {
  background: var(--card);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: "Barlow", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  padding: 7px 10px;
  box-shadow: 0 3px 14px rgba(0,0,0,.5);
}
.seg-tip:before { border-top-color: var(--line); }
.seg-tip .tip-meta { color: var(--muted); font-size: 12px; }

/* popupy Leaflet w ciemnym stylu */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--card); color: var(--txt);
}
.leaflet-popup-content a { color: var(--orange); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

@media (max-width: 700px) {
  #app { flex-direction: column; }
  #panel { width: 100%; max-height: 48%; }
}
