/* =====================================================================
   Cubo · interfaz "liquid glass" oscura con degradés (lenguaje PLANEO:
   Helvetica, títulos en mayúscula, etiquetas espaciadas, botones píldora,
   degradé de tres colores y manchas difusas).
   ===================================================================== */
/* ---------- tipografía: Barlow (texto) + Barlow Condensed (títulos, etiquetas, botones, mapa) ---------- */
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url(vendor/fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url(vendor/fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url(vendor/fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url(vendor/fonts/barlow-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 800; font-display: swap; src: url(vendor/fonts/barlow-latin-800-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url(vendor/fonts/barlow-condensed-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url(vendor/fonts/barlow-condensed-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url(vendor/fonts/barlow-condensed-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-display: swap; src: url(vendor/fonts/barlow-condensed-latin-800-normal.woff2) format("woff2"); }

:root {
  /* identidad */
  --c1: #2fd39a;   /* verde pasto */
  --c2: #3b82f6;   /* azul cielo */
  --c3: #8b5cf6;   /* violeta */
  --grad: linear-gradient(110deg, var(--c1), var(--c2) 52%, var(--c3));
  --grad-soft: linear-gradient(110deg, rgba(47,211,154,.22), rgba(59,130,246,.22) 52%, rgba(139,92,246,.22));

  /* superficies de vidrio */
  --glass: rgba(18, 20, 30, .58);
  --glass-strong: rgba(18, 20, 30, .82);
  --glass-hi: rgba(255, 255, 255, .07);
  --edge: rgba(255, 255, 255, .14);
  --edge-soft: rgba(255, 255, 255, .08);
  --sheen: linear-gradient(160deg, rgba(255,255,255,.14), rgba(255,255,255,.03) 38%, rgba(255,255,255,0) 60%);
  --blur: blur(22px) saturate(170%);

  --text: #f2f3f7;
  --muted: #a3a9b8;
  --danger: #ff6b6b;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .38), 0 2px 8px rgba(0, 0, 0, .25);
  --inner: inset 0 1px 0 rgba(255, 255, 255, .16), inset 0 -1px 0 rgba(0, 0, 0, .25);
  --sans: "Barlow", "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif;
  --display: "Barlow Condensed", "Barlow", "Arial Narrow", sans-serif;

  font-family: var(--sans);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #0b0d12; color: var(--text); -webkit-font-smoothing: antialiased; }
#map { position: fixed; inset: 0; background: #0b0d12; }
.leaflet-container { background: #0b0d12; font: inherit; }
.leaflet-tile { image-rendering: pixelated; }
button { font: inherit; color: inherit; }
input[type=checkbox] { accent-color: var(--c2); width: 15px; height: 15px; cursor: pointer; }
::selection { background: rgba(59,130,246,.45); }

/* ---------- vidrio base ---------- */
.glass, .panel, .search input, .coords, .toast, .editbar, .menu, .btn, dialog,
#search-results, .leaflet-control-zoom, .leaflet-popup-content-wrapper {
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.glass, .panel, .coords, .menu, #search-results, .leaflet-popup-content-wrapper, dialog {
  background: var(--sheen), var(--glass);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow), var(--inner);
}

/* ---------- barra superior ---------- */
.topbar {
  position: fixed; top: 14px; left: 14px; right: 14px; z-index: 1000;
  display: flex; gap: 10px; align-items: center; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px; padding: 7px 16px 7px 9px; border-radius: 999px;
  position: relative; overflow: hidden; isolation: isolate;
}
/* manchas difusas de color detrás del logo, como el "mesh" de PLANEO */
.brand::before {
  content: ""; position: absolute; inset: -60%; z-index: -1; opacity: .5; filter: blur(18px);
  background:
    radial-gradient(circle at 20% 50%, var(--c1), transparent 35%),
    radial-gradient(circle at 60% 30%, var(--c2), transparent 35%),
    radial-gradient(circle at 85% 70%, var(--c3), transparent 35%);
  animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8%, 6%) scale(1.12); }
  100% { transform: translate(-6%, 10%) scale(.92); }
}
.cube { width: 30px; height: 30px; flex: none; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand #title { font-weight: 800; text-transform: uppercase; letter-spacing: -.01em; font-size: 17px; }
.brand small { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

.search { position: relative; flex: 0 1 400px; }
.search-icon { position: absolute; left: 15px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; z-index: 1; }
.search input {
  width: 100%; height: 44px; padding: 0 16px 0 40px; border-radius: 999px;
  border: 1px solid var(--edge); background: var(--sheen), var(--glass); color: var(--text);
  box-shadow: var(--shadow), var(--inner); outline: none; font-size: 14px; transition: border-color .2s, box-shadow .2s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: rgba(59,130,246,.7); box-shadow: var(--shadow), 0 0 0 4px rgba(59,130,246,.18); }
#search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; margin: 0; padding: 6px;
  list-style: none; border-radius: 18px; max-height: 55vh; overflow: auto; background: var(--sheen), var(--glass-strong);
}
#search-results li { padding: 8px 10px; border-radius: 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; font-size: 14px; }
#search-results li:hover, #search-results li.active { background: var(--grad-soft); }
#search-results .kind { margin-left: auto; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }

.account { margin-left: auto; position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px !important; height: 44px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 14px; box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}
.caret { color: var(--muted); font-size: 11px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; border-radius: 18px;
  background: var(--sheen), var(--glass-strong);
}
.menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 11px; cursor: pointer; font-size: 14px; }
.menu button:hover { background: var(--grad-soft); }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 18px; height: 40px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--edge); background: var(--sheen), var(--glass);
  box-shadow: var(--shadow), var(--inner);
  font-weight: 700; font-size: 12.5px; letter-spacing: .07em; text-transform: uppercase;
  transition: transform .15s, border-color .2s, background .2s, filter .2s;
}
.btn:hover { border-color: rgba(255,255,255,.3); background: var(--sheen), rgba(40,44,60,.7); }
.btn:active { transform: scale(.97); }
.btn.primary {
  color: #fff; border: 1px solid rgba(255,255,255,.25);
  background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0) 55%), var(--grad);
  box-shadow: 0 8px 24px rgba(59,130,246,.35), inset 0 1px 0 rgba(255,255,255,.45);
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.btn.primary:hover { filter: brightness(1.08) saturate(1.1); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: rgba(255,107,107,.5); background: rgba(255,107,107,.12); }
.btn.small {
  height: 30px; padding: 0 12px; font-size: 10.5px; box-shadow: var(--inner);
  background: var(--glass-hi); border-color: var(--edge-soft);
}
.btn.small:hover { background: rgba(255,255,255,.12); }
.btn.small.primary { background: var(--grad); }
.btn.add {
  width: 28px; height: 28px; padding: 0; font-size: 17px; font-weight: 600; letter-spacing: 0;
  background: var(--glass-hi); border-color: var(--edge-soft); box-shadow: var(--inner);
}
.btn.add:hover { background: var(--grad); color: #fff; border-color: transparent; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 3px 5px; font-size: 13px; border-radius: 8px; opacity: .75; transition: background .15s, opacity .15s; }
.icon-btn:hover { background: rgba(255,255,255,.1); opacity: 1; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; text-align: left; display: inline-flex; align-items: center; gap: 5px; }
.linkish:hover { text-decoration: underline; text-decoration-color: rgba(255,255,255,.35); text-underline-offset: 3px; }
.picker-head .linkish { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- panel de capas ---------- */
.panel {
  position: fixed; top: 72px; right: 14px; bottom: 50px; z-index: 999; width: 340px;
  display: flex; flex-direction: column; border-radius: 24px; overflow: hidden;
}
.panel.collapsed { width: auto; bottom: auto; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; overflow: visible; }
.panel.collapsed .panel-body { display: none; }
.panel-toggle {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; z-index: 2;
  display: grid; place-items: center; border: 1px solid var(--edge); cursor: pointer;
  background: var(--sheen), var(--glass-strong); box-shadow: var(--inner);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.panel-toggle svg { width: 18px; height: 18px; }
.panel-toggle:hover { background: var(--grad); border-color: transparent; }
.panel.collapsed .panel-toggle { position: static; width: 44px; height: 44px; box-shadow: var(--shadow), var(--inner); }
.panel-body { overflow: auto; overflow-x: hidden; padding: 18px 16px 18px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.panel h2 {
  font-size: 10.5px; font-weight: 400; text-transform: uppercase; letter-spacing: .18em; color: var(--muted);
  margin: 2px 0 10px; display: flex; align-items: center; gap: 8px;
}
.panel h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--edge), transparent); }
.panel h2:first-child { margin-right: 44px; }
.panel h3 { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .01em; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.panel h3 small { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; }
.panel section {
  margin-bottom: 14px; padding: 14px; border-radius: 18px;
  background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); border: 1px solid var(--edge-soft);
}

.layers, .metro-lines { list-style: none; margin: 0 0 18px; padding: 0; }
.layers li {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; margin: 0 -8px; border-radius: 12px;
  transition: background .15s;
}
.layers li:hover { background: rgba(255,255,255,.05); }
.layers label { display: flex; align-items: center; gap: 9px; flex: 1; cursor: pointer; min-width: 0; font-size: 14px; font-weight: 500; }
.layers .count {
  color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums;
  padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.06);
}
.layers .count:empty { display: none; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 1px solid rgba(255,255,255,.35); }
.swatch.line { height: 4px; border: 0; border-radius: 2px; }
.swatch.point { border-radius: 50%; }
.swatch-emoji { font-size: 13px; width: 14px; text-align: center; }
.style-swatch { flex: none; }

.tools-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tools-row:empty { display: none; }
.lines { list-style: none; margin: 0 0 10px; padding: 0; }
.lines li { display: flex; align-items: center; gap: 7px; padding: 5px 6px; margin: 0 -6px; border-radius: 10px; font-size: 13.5px; min-width: 0; }
.lines li:hover { background: rgba(255,255,255,.05); }
.lines li.off { opacity: .4; }
.lines li.no-tramos .style-swatch { opacity: .3; }
.lines li > .linkish + .icon-btn { margin-left: auto; }
.lines li.empty { color: var(--muted); font-size: 13px; }
.lines li > .linkish { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; }
.lines li > .linkish .chip { display: inline-block; vertical-align: middle; margin-right: 3px; }
.lines .count { color: var(--muted); font-size: 10px; letter-spacing: .04em; white-space: nowrap; }
.subtoggles { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); padding-top: 10px; border-top: 1px solid var(--edge-soft); }
.subtoggles label {
  display: flex; align-items: center; gap: 5px; cursor: pointer; padding: 4px 10px 4px 6px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--edge-soft);
}
.metro-lines { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 0; }
.metro-lines li {
  display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--edge-soft); cursor: pointer; font-size: 12.5px; user-select: none;
  transition: background .15s, opacity .15s;
}
.metro-lines li:hover { background: rgba(255,255,255,.1); }
.metro-lines li .dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 0 2px #000; box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.metro-lines li.off { opacity: .35; }
.metro-lines .empty { border: 0; background: none; color: var(--muted); cursor: default; padding: 0; }

