:root {
  --bg: #0e1216;
  --panel: #151a20;
  --card: #1d242d;
  --line: #2a333f;
  --txt: #e9edf2;
  --muted: #8b97a6;
  --orange: #fc5200;
  --green: #2fbf71;
  --blue: #3d8bff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Barlow", system-ui, sans-serif; background: var(--bg); color: var(--txt); font-size: 14px; }
a { color: var(--orange); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

#app { display: flex; height: 100vh; }
#panel {
  width: 370px; flex: none; overflow-y: auto; padding: 14px;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
#map { flex: 1; background: #dfe3e8; }
#app.collapsed #panel { display: none; }
#app.collapsed #map { height: 100vh; }
/* zakładka chowania menu — na krawędzi panelu, w połowie jego wysokości */
#panel-tab {
  position: fixed; z-index: 1000; top: 50%; left: 370px; transform: translateY(-50%);
  width: 22px; height: 64px; padding: 0; border-radius: 0 8px 8px 0;
  background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-left: 0;
  font-size: 12px; box-shadow: 2px 0 8px rgba(0,0,0,.3);
}
#panel-tab:hover { color: var(--orange); }
#app.collapsed #panel-tab { left: 0; }

header h1 { font-family: "Barlow Condensed", sans-serif; font-weight: 800; font-size: 30px; margin: 0; letter-spacing: .5px; }
header h1 span { color: var(--orange); font-weight: 600; font-size: 20px; margin-left: 4px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card p { margin: 6px 0; }

button, .button {
  font: 600 14px "Barlow", sans-serif; cursor: pointer; border: 0; border-radius: 7px;
  padding: 8px 12px; background: var(--orange); color: #fff; display: inline-block;
}
button:disabled { opacity: .5; cursor: wait; }
button.secondary, .button.secondary { background: #27303b; color: var(--txt); border: 1px solid var(--line); }
button.secondary.on { border-color: var(--orange); color: var(--orange); }
button.link { background: none; color: var(--muted); padding: 0 4px; text-decoration: underline; }
button.strava { background: none; padding: 0; }
button.big { width: 100%; font-size: 17px; padding: 11px; margin-top: 10px; }
select { background: #27303b; color: var(--txt); border: 1px solid var(--line); border-radius: 7px; padding: 7px; font: inherit; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }

.map-clear { background: #fff; color: #222; border: 2px solid rgba(0,0,0,.25); border-radius: 6px; font-size: 13px; padding: 5px 9px; }
.map-clear:hover { color: #c00; }
.map-paint.on { background: var(--orange); color: #fff; border-color: #b33a00; }
#map.painting { touch-action: none; cursor: crosshair; }
.touch-only { display: none; }
body.touch .touch-only { display: block; }
body.touch .desk-only { display: none; }
label.file-btn { margin-top: 6px; font-size: 16px; padding: 10px 14px; }
#btn-share:not(.hidden) + #btn-gpx { margin-top: 6px; background: #27303b; color: var(--txt); border: 1px solid var(--line); }
a.bm { display: inline-block; margin: 4px 0; padding: 4px 9px; border: 1px dashed var(--orange); border-radius: 6px; text-decoration: none; font-weight: 600; cursor: grab; }
.card .legend { margin-top: 8px; }
.howto summary { cursor: pointer; color: var(--orange); font-weight: 600; }
.howto ol { margin: 8px 0 4px; padding-left: 20px; line-height: 1.5; }
.howto li { margin-bottom: 6px; }
.linklike { color: var(--orange); text-decoration: underline; cursor: pointer; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border-radius: 0; background: #27303b; color: var(--muted); padding: 8px 0; }
.seg button.on { background: var(--orange); color: #fff; }

.slider { margin-top: 12px; }
.slider input { width: 100%; accent-color: var(--orange); }
.slider .ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 6px; align-items: center; margin-top: 8px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.kpis b { display: block; font: 800 24px "Barlow Condensed", sans-serif; }
.kpis span { font-size: 11px; color: var(--muted); line-height: 1.1; display: block; }
.surface-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 12px 0 6px; background: #333; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

footer { margin-top: auto; line-height: 1.5; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000;
  background: #222b35; color: var(--txt); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: 90vw;
}
.leaflet-container.picking { cursor: crosshair; }
.start-pin { background: var(--orange); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 1px 6px rgba(0,0,0,.5); }

@media (max-width: 760px) {
  #app { flex-direction: column-reverse; height: auto; }
  #map { height: 62vh; flex: none; }
  #panel { width: 100%; border-right: 0; }
  #panel-tab { position: absolute; left: 0; top: 31vh; } /* przy mapie, nie nad przewijanym panelem */
  #app.collapsed #panel-tab { top: 50%; }
  .map-clear { font-size: 15px; padding: 8px 11px; }
  button.secondary, select { padding: 10px 12px; }
}

/* zwijane sekcje panelu: nagłówek = podsumowanie, klik zwija/rozwija */
details.card > summary {
  list-style: none; display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  font: 600 18px "Barlow Condensed", sans-serif; margin: -12px; padding: 12px;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▾"; color: var(--muted); font-size: 14px; transition: transform .15s; }
details.card:not([open]) > summary::after { transform: rotate(-90deg); }
details.card[open] > summary { margin-bottom: -4px; }
details.card > summary b {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--orange); color: #fff; font-size: 13px;
}
details.card > summary .sum {
  margin-left: auto; font: 400 13px "Barlow", sans-serif; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%;
}
details.card > summary .sum.ok { color: var(--green); }
details.card > summary:hover::after { color: var(--orange); }
.plan-box { margin-top: -4px; }
.plan-box button.big { margin-top: 0; }
.plan-box p:empty { display: none; }
