:root {
  --c-bici: #1a9850;
  --c-acera: #2b7bb9;
  --c-calma: #e0a800;
  --c-mala: #d73027;
  --bg: #ffffff;
  --fg: #1d2327;
  --muted: #5f6b73;
  --border: #d9dee2;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f2428;
    --fg: #e8ecef;
    --muted: #a3adb4;
    --border: #3a4248;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

#map {
  position: fixed;
  inset: 0;
}

/* --- barra de botones --- */
#toolbar {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#toolbar button {
  width: 44px;
  height: 44px;
  font-size: 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--shadow);
  cursor: pointer;
}

#toolbar button[aria-pressed="true"],
#toolbar button.active {
  outline: 3px solid var(--c-bici);
}

/* --- panel --- */
#panel {
  position: fixed;
  z-index: 1000;
  left: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(340px, calc(100vw - 76px));
  max-height: 60vh;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.4;
}

#panel h2 {
  font-size: 15px;
  margin: 8px 0 6px;
}

.hint, .small { color: var(--muted); }
.hint { margin: 0; }
.small { font-size: 12px; margin: 6px 0; }

#origin-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 0 0 6px;
}

#btn-save-home {
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}

.big {
  font-size: 22px;
  font-weight: 650;
}

.bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin: 8px 0;
  background: var(--border);
}

.bar span { display: block; height: 100%; }

.cats {
  list-style: none;
  padding: 0;
  margin: 6px 0;
}

.cats li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
}

.cats li .val {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cats i {
  width: 18px;
  height: 5px;
  border-radius: 3px;
  background: var(--c);
  flex: none;
}

.cats i.dashed {
  background: repeating-linear-gradient(90deg, #666 0 4px, transparent 4px 7px);
}

.warn { color: var(--c-mala); margin: 4px 0; }

#weights label {
  display: block;
  margin: 8px 0;
}

#weights output {
  float: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

#weights input[type="range"] {
  width: 100%;
  accent-color: var(--c-bici);
}

#weights button,
#legend summary {
  cursor: pointer;
}

#weights button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
}

#legend {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

#legend summary { color: var(--muted); }

/* --- avisos --- */
#toast {
  position: fixed;
  z-index: 1100;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 120px);
  padding: 8px 14px;
  border-radius: 8px;
  background: #1d2327;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 16px;
}

#loading[hidden] { display: none; }

/* --- marcadores --- */
.pin {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  color: #fff;
  font: 700 13px system-ui, sans-serif;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.pin.a { background: #1d2327; }
.pin.b { background: var(--c-mala); }

.leaflet-container { background: #dfe4e7; }

@media (max-width: 600px) {
  #panel {
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 45vh;
  }

  #toolbar { right: 8px; }
}