/* ---------- etiquetas en el mapa ---------- */
.leaflet-tooltip.lbl {
  background: none; border: 0; box-shadow: none; padding: 0; color: #fff; font-weight: 700;
  text-shadow: 0 0 3px #000, 0 0 2px #000, 0 0 1px #000; white-space: nowrap;
}
.leaflet-tooltip.lbl::before { display: none; }
.lbl-district { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800 !important; }
.lbl-poi { font-size: 12px; }
.lbl-station { font-size: 11px; }
#map[data-zoom="-4"] .lbl-district { display: none; }
#map[data-zoom="-4"] .lbl-poi, #map[data-zoom="-3"] .lbl-poi, #map[data-zoom="-2"] .lbl-poi { display: none; }
#map[data-zoom="-4"] .lbl-station, #map[data-zoom="-3"] .lbl-station, #map[data-zoom="-2"] .lbl-station { display: none; }
.leaflet-tooltip:not(.lbl) {
  background: var(--glass-strong); color: var(--text); border: 1px solid var(--edge); border-radius: 10px;
  box-shadow: var(--shadow); font-weight: 600; font-size: 12.5px; padding: 5px 10px;
}
.leaflet-tooltip:not(.lbl)::before { display: none; }

/* ---------- pines y distintivos ---------- */
.pin-wrap { background: none; border: 0; }
.pin { width: 34px; height: 34px; display: grid; place-items: center; filter: drop-shadow(0 2px 4px rgba(0,0,0,.55)); transition: transform .15s; }
.leaflet-marker-icon:hover .pin { transform: scale(1.12); }
.badge-txt, .badge-emoji, .badge-img {
  display: inline-grid; place-items: center; border-radius: 50%; flex: none; overflow: hidden;
  border: 2px solid #fff; font-weight: 800; line-height: 1; letter-spacing: -.02em;
}
.badge-emoji { font-weight: 400; }
.badge-img { background: #fff; }
.badge-img img { width: 100%; height: 100%; object-fit: contain; }
.exit-icon {
  width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; font-size: 11px; font-weight: 800;
  background: linear-gradient(180deg, #3fae5a, #237a3a); color: #fff; border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,.55);
}
.exit-mini { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 6px; background: #2b8a3e; color: #fff; font-size: 11px; font-weight: 800; }
#map[data-zoom="-4"] .exit-icon, #map[data-zoom="-3"] .exit-icon, #map[data-zoom="-2"] .exit-icon, #map[data-zoom="-1"] .exit-icon { display: none; }
#map[data-zoom="-4"] .pin { transform: scale(.6); }

/* ---------- popups ---------- */
.leaflet-popup-content-wrapper { color: var(--text); border-radius: 20px; padding: 0; background: var(--sheen), var(--glass-strong); }
.leaflet-popup-tip { background: rgba(18,20,30,.85); box-shadow: none; }
.leaflet-popup-content { margin: 16px 18px; min-width: 220px; font-size: 13.5px; line-height: 1.45; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); top: 8px; right: 8px; width: 24px; height: 24px; font-size: 18px; border-radius: 50%; }
.leaflet-container a.leaflet-popup-close-button:hover { background: rgba(255,255,255,.1); color: #fff; }
.pop h4 { margin: 0 24px 4px 0; font-size: 16px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.pop .layer-name { color: var(--muted); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; }
.pop .desc { white-space: pre-wrap; margin: 8px 0; }
.pop .meta { color: var(--muted); font-size: 11.5px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--edge-soft); }
.pop .tools { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.pop .chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.pop-head { display: flex; gap: 12px; align-items: center; margin-bottom: 4px; }
.pop .small { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.pop .exits { margin-top: 10px; font-size: 13px; }
.pop .exits b { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.pop .exits ul { list-style: none; margin: 6px 0 0; padding: 0; }
.pop .exits li { margin: 4px 0; display: flex; gap: 8px; align-items: center; }
.chip {
  display: inline-block; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 800; color: #fff; text-shadow: 0 0 2px rgba(0,0,0,.8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3);
}
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; background: rgba(255,255,255,.1); color: #fff; }
.badge.planificado { background: #3b5bdb; } .badge.en_obra { background: #e8590c; } .badge.terminado { background: #2f9e44; }

/* ---------- abajo / flotantes ---------- */
.coords {
  position: fixed; left: 14px; bottom: 14px; z-index: 999; padding: 7px 14px; font-size: 12.5px; border-radius: 999px;
  font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .02em;
}
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 2000; max-width: min(640px, calc(100vw - 32px));
  padding: 11px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600; text-align: center;
  background: linear-gradient(var(--glass-strong), var(--glass-strong)) padding-box, var(--grad) border-box;
  border: 1.5px solid transparent; box-shadow: var(--shadow);
  animation: pop-in .25s ease-out;
}
.toast.err { background: linear-gradient(var(--glass-strong), var(--glass-strong)) padding-box, linear-gradient(90deg, #ff6b6b, #f59f00) border-box; }
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.editbar {
  position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: 1001;
  display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: linear-gradient(var(--glass-strong), var(--glass-strong)) padding-box, var(--grad) border-box;
  border: 1.5px solid transparent; box-shadow: var(--shadow);
}
.editbar .btn { height: 34px; }

/* controles de Leaflet */
.leaflet-top.leaflet-left { top: 58px; }
.leaflet-control-zoom {
  border: 1px solid var(--edge) !important; border-radius: 16px !important; overflow: hidden;
  background: var(--sheen), var(--glass); box-shadow: var(--shadow), var(--inner) !important; margin-left: 14px !important;
}
.leaflet-control-zoom a {
  background: transparent !important; color: var(--text) !important; border: 0 !important;
  width: 38px !important; height: 38px !important; line-height: 38px !important; font-size: 18px !important;
}
.leaflet-control-zoom a + a { border-top: 1px solid var(--edge-soft) !important; }
.leaflet-control-zoom a:hover { background: rgba(255,255,255,.1) !important; }
.leaflet-control-attribution { background: rgba(0,0,0,.35) !important; color: var(--muted) !important; border-radius: 999px 0 0 0; padding: 2px 10px !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

/* ---------- diálogos ---------- */
dialog {
  border-radius: 26px; padding: 0; width: min(440px, calc(100vw - 32px)); color: var(--text);
  background: var(--sheen), rgba(20, 22, 34, .86); overflow: visible;
  animation: dlg-in .22s ease-out;
}
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
dialog.wide { width: min(660px, calc(100vw - 32px)); }
dialog.xwide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(6, 8, 14, .55); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
/* banda superior con degradé difuso */
dialog > form, dialog > h3:first-child { position: relative; }
dialog > form, dialog { --pad: 22px; }
dialog > form { padding: var(--pad); }
dialog:not(:has(> form:first-child)) { padding: var(--pad); }
dialog::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 110px; border-radius: 26px 26px 0 0; pointer-events: none; z-index: -1;
  background:
    radial-gradient(ellipse 60% 120% at 8% 0%, rgba(47,211,154,.28), transparent 70%),
    radial-gradient(ellipse 55% 120% at 55% 0%, rgba(59,130,246,.24), transparent 70%),
    radial-gradient(ellipse 50% 120% at 100% 0%, rgba(139,92,246,.28), transparent 70%);
}
dialog h3 { margin: 0 0 16px; font-size: 21px; font-weight: 800; text-transform: uppercase; letter-spacing: -.015em; line-height: 1.05; position: relative; }
dialog h4 { margin: 18px 0 8px; width: 100%; font-size: 10.5px; font-weight: 400; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
dialog label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
dialog label.row { flex-direction: row; align-items: center; gap: 10px; }
dialog label.row, .checklist label, .road-form legend label, dialog label:has(> input[type=checkbox]) { text-transform: none; letter-spacing: 0; font-size: 13.5px; color: var(--text); }
dialog input:not([type=checkbox]):not([type=range]):not([type=color]), dialog select, dialog textarea {
  font: inherit; font-size: 14px; letter-spacing: 0; text-transform: none; color: var(--text);
  background: rgba(255,255,255,.06); border: 1px solid var(--edge-soft); border-radius: var(--radius-sm);
  padding: 10px 13px; outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
dialog select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a3a9b8' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; }
dialog select option { background: #1b1e2b; }
dialog input:focus, dialog select:focus, dialog textarea:focus { border-color: rgba(59,130,246,.7); background-color: rgba(255,255,255,.09); box-shadow: 0 0 0 4px rgba(59,130,246,.16); }
dialog textarea { resize: vertical; min-height: 72px; }
dialog input[type=color] {
  appearance: none; -webkit-appearance: none; width: 40px; height: 40px; padding: 0; border: 2px solid rgba(255,255,255,.25);
  border-radius: 50%; background: none; cursor: pointer; overflow: hidden; box-shadow: var(--inner);
}
dialog input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
dialog input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; }
dialog input[type=color]::-moz-color-swatch { border: 0; border-radius: 50%; }
input[type=range] { accent-color: var(--c2); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; align-items: center; }
.error { color: var(--danger); margin: 6px 0; font-size: 13.5px; font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 12px; line-height: 1.45; text-transform: none; letter-spacing: 0; }
.spacer { flex: 1; }
form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline label { margin: 0; }
form.inline input:not([type=checkbox]):not([type=color]) { flex: 1 1 140px; }
input.short { flex: 0 0 76px !important; }
.grid2 { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.grid2 > label { margin-bottom: 14px; }
.row-inline { display: flex; gap: 8px; align-items: center; }
.row-inline select { flex: 1; }
.field { margin-bottom: 14px; }
.flabel { display: block; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.checklist { display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow: auto; padding: 8px 10px; border: 1px solid var(--edge-soft); border-radius: var(--radius-sm); background: rgba(255,255,255,.03); }
.checklist label { margin: 0; padding: 4px 0; }
.style-preview, .road-preview {
  padding: 12px; margin: -4px 0 14px; border-radius: 16px; display: flex; flex-direction: column; align-items: center;
  background: radial-gradient(circle at 30% 20%, #4d6a3f, #33472b 70%); box-shadow: inset 0 2px 10px rgba(0,0,0,.35);
}
.road-preview .hint { margin: 8px 0 0; color: #d9e3cf; font-size: 11px; }

/* tablas e historial */
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th, table.users td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--edge-soft); }
table.users th { color: var(--muted); font-weight: 400; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; }
table.users td:last-child { text-align: right; white-space: nowrap; }
.history { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.history li { padding: 10px 8px; border-bottom: 1px solid var(--edge-soft); font-size: 14px; display: flex; gap: 8px; border-radius: 10px; }
.history li.link { cursor: pointer; }
.history li.link:hover { background: var(--grad-soft); }
.history .when { color: var(--muted); margin-left: auto; white-space: nowrap; font-size: 11.5px; }
.history .act-create { color: #69db7c; font-weight: 700; } .history .act-update { color: #ffd43b; font-weight: 700; } .history .act-delete { color: #ff8787; font-weight: 700; }

/* selector de marcas */
.brand-picker { margin-bottom: 14px; }
.picker-head { display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; max-height: 240px; overflow: auto; padding: 2px; }
.brand-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; border-radius: 14px;
  border: 1px solid var(--edge-soft); background: rgba(255,255,255,.04); cursor: pointer; font-size: 11.5px; font-weight: 600; text-align: center;
  transition: transform .15s, background .15s, border-color .15s;
}
.brand-tile:hover { background: rgba(255,255,255,.09); transform: translateY(-1px); }
.brand-tile.sel {
  background: linear-gradient(rgba(30,34,50,.9), rgba(30,34,50,.9)) padding-box, var(--grad) border-box;
  border: 1.5px solid transparent; box-shadow: 0 6px 18px rgba(59,130,246,.25);
}
.icon-field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.icon-field .hint { margin: 0; flex-basis: 100%; }
.brand-admin { max-height: 50vh; overflow: auto; padding-right: 4px; }
.brand-rows { display: grid; gap: 4px; }
.brand-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 12px; }
.brand-row:hover { background: rgba(255,255,255,.04); }
.brand-row .bname { flex: 1; font-weight: 600; font-size: 14px; }

/* autocompletado */
.suggest-wrap { position: relative; }
.suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10; margin: 6px 0 0; padding: 6px; list-style: none;
  background: var(--sheen), rgba(24, 27, 40, .97); border: 1px solid var(--edge); border-radius: 16px; box-shadow: var(--shadow);
  color: var(--text); text-transform: none; letter-spacing: 0;
}
.suggest li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 11px; cursor: pointer; font-size: 14px; font-weight: 600; }
.suggest li.active, .suggest li:hover { background: var(--grad-soft); }
.suggest .kind { margin-left: auto; color: var(--muted); font-size: 10.5px; font-weight: 400; letter-spacing: .1em; text-transform: uppercase; }
.rname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* editor de tipos de vía */
.roads-editor { display: grid; grid-template-columns: 250px 1fr; gap: 18px; }
.road-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.road-list li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 13px; cursor: pointer; border: 1px solid transparent; font-weight: 600; font-size: 14px; }
.road-list li:hover { background: rgba(255,255,255,.05); }
.road-list li.sel { background: linear-gradient(rgba(30,34,50,.92), rgba(30,34,50,.92)) padding-box, var(--grad) border-box; border: 1.5px solid transparent; }
.road-list .count { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 400; }
.road-form fieldset { border: 1px solid var(--edge-soft); border-radius: 16px; padding: 6px 12px 0; margin: 0 0 14px; background: rgba(255,255,255,.025); }
.road-form legend { padding: 0 4px; }
.road-form legend label { margin: 0; }
.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; padding: 0; }
.range output { min-width: 30px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 700; letter-spacing: 0; }
input:disabled, select:disabled { opacity: .35; }

/* ---------- tipografía aplicada ---------- */
body, input, select, textarea, button, .leaflet-container { font-family: var(--sans); }

/* Títulos y marca: condensada, mayúscula, pesada */
.brand #title, dialog h3, .panel h3, .pop h4 {
  font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .01em;
}
.brand #title { font-size: 21px; }
dialog h3 { font-size: 27px; line-height: .95; }
.panel h3 { font-size: 17px; }
.pop h4 { font-size: 20px; line-height: 1; }

/* Etiquetas tipo "kicker" (secciones, campos, categorías): condensada espaciada */
.brand small, .panel h2, dialog h4, dialog label, .flabel, .picker-head, .pop .layer-name, .pop .exits b,
table.users th, #search-results .kind, .suggest .kind, .badge {
  font-family: var(--display); font-weight: 600; letter-spacing: .14em;
}
.brand small { font-size: 11px; }
.panel h2 { font-size: 12.5px; }
dialog h4, dialog label, .flabel, .picker-head { font-size: 12px; }
.pop .layer-name { font-size: 12px; }
/* dentro de un label, el contenido (inputs, opciones) vuelve a la fuente de texto */
dialog label > *:not(span.range), dialog label.row, .checklist label, .road-form legend label, dialog label:has(> input[type=checkbox]) {
  font-family: var(--sans); font-weight: 500; letter-spacing: 0;
}

/* Botones: condensada en mayúscula, estilo señalética */
.btn, .linkish.picker-link, .picker-head .linkish {
  font-family: var(--display); font-weight: 700; letter-spacing: .08em;
}
.btn { font-size: 14.5px; }
.btn.small { font-size: 12.5px; }
.picker-head .linkish { font-size: 13px; }
.btn.add { font-family: var(--sans); }

/* Listas del panel */
.layers label { font-weight: 600; font-size: 15px; }
.lines li { font-weight: 600; font-size: 14.5px; }
.metro-lines li, .subtoggles label { font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: .02em; }
.chip, .metro-lines li .dot, .exit-icon, .exit-mini, .avatar { font-family: var(--display); font-weight: 800; letter-spacing: .02em; }
.chip { font-size: 13px; }
.layers .count, .road-list .count { font-family: var(--display); font-weight: 600; font-size: 12.5px; letter-spacing: .04em; }

/* Barra, menú, coordenadas, avisos */
#user-name { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .06em; }
.menu button { font-weight: 600; font-size: 15px; }
.coords { font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: .06em; }
.toast, .editbar { font-weight: 600; font-size: 15px; }
.search input { font-size: 15px; font-weight: 500; }

/* Mapa: etiquetas de estaciones, lugares y distritos en condensada (más legible y ocupa menos) */
.leaflet-tooltip.lbl { font-family: var(--display); font-weight: 700; letter-spacing: .02em; }
.lbl-district { font-size: 18px; letter-spacing: .1em; }
.lbl-poi { font-size: 14px; }
.lbl-station { font-size: 13px; }
.leaflet-tooltip:not(.lbl) { font-family: var(--display); font-weight: 600; font-size: 14px; letter-spacing: .02em; }
.badge-txt { font-family: var(--display); font-weight: 800; }

/* Formularios, popups e historial */
.pop, .history li, table.users td, .suggest li, .road-list li, .brand-row .bname, .brand-tile { font-family: var(--sans); }
.pop .meta, .history .when { font-family: var(--display); font-weight: 500; font-size: 13px; letter-spacing: .03em; }
.road-list li { font-weight: 600; font-size: 15px; }
.range output { font-family: var(--display); font-size: 15px; }

/* =====================================================================
   Lore: hoja lateral izquierda
   ===================================================================== */
.lore-btn { height: 44px; gap: 8px; padding: 0 16px; }
.lore-btn svg { width: 18px; height: 18px; }
body.lore-open .lore-btn { background: linear-gradient(180deg, rgba(255,255,255,.2), rgba(255,255,255,0) 55%), var(--grad); border-color: rgba(255,255,255,.25); }

.lore-sheet {
  position: fixed; top: 72px; left: 14px; bottom: 14px; z-index: 1001; width: 440px;
  display: flex; flex-direction: column; border-radius: 26px; overflow: hidden;
  background: var(--sheen), rgba(16, 18, 28, .84); border: 1px solid var(--edge); box-shadow: var(--shadow), var(--inner);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  animation: sheet-in .25s ease-out;
}
@keyframes sheet-in { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
body.lore-open .leaflet-top.leaflet-left { left: 468px; }
body.lore-open .coords { left: 468px; }
.lore-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--edge-soft);
  background: linear-gradient(110deg, rgba(47,211,154,.12), rgba(59,130,246,.10) 50%, rgba(139,92,246,.12));
}
.round-btn {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--edge-soft); background: rgba(255,255,255,.06); color: var(--text);
}
.round-btn:hover { background: rgba(255,255,255,.14); }
.round-btn svg { width: 16px; height: 16px; }
.lore-home { background: none; border: 0; cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.lore-home:hover { color: var(--text); }
.lore-body { flex: 1; overflow: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.lore-body .muted, .muted { color: var(--muted); }
.lore-empty { color: var(--muted); padding: 8px 2px; font-size: 14.5px; }
.lore-empty a { color: var(--c2); }

/* portada de la ficha */
.ficha-hero { position: relative; min-height: 150px; display: flex; align-items: flex-end; overflow: hidden; isolation: isolate; }
.ficha-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.ficha-hero.has-img { min-height: 230px; }
.ficha-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(16,18,28,0) 30%, rgba(16,18,28,.92) 100%); }
.hero-mesh {
  position: absolute; inset: 0; z-index: -2; display: grid; place-items: center end; padding-right: 28px;
  background:
    radial-gradient(circle at 15% 20%, rgba(47,211,154,.55), transparent 45%),
    radial-gradient(circle at 60% 0%, rgba(59,130,246,.5), transparent 50%),
    radial-gradient(circle at 95% 60%, rgba(139,92,246,.55), transparent 50%), #1a1d2b;
}
.hero-icon { font-size: 64px; opacity: .35; filter: saturate(.6); }
.hero-text { padding: 18px 20px 14px; width: 100%; }
.kicker { font-family: var(--display); font-weight: 600; font-size: 12.5px; letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.75); margin-bottom: 4px; }
.ficha-hero h2, .lore-title h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 34px; line-height: .95; text-transform: uppercase; letter-spacing: .005em; }
.ficha-hero .summary { margin: 8px 0 0; font-size: 15px; line-height: 1.4; color: rgba(255,255,255,.88); }

.ficha { padding-bottom: 8px; }
.ficha > :not(.ficha-hero) { margin-left: 20px; margin-right: 20px; }
.infobox {
  display: grid; grid-template-columns: auto 1fr; gap: 0; margin-top: 14px; margin-bottom: 4px;
  border: 1px solid var(--edge-soft); border-radius: 16px; overflow: hidden; background: rgba(255,255,255,.035);
}
.infobox dt, .infobox dd { margin: 0; padding: 9px 12px; border-bottom: 1px solid var(--edge-soft); }
.infobox dt { font-family: var(--display); font-weight: 600; font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.infobox dd { font-weight: 600; font-size: 14.5px; }
.infobox dt:nth-last-of-type(1), .infobox dd:last-of-type { border-bottom: 0; }
.maplink { color: var(--c1); text-decoration: none; font-family: var(--display); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 13px; }
.maplink:hover { text-decoration: underline; }
.ficha-sec { margin-top: 20px; }
.ficha-sec h3 {
  margin: 0 0 10px; font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.ficha-sec h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--edge), transparent); }
.milestones { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid transparent; border-image: var(--grad) 1; }
.milestones li { position: relative; padding: 4px 0 8px 14px; display: flex; gap: 10px; align-items: baseline; font-size: 14.5px; }
.milestones li::before { content: ""; position: absolute; left: -21px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(59,130,246,.35); }
.milestones time { font-family: var(--display); font-weight: 700; letter-spacing: .04em; min-width: 92px; color: var(--text); }
.milestones span { color: rgba(255,255,255,.85); }
.roles { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.roles li { padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--edge-soft); font-size: 14.5px; }
.roles li.current { background: linear-gradient(rgba(26,30,45,.95), rgba(26,30,45,.95)) padding-box, var(--grad) border-box; border: 1px solid transparent; }
.roles small { display: block; color: var(--muted); font-family: var(--display); font-size: 13px; letter-spacing: .04em; margin-top: 2px; }
a.wl { color: #8cc4ff; text-decoration: none; font-weight: 600; }
a.wl:hover { text-decoration: underline; }
a.wl.missing { color: #ff9d9d; text-decoration: underline dotted; }
.prose { font-size: 15.5px; line-height: 1.6; color: rgba(255,255,255,.92); }
.prose p { margin: 0 0 12px; }
.prose h3 { font-family: var(--display); font-weight: 800; font-size: 22px; text-transform: uppercase; margin: 18px 0 8px; letter-spacing: .01em; color: var(--text); }
.prose h4 { font-family: var(--display); font-weight: 700; font-size: 17px; text-transform: uppercase; margin: 14px 0 6px; letter-spacing: .04em; color: var(--text); }
.prose ul { margin: 0 0 12px; padding-left: 20px; }
.prose code { font-family: Consolas, "Cascadia Mono", monospace; font-size: .88em; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,.09); }
.prose blockquote { margin: 0 0 12px; padding: 8px 14px; border-left: 3px solid var(--c3); background: rgba(139,92,246,.1); border-radius: 0 10px 10px 0; font-style: italic; }
.lore-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lore-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px 4px 4px; border-radius: 999px; font-size: 13.5px;
  background: rgba(255,255,255,.06); border: 1px solid var(--edge-soft); color: var(--text) !important; text-decoration: none !important;
}
a.lore-chip:hover { background: var(--grad-soft); }
.lore-chip img, .lore-chip .ic { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; font-size: 12px; background: rgba(255,255,255,.08); }
.lore-chip .x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 0 0 2px; }
.ficha-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--edge-soft); font-size: 13px; font-family: var(--display); letter-spacing: .03em; }
.ficha-foot .tools { display: flex; gap: 6px; }

