/* trop. GPX editor. Same tokens as the product page (web/index.css), a full-screen map with one floating panel. */
:root {
  --paper: #ffffff;
  --well: #f3f4f6;
  --hair: #e6e7ea;
  --ink: #1d1e22;
  --muted: #858a94;
  --accent: #2e5e5a;
  --accent-soft: #e4eeed;
  --red: #e64540;
  --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 8px 28px rgba(20, 24, 33, .14);
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1e1f22; --well: #2a2b2f; --hair: #34363b;
    --ink: #ecedef; --muted: #8e929b; --accent: #5c9a95; --accent-soft: #1a2a29;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1e1f22; --well: #2a2b2f; --hair: #34363b;
  --ink: #ecedef; --muted: #8e929b; --accent: #5c9a95; --accent-soft: #1a2a29;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.45 var(--ui); -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
#map { position: fixed; inset: 0; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- panel ---------- */
.panel {
  position: fixed; z-index: 2;
  top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left));
  width: min(340px, calc(100vw - 24px));
  padding: 14px 16px 16px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid color-mix(in srgb, var(--hair) 70%, transparent);
  border-radius: 16px; box-shadow: var(--shadow);
  max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;
}
@media (prefers-reduced-transparency: reduce) {
  .panel { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.panel-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.brand {
  font: 700 21px/1 var(--display); letter-spacing: -0.03em;
  color: var(--ink); text-decoration: none;
}
.brand .dot { color: var(--accent); }
/* The brand doubles as the way back to the product page, so it carries a back chevron like an iOS back button. */
.brand { display: inline-flex; align-items: center; margin-left: -6px; padding: 2px 4px 2px 0; border-radius: 8px; }
.brand i[data-icon] { width: 22px; height: 22px; color: var(--accent); }
@media (hover: hover) { .brand:hover { background: var(--well); } }
.tag { font-size: 13px; color: var(--muted); }
.panel p { margin: 0; }
.panel .hint { margin-top: 10px; font-size: 13px; color: var(--muted); }
.hint:empty { display: none; }

.name {
  display: block; width: 100%; margin: 0 0 10px; padding: 4px 6px; margin-left: -6px; width: calc(100% + 12px);
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink);
  font: 600 17px/1.3 var(--display); letter-spacing: -0.015em; text-overflow: ellipsis;
}
@media (hover: hover) { .name:hover { border-color: var(--hair); } }
.name:focus { outline: none; border-color: var(--accent); background: var(--paper); }
.stats { display: grid; grid-template-columns: repeat(4, auto); gap: 4px 14px; margin: 0 0 14px; }
.stats div { min-width: 0; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font: 600 15px/1.3 var(--ui); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Elevation profile: a quiet strip under the numbers; orange shows the selection, as on the map. */
.profile { position: relative; margin: -4px 0 14px; padding-top: 2px; }
.profile svg { display: block; width: 100%; height: 56px; cursor: crosshair; touch-action: none; overflow: visible; }
.profile .area { fill: var(--accent-soft); }
.profile .line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.profile .sel { fill: none; stroke: #f59421; stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.profile .cursor { stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .5; }
.profile-max, .profile-min { position: absolute; left: 0; font-size: 11px; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }
.profile-max { top: 2px; }
.profile-min { bottom: 2px; }
.profile-tip { position: absolute; top: -22px; transform: translateX(-50%); padding: 2px 7px; border-radius: 6px; background: var(--ink); color: var(--paper); font: 600 11px/1.5 var(--ui); font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.profile-tip[hidden] { display: none; }

/* ---------- buttons ---------- */
.row { display: flex; gap: 8px; margin-top: 10px; }
.stack { display: grid; gap: 8px; margin-top: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--hair); background: var(--paper); color: var(--ink);
  font: 500 14px/1 var(--ui); cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.stack .btn { justify-content: center; }
.btn.grow { flex: 1; }
.btn.icon-only { width: 38px; padding: 0; }
@media (hover: hover) { .btn:hover { background: var(--well); } }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (hover: hover) { .btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); } }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn:has(input:focus-visible) { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.footer { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hair); }
.link {
  margin-top: 10px; padding: 0; border: 0; background: none; color: var(--accent);
  font: 500 14px/1.4 var(--ui); cursor: pointer; text-align: left;
}
@media (hover: hover) { .link:hover { text-decoration: underline; } }

/* Icons: Lucide (ISC licence), drawn inline by edytor.js from data-icon. */
i[data-icon] { display: inline-flex; flex: none; width: 18px; height: 18px; }
i[data-icon] svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- context under the numbers ---------- */
.box { margin-top: 4px; padding: 10px 12px 12px; border-radius: 12px; background: var(--well); }
.box p { font-size: 14px; }
/* Guide: what is selected, the step you are on, what to do next. */
.guide { margin-top: 4px; padding: 10px 12px 12px; border-radius: 12px; background: var(--well); }
.guide-title { font: 600 14px/1.35 var(--ui); font-variant-numeric: tabular-nums; }
.panel .guide-text { margin-top: 4px; font-size: 13px; color: var(--muted); }
.steps { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps .num {
  display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid currentColor; font: 600 11px/1 var(--ui);
}
.steps li.now .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps li.done { color: var(--accent); }
.steps li.done .num { background: var(--accent-soft); border-color: transparent; }
.steps .num svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
/* Next steps as an iOS-style menu: full-width rows, icon + label, grouped in rounded blocks, Delete alone at the end. */
.guide-actions { display: grid; gap: 8px; margin-top: 10px; }
.guide-actions:empty { display: none; }
.menu { display: grid; border-radius: 10px; background: var(--paper); overflow: hidden; }
.menu-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px;
  border: 0; background: transparent; color: var(--ink); text-align: left;
  font: 500 14px/1.2 var(--ui); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color 120ms ease;
}
.menu-row + .menu-row { box-shadow: inset 0 1px 0 var(--hair); }
.menu-row i[data-icon] { color: var(--muted); }
@media (hover: hover) { .menu-row:hover { background: var(--well); } }
.menu-row:active { background: var(--well); }
.menu-row:focus-visible { outline: 2.5px solid var(--accent); outline-offset: -2.5px; border-radius: 10px; }
.menu-row.danger, .menu-row.danger i[data-icon] { color: var(--red); }

.range-label { display: block; font-size: 14px; }
.box input[type="range"] { width: 100%; margin: 8px 0 4px; accent-color: var(--accent); }

/* ---------- toolbox: second floating card, icon over caption, like a Mac app toolbar ---------- */
.toolbox {
  position: fixed; z-index: 2;
  top: max(12px, env(safe-area-inset-top)); left: calc(max(12px, env(safe-area-inset-left)) + 340px + 10px);
  display: flex; padding: 4px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid color-mix(in srgb, var(--hair) 70%, transparent);
  border-radius: 14px; box-shadow: var(--shadow);
}
@media (prefers-reduced-transparency: reduce) {
  .toolbox { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.group { display: flex; }
.group + .group { margin-left: 4px; padding-left: 4px; border-left: 1px solid var(--hair); }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 64px; height: 54px; padding: 0 2px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink); cursor: pointer;
  font: 500 11px/1.1 var(--ui); -webkit-tap-highlight-color: transparent;
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.tool i[data-icon] { width: 20px; height: 20px; }
.tool .cap { white-space: nowrap; }
/* Its caption changes (Out and back / Close loop) and is longer than the rest: a fixed, wider slot, so nothing jumps. */
.tool#loop { width: 92px; }
@media (hover: hover) { .tool:hover:not(:disabled) { background: var(--well); } }
.tool:active:not(:disabled) { transform: scale(0.95); }
.tool:disabled { opacity: .35; cursor: default; }
.tool.danger { color: var(--red); }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* Selection box drawn while dragging with the "Obszar" tool or Shift. */
.boxsel {
  position: absolute; z-index: 1; pointer-events: none;
  border: 1.5px dashed #f59421; background: rgba(245, 148, 33, .12); border-radius: 2px;
}

/* ---------- help ---------- */
.help-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; margin-left: auto; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
  align-self: center;
}
@media (hover: hover) { .help-btn:hover { background: var(--well); color: var(--ink); } }
/* Language switch next to help: shows the other language (EN / PL), like the switch on the product page. */
.lang-btn {
  margin-left: auto; padding: 4px 7px; align-self: center;
  border: 1px solid var(--hair); border-radius: 8px; background: transparent;
  color: var(--muted); font: 600 12px/1 var(--ui); letter-spacing: .04em; cursor: pointer;
}
@media (hover: hover) { .lang-btn:hover { background: var(--well); color: var(--ink); } }
.lang-btn + .help-btn { margin-left: 2px; }
.help-btn i[data-icon] { width: 20px; height: 20px; }
/* Open another file, in the header once a track is loaded (the empty state has its own big button). */
.head-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; margin-left: auto; padding: 0;
  border-radius: 50%; color: var(--muted); cursor: pointer; align-self: center;
}
.head-btn[hidden] { display: none; }
@media (hover: hover) { .head-btn:hover { background: var(--well); color: var(--ink); } }
.head-btn:has(input:focus-visible) { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.head-btn i[data-icon] { width: 20px; height: 20px; }
.head-btn:not([hidden]) + .lang-btn { margin-left: 2px; }
.help {
  width: min(520px, calc(100vw - 32px)); max-height: min(80dvh, 720px); padding: 18px 20px 20px;
  border: 0; border-radius: 16px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
  overflow-y: auto; overscroll-behavior: contain;
}
.help::backdrop { background: rgba(20, 24, 33, .35); }
/* Send to trop.: the QR code stays black on white in dark mode too, so any camera reads it. */
/* Save and Send side by side, the same width. */
.footer .btn { flex: 1 1 0; min-width: 0; padding: 0 10px; white-space: nowrap; }
.footer.phone #send { order: -1; }
.send { width: min(420px, calc(100vw - 32px)); }
.send > p { font-size: 14px; }
.send header { margin-bottom: 8px; }
.send .qr { display: flex; justify-content: center; margin: 14px 0 6px; }
.send .qr svg { display: block; max-width: 100%; height: auto; border-radius: 8px; }
.send .note { color: var(--muted); font-size: 13px; text-align: center; }
.send .row { margin-top: 10px; }
.help header { display: flex; align-items: center; margin-bottom: 4px; }
.help h2 { margin: 0; font: 600 19px/1.2 var(--display); letter-spacing: -0.015em; }
.help h3 { margin: 16px 0 6px; font: 600 13px/1.2 var(--ui); color: var(--muted); }
.help p { margin: 0; font-size: 14px; }
.help ul { margin: 0; padding: 0; list-style: none; }
.help .plain li { font-size: 14px; padding: 3px 0; }
.help .tools li { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--hair); }
.help .tools li:first-child { border-top: 0; }
.help .tools i[data-icon] { width: 20px; height: 20px; margin-top: 1px; }
.help .tools i.danger, .help .tools li:has(i.danger) b { color: var(--red); }
.help .tools b { font-size: 14px; }

/* ---------- drop overlay and error toast ---------- */
.drop {
  position: fixed; inset: 0; z-index: 3; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border: 3px dashed var(--accent); pointer-events: none;
}
.drop p {
  padding: 12px 20px; border-radius: 12px; background: var(--paper); box-shadow: var(--shadow);
  font: 600 16px/1 var(--ui);
}
.toast {
  position: fixed; z-index: 4; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--paper);
  font-size: 14px; box-shadow: var(--shadow);
}
/* A track from the QR code on a phone: a toast that stays at the top (the sheet takes the bottom) until closed. */
.linkbar {
  position: fixed; z-index: 4;
  top: max(12px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right));
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px 10px 16px; border-radius: 14px; background: var(--ink); color: var(--paper);
  box-shadow: var(--shadow);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(-8px); }
}
.linkbar p { flex: 1; margin: 0; font-size: 14px; line-height: 1.3; }
.linkbar .btn { min-height: 44px; flex: none; }
.link-close {
  display: grid; place-items: center; width: 36px; height: 44px; flex: none;
  padding: 0; border: 0; border-radius: 10px; background: transparent; color: inherit; opacity: .7; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.link-close i[data-icon] { width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) { .linkbar { transition: opacity 200ms ease; @starting-style { transform: none; } } }
[hidden] { display: none !important; }

/* ---------- MapLibre controls in the page's look ---------- */
.maplibregl-ctrl-group {
  border-radius: 12px !important; overflow: hidden;
  box-shadow: var(--shadow) !important; background: var(--paper) !important;
}
.maplibregl-ctrl-group button { width: 36px; height: 36px; }
.maplibregl-ctrl-scale { border-color: var(--muted); color: var(--ink); background: color-mix(in srgb, var(--paper) 75%, transparent); }

/* Narrow desktop: no room beside the panel, so the toolbox moves to the bottom edge. */
@media (max-width: 1200px) and (min-width: 701px) {
  .toolbox {
    left: max(12px, env(safe-area-inset-left)); top: auto; bottom: max(12px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 80px); overflow-x: auto; scrollbar-width: none;
  }
  .maplibregl-ctrl-bottom-left { bottom: 76px; }
}
/* Phone: the panel becomes a sheet at the bottom, like Apple Maps; the toolbox sits on top of it and scrolls sideways. */
@media (max-width: 700px) {
  .panel {
    top: auto; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; right: 8px; width: auto;
    max-height: 45dvh; padding: 12px 14px 14px;
  }
  .toolbox {
    left: 8px; right: 8px; top: auto; bottom: calc(var(--panel-h, 0px) + 16px);
    overflow-x: auto; scrollbar-width: none;
  }
  .toolbox::-webkit-scrollbar { display: none; }
  /* More tools to the right: the edge fades until the row is scrolled to the end. */
  .toolbox:not(.at-end) {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .tool { width: 58px; }
  /* The handle: drag it and the sheet follows the finger; let go and it folds to one line or opens (edytor.js). */
  .panel-head { touch-action: none; }
  .grabber {
    display: block; width: calc(100% + 28px); height: 22px; margin: -12px -14px 2px; padding: 0;
    border: 0; background: transparent; cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent;
  }
  .grabber span {
    display: block; width: 36px; height: 5px; margin: 0 auto; border-radius: 3px;
    background: color-mix(in srgb, var(--muted) 45%, transparent);
  }
  /* The folded line sits over the header and takes its place as the sheet goes down. */
  .peek {
    position: absolute; top: 22px; left: 14px; right: 14px;
    display: flex; align-items: baseline; gap: 10px; min-height: 32px; padding: 0 0 2px;
    border: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; opacity: 0;
    touch-action: none; -webkit-tap-highlight-color: transparent;
  }
  .panel:not(.folded) > .peek { pointer-events: none; }
  .peek-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 16px/1.3 var(--display); letter-spacing: -0.015em; }
  .peek-stats { flex: none; font: 500 14px/1.3 var(--ui); color: var(--muted); font-variant-numeric: tabular-nums; }
  .panel.folded { overflow: hidden; }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: var(--sheet, 0px); }
}
/* Pinch zooms on a phone; the + and − buttons only took map space. */
@media (max-width: 700px) and (pointer: coarse) {
  .maplibregl-ctrl-zoom-in, .maplibregl-ctrl-zoom-out { display: none !important; }
}