/* índice y línea de tiempo */
.lore-index, .lore-form { padding: 18px 20px 20px; }
.lore-title { margin-bottom: 14px; }
.lore-title h2 { font-size: 36px; }
.lore-actions { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 16px; background: rgba(255,255,255,.05); border: 1px solid var(--edge-soft); margin-bottom: 12px; }
.seg button {
  flex: 1 1 auto; border: 0; background: none; cursor: pointer; padding: 6px 10px; border-radius: 12px; color: var(--muted);
  font-family: var(--display); font-weight: 700; font-size: 13.5px; letter-spacing: .06em; text-transform: uppercase; display: inline-flex; gap: 6px; align-items: center; justify-content: center;
}
.seg button span { font-size: 11.5px; opacity: .7; }
.seg button.on { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(59,130,246,.3); }
.lore-search {
  width: 100%; height: 42px; border-radius: 999px; padding: 0 16px; margin-bottom: 12px; font: inherit; font-size: 15px;
  background: rgba(255,255,255,.06); border: 1px solid var(--edge-soft); color: var(--text); outline: none;
}
.lore-search:focus { border-color: rgba(59,130,246,.7); box-shadow: 0 0 0 4px rgba(59,130,246,.16); }
.lore-list { display: grid; gap: 8px; }
.lore-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 16px; text-decoration: none !important; color: var(--text) !important;
  background: rgba(255,255,255,.04); border: 1px solid var(--edge-soft); transition: background .15s, transform .15s;
}
.lore-card:hover { background: var(--grad-soft); transform: translateY(-1px); }
.lore-card img, .lore-card .ic { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex: none; display: grid; place-items: center; font-size: 24px; background: linear-gradient(135deg, rgba(47,211,154,.3), rgba(139,92,246,.3)); }
.lore-card b { display: block; font-family: var(--display); font-weight: 800; font-size: 18px; text-transform: uppercase; letter-spacing: .01em; line-height: 1.05; }
.lore-card small { font-family: var(--display); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-size: 11.5px; }
.lore-card p { margin: 4px 0 0; font-size: 13.5px; color: rgba(255,255,255,.8); line-height: 1.35; font-weight: 400; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline .year { font-family: var(--display); font-weight: 800; font-size: 28px; margin: 14px 0 6px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.timeline .ev { display: flex; gap: 12px; padding: 8px 0 8px 14px; border-left: 2px solid var(--edge); position: relative; }
.timeline .ev::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--c2); box-shadow: 0 0 0 3px rgba(59,130,246,.25); }
.timeline .ev.k-personaje::before { background: var(--c3); } .timeline .ev.k-lugar::before { background: var(--c1); } .timeline .ev.k-evento::before { background: #f59f00; }
.timeline time { font-family: var(--display); font-weight: 700; min-width: 58px; color: var(--muted); letter-spacing: .04em; }
.timeline .ev div { display: flex; flex-direction: column; }
.timeline .ev span { font-size: 14px; color: rgba(255,255,255,.85); }
.revs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.revs li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--edge-soft); }
.revs li div { flex: 1; }
.revs small { color: var(--muted); font-family: var(--display); letter-spacing: .03em; }
.revs .badge { margin-left: 6px; background: var(--grad); }
.rev-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; background: rgba(245,159,0,.15); border-bottom: 1px solid rgba(245,159,0,.4); font-family: var(--display); font-weight: 600; letter-spacing: .04em; }

/* editor de fichas */
.lore-form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-family: var(--display); font-weight: 600; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.lore-form input:not([type=checkbox]), .lore-form select, .lore-form textarea {
  font: inherit; font-family: var(--sans); font-size: 14.5px; letter-spacing: 0; text-transform: none; color: var(--text); width: 100%; min-width: 0;
  background: rgba(255,255,255,.06); border: 1px solid var(--edge-soft); border-radius: var(--radius-sm); padding: 9px 12px; outline: none;
}
.lore-form select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a3a9b8' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.lore-form select option, .lore-form select optgroup { background: #1b1e2b; }
.lore-form input:focus, .lore-form select:focus, .lore-form textarea:focus { border-color: rgba(59,130,246,.7); box-shadow: 0 0 0 4px rgba(59,130,246,.16); }
.lore-form input:invalid:not(:placeholder-shown) { border-color: rgba(255,107,107,.7); }
.lore-form .g-kind { grid-template-columns: 150px 1fr; }
.body-ta { min-height: 220px; resize: vertical; line-height: 1.5; }
.img-field { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.img-field img, .img-ph { width: 76px; height: 76px; border-radius: 16px; object-fit: cover; flex: none; display: grid; place-items: center; font-size: 30px; background: linear-gradient(135deg, rgba(47,211,154,.3), rgba(139,92,246,.3)); border: 1px solid var(--edge-soft); }
.img-field .hint { margin: 6px 0 0; }
.img-field div > .btn { margin-right: 6px; }
.rows-ed .rows { display: grid; gap: 6px; margin-bottom: 8px; }
.row-ed { display: flex; gap: 6px; align-items: center; }
.row-ed > input { flex: 1; }
.row-ed .w-key { flex: 0 0 38%; }
.row-ed .w-date { flex: 0 0 130px; }
.role-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--edge-soft); }
.role-grid .w-date { width: 100%; }
.rel-ed .lore-chips { margin-bottom: 8px; }
.md-help { margin-top: -6px; }
.md-help code { font-size: 12px; padding: 1px 5px; border-radius: 5px; background: rgba(255,255,255,.08); }
.sticky-actions { position: sticky; bottom: -20px; margin: 0 -20px -20px; padding: 12px 20px; background: linear-gradient(transparent, rgba(16,18,28,.95) 30%); }

/* editor visual de la historia */
.rte { position: relative; }
.rte-bar {
  position: sticky; top: -18px; z-index: 3; display: flex; flex-wrap: wrap; gap: 3px; align-items: center; padding: 5px;
  border: 1px solid var(--edge-soft); border-bottom: 0; border-radius: 14px 14px 0 0;
  background: linear-gradient(110deg, rgba(47,211,154,.12), rgba(59,130,246,.10) 50%, rgba(139,92,246,.12)), rgba(22,25,38,.96);
}
.rte-btn {
  height: 30px; min-width: 32px; padding: 0 9px; border-radius: 9px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--text);
  font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase;
}
.rte-btn b, .rte-btn i { font-family: var(--sans); font-size: 15px; text-transform: none; }
.rte-btn:hover { background: rgba(255,255,255,.1); }
.rte-btn.on { background: var(--grad); color: #fff; box-shadow: 0 3px 10px rgba(59,130,246,.3); }
.rte-sep { width: 1px; height: 20px; background: var(--edge); margin: 0 3px; }
.rte-area {
  min-height: 240px; max-height: none; padding: 12px 14px; outline: none; cursor: text;
  background: rgba(255,255,255,.05); border: 1px solid var(--edge-soft); border-radius: 0 0 14px 14px;
  font-family: var(--sans); font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--text);
}
.rte-area:focus { border-color: rgba(59,130,246,.7); box-shadow: 0 0 0 4px rgba(59,130,246,.16); }
.rte-area:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.rte-area > :first-child { margin-top: 0; }
.rte-area a.wl { cursor: text; }
.rte-link {
  position: absolute; left: 6px; right: 6px; top: 44px; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; padding: 8px;
  background: var(--sheen), rgba(24,27,40,.98); border: 1px solid var(--edge); border-radius: 14px; box-shadow: var(--shadow);
}
.rte-link input { flex: 1; }
.rte-link-list { list-style: none; margin: 0; padding: 0; flex-basis: 100%; order: 3; display: grid; gap: 2px; max-height: 240px; overflow: auto; }
.rte-link-list li { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text); font-family: var(--sans); }
.rte-link-list li:hover { background: var(--grad-soft); }
.rte-link-list li .ic { width: 22px; text-align: center; }
.rte-link-list li small { margin-left: auto; color: var(--muted); font-family: var(--display); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; font-size: 11px; }
.rte-link-list li.new { color: #ff9d9d; }

/* =====================================================================
   Administración
   ===================================================================== */
dialog.admin-dlg { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 22px; flex-direction: column; }
/* solo cuando está abierto: un display propio sin [open] haría visible el diálogo cerrado */
dialog.admin-dlg[open] { display: flex; }
.admin-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; position: relative; }
.admin-head h3 { margin: 0; }
.admin-head .kicker { color: var(--muted); }
.admin-head a.btn { text-decoration: none; color: #fff; }
.admin-tabs { flex: none; }
.admin-body { overflow: auto; flex: 1; min-height: 200px; padding-right: 4px; margin-right: -4px; }
.adm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.adm-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 18px;
  background: linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.02)); border: 1px solid var(--edge-soft);
}
.adm-card small { font-family: var(--display); font-weight: 600; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.adm-card b { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.05; }
.adm-card span { font-size: 13px; color: rgba(255,255,255,.75); }
.adm-card.ok { border-color: rgba(47,211,154,.35); }
.adm-card.ok b { color: #6ff2c0; }
.adm-card.warn { border-color: rgba(245,159,0,.5); }
.adm-card.warn b { color: #ffc14d; }
.adm-alert { padding: 10px 14px; border-radius: 14px; background: rgba(245,159,0,.14); border: 1px solid rgba(245,159,0,.45); margin-bottom: 12px; font-size: 14px; }
.adm-services { display: grid; gap: 10px; }
.svc { padding: 14px 16px; border-radius: 18px; background: rgba(255,255,255,.04); border: 1px solid var(--edge-soft); }
.svc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.svc-head small, .svc-cost small { font-family: var(--display); font-weight: 600; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.svc-head h4 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 22px; text-transform: uppercase; letter-spacing: .01em; }
.svc-head .ext { color: var(--c2); text-decoration: none; font-size: 16px; }
.svc-cost { text-align: right; display: flex; flex-direction: column; }
.svc-cost b { font-family: var(--display); font-weight: 800; font-size: 22px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.svc p { margin: 6px 0; font-size: 14.5px; color: rgba(255,255,255,.88); }
.svc dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: 13.5px; }
.svc dt { font-family: var(--display); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; font-size: 12px; color: var(--muted); padding-top: 1px; }
.svc dd { margin: 0; white-space: pre-wrap; }
.svc dd.warn { color: #ffc14d; font-weight: 700; }
.svc .tools { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.svc-form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-family: var(--display); font-weight: 600; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.svc-form input, .svc-form select, .svc-form textarea { font: inherit; font-family: var(--sans); font-size: 14.5px; letter-spacing: 0; text-transform: none; }
.grid-svc { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 10px; }
.adm-kv { grid-template-columns: 160px 1fr; margin-top: 0; }
.adm-kv dd { font-weight: 500; word-break: break-word; }
.adm-h { margin: 18px 0 8px !important; }
.adm-props { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.adm-props span { display: flex; flex-direction: column; padding: 7px 10px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid var(--edge-soft); font-weight: 600; font-size: 14px; }
.adm-props small { font-family: var(--display); font-weight: 600; letter-spacing: .06em; color: var(--muted); font-size: 11.5px; }
.adm-mods td { vertical-align: top; }
.adm-mods .small { font-size: 11.5px; }
.badge.warn { background: #b26a00; }
.adm-notes { display: grid; gap: 12px; }
.note { padding: 14px 16px; border-radius: 18px; background: rgba(255,255,255,.04); border: 1px solid var(--edge-soft); }
.note-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.note-head h4 { margin: 0; flex: 1; font-family: var(--display); font-weight: 800; font-size: 20px; text-transform: uppercase; letter-spacing: .01em; color: var(--text); }
.note-head .tools { display: flex; gap: 6px; align-items: center; }
.note .prose { font-size: 14.5px; }
.note .prose code, .adm-notes code { font-size: 12.5px; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,.08); }
.note-edit label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

/* resaltado de lugares en el mapa */
.lore-glow { filter: drop-shadow(0 0 6px rgba(120, 200, 255, .9)) drop-shadow(0 0 14px rgba(139, 92, 246, .7)); animation: glow 1.8s ease-in-out infinite alternate; }
@keyframes glow { from { stroke-opacity: .45; } to { stroke-opacity: 1; } }
.lore-row { margin-top: 8px !important; }
.btn.small.primary.lore-pop-btn { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); border-color: rgba(255,255,255,.3); }

@media (max-width: 760px) {
  .lore-sheet { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 62vh; border-radius: 26px 26px 0 0; }
  body.lore-open .leaflet-top.leaflet-left, body.lore-open .coords { left: 0; }
  .lore-btn span { display: none; }
  .lore-btn { width: 44px; padding: 0; }
}

/* ---------- responsive ---------- */
@media (max-width: 760px) { .roads-editor { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .brand-text small { display: none; }
  .brand { padding-right: 12px; }
  .brand #title { display: none; }
  .user-btn #user-name, .user-btn .caret { display: none; }
  .user-btn { padding: 5px !important; }
  .panel { top: auto; bottom: 58px; left: 14px; right: 14px; width: auto; max-height: 48vh; }
  .panel.collapsed { left: auto; }
  .coords { font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .brand::before, .toast, dialog { animation: none; }
}
