/* Pulido visual Territorio: tierra | mapa | mar. Solo presentación. */
.territorio-real .territorio-locality-label {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #43545b;
  font: 600 11px/1.12 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .005em;
  text-align: left;
  text-shadow:
    -1px -1px 0 rgba(250, 249, 244, .95),
     1px -1px 0 rgba(250, 249, 244, .95),
    -1px  1px 0 rgba(250, 249, 244, .95),
     1px  1px 0 rgba(250, 249, 244, .95),
     0 0 3px rgba(250, 249, 244, .92);
  white-space: nowrap;
  pointer-events: none;
}

.territorio-real .territorio-locality-label::before { display: none; }

.territorio-real #addr-search,
.territorio-real #addr-search:focus {
  background: transparent;
  border: 0;
  outline: 0;
  box-shadow: none;
}

.territorio-real .localities-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px 16px;
}

.territorio-real .locality-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid rgba(40, 93, 100, .20);
  border-radius: 8px;
  background: rgba(255, 253, 247, .95);
  color: #193d50;
  font: 600 13px/1.25 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: left;
  cursor: pointer;
}

.territorio-real .locality-nav-btn:hover,
.territorio-real .locality-nav-btn:focus-visible {
  background: rgba(231, 241, 234, .97);
  border-color: rgba(36, 94, 122, .42);
  outline: 0;
}

.territorio-real .locality-nav-btn:active { transform: translateY(1px); }
.territorio-real .locality-nav-btn .ic {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  color: #245e7a;
}
.territorio-real .locality-nav-btn span:nth-child(2) { min-width: 0; }
.territorio-real .locality-nav-arrow {
  margin-left: auto;
  color: #66808a;
  font-size: 16px;
  font-weight: 500;
}

/* T1.1: el embed conserva la misma app y superpone su navegación al mapa. */
.territorio-real .embed-open-full {
  display: none;
}

.territorio-real .embed-title,
.territorio-real .embed-notice {
  display: none;
}

.territorio-real.embed-mode {
  overflow: hidden;
}

.territorio-real.embed-mode .embed-title {
  position: absolute;
  top: 12px;
  left: calc(var(--rail-w) + 12px);
  z-index: 55;
  display: block;
  max-width: min(44vw, 420px);
  box-sizing: border-box;
  margin: 0;
  padding: 7px 11px;
  overflow: hidden;
  border: 1px solid rgba(36, 94, 122, .22);
  border-radius: 8px;
  background: rgba(250, 249, 244, .92);
  color: #193d50;
  box-shadow: 0 3px 12px rgba(16, 49, 63, .14);
  font: 700 13px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.territorio-real.embed-mode .embed-notice {
  position: absolute;
  top: 56px;
  left: calc(var(--rail-w) + 12px);
  z-index: 55;
  display: block;
  max-width: min(420px, calc(100% - var(--rail-w) - 24px));
  box-sizing: border-box;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid rgba(143, 98, 25, .30);
  border-radius: 7px;
  background: rgba(255, 249, 231, .95);
  color: #624518;
  box-shadow: 0 3px 12px rgba(16, 49, 63, .12);
  font: 600 10.5px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.territorio-real.embed-mode .embed-notice[hidden] {
  display: none;
}

.territorio-real.embed-mode .embed-open-full {
  position: absolute;
  top: 12px;
  right: 56px;
  z-index: 55;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  box-sizing: border-box;
  padding: 7px 11px;
  border: 1px solid rgba(36, 94, 122, .28);
  border-radius: 8px;
  background: rgba(250, 249, 244, .94);
  color: #193d50;
  box-shadow: 0 3px 12px rgba(16, 49, 63, .16);
  font: 700 11px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-decoration: none;
  white-space: nowrap;
}

.territorio-real.embed-mode .embed-open-full:hover,
.territorio-real.embed-mode .embed-open-full:focus-visible {
  background: #fffdf7;
  border-color: rgba(36, 94, 122, .52);
  outline: 0;
}

@media (min-width: 901px) {
  body.territorio-real.embed-mode {
    --rail-w: 64px;
    --right-w: min(360px, 38vw);
  }

  .territorio-real.embed-mode .stage #map { right: 0; }

  .territorio-real.embed-mode .rail {
    background-image: none;
  }

  .territorio-real.embed-mode .rail-btn span { display: none; }
  .territorio-real.embed-mode .rail-primary { margin-bottom: 0; }

  .territorio-real.embed-mode #right-panel {
    pointer-events: none;
    background: transparent;
    border-left: 0;
  }

  .territorio-real.embed-mode #right-panel > .drawer {
    pointer-events: auto;
    background: rgba(247, 248, 241, .96);
    border-left: 1px solid rgba(40, 93, 100, .20);
    box-shadow: -8px 0 24px rgba(16, 49, 63, .12);
  }

  /* Pie desktop: dos líneas discretas, separadas y apoyadas al mapa. */
  .territorio-real #map .leaflet-bottom.leaflet-right {
    bottom: 4px;
    left: 8px;
    right: 8px;
  }

  .territorio-real #map .legal-mini {
    float: right;
    clear: both;
    width: max-content;
    max-width: 100%;
    margin: 0;
    padding: 2px 5px;
    border: 0;
    border-radius: 2px;
    background: rgba(250, 249, 244, .72);
    color: #536b73;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    font-size: 9.5px;
    line-height: 1.2;
    text-align: right;
  }

  .territorio-real #map .leaflet-control-attribution {
    float: right;
    clear: both;
    width: max-content;
    max-width: 100%;
    margin: 2px 0 0 !important;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    color: #3b5961 !important;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    font-size: 8.5px !important;
    line-height: 1.1;
    white-space: nowrap;
  }

  .territorio-real #map .leaflet-control-attribution a {
    color: #245e7a !important;
  }

  /* Autocomplete anclado a la geometría del campo, compacto y legible. */
  .territorio-real .topbar { z-index: 80; }
  .territorio-real .topbar-search { z-index: 1; }
  .territorio-real #addr-results {
    left: 0;
    right: auto;
    width: min(100%, 520px);
    max-width: calc(100vw - 48px);
    max-height: min(280px, calc(100vh - 112px));
    box-sizing: border-box;
    margin-top: 0;
    padding: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    background: rgba(250, 249, 244, .98);
    border: 1px solid rgba(36, 94, 122, .25);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(16, 49, 63, .18);
  }
  .territorio-real #addr-results li {
    min-width: 0;
    box-sizing: border-box;
    padding: 8px 9px;
    overflow: hidden;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .territorio-real #addr-results li.empty { -webkit-line-clamp: 3; }

  .territorio-real .rail {
    background-color: #f8f6ec;
    background-image:
      linear-gradient(180deg, rgba(255, 253, 245, .13) 0%, transparent 38%, rgba(255, 251, 238, .22) 100%),
      url('../art/dunas-izquierda.webp');
    background-position: center, center bottom;
    background-size: cover;
    background-repeat: no-repeat;
    border-right-color: rgba(29, 73, 84, .13);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .territorio-real #right-panel {
    background-color: #a7dfe6;
    background-image: url('../art/mar-derecha.webp');
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
    border-left: 0;
  }

  #right-panel .drawer-head,
  #right-panel .capas-search {
    background: rgba(251, 251, 244, .84);
    border-color: rgba(41, 97, 108, .19);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }

  #right-panel .drawer-body { background: transparent; }
  #right-panel .lp-card,
  #right-panel .cat-cat,
  #right-panel .cat-capa,
  #right-panel .cat-card,
  #right-panel .info-disclaimer,
  #right-panel .mdd-chk,
  #right-panel .info-links a,
  #right-panel #date-range {
    background-color: rgba(255, 253, 247, .95);
    border-color: rgba(40, 93, 100, .20);
  }

  #right-panel .lp-card:hover,
  #right-panel .cat-cat:hover,
  #right-panel .cat-capa:hover,
  #right-panel .cat-card:hover,
  #right-panel .mdd-chk:hover,
  #right-panel .info-links a:hover {
    background-color: rgba(255, 253, 247, .97);
  }

  #right-panel .lp-group,
  #right-panel .drawer-label,
  #right-panel .info-src,
  #right-panel .lp-empty,
  #right-panel .cat-cards-toggle {
    color: #173b4b;
    text-shadow: 0 1px 0 rgba(251, 253, 249, .7);
  }

  #right-panel #capas-q { background: rgba(255, 253, 247, .96); }
  #right-panel .info-src {
    margin: 16px 0 0;
    padding: 10px 12px;
    background: rgba(255, 253, 247, .92);
    border: 1px solid rgba(40, 93, 100, .20);
    border-radius: 8px;
    color: #3b5961;
    line-height: 1.55;
    text-shadow: none;
  }
  #right-panel #list-panel .lp-legal {
    background: rgba(250, 250, 241, .88);
    border-top-color: rgba(41, 97, 108, .19);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }

  .territorio-real .rail-btn:not(.rail-primary) {
    min-height: 50px;
    color: #193d50;
    font-weight: 600;
  }
  .territorio-real .rail-btn:not(.rail-primary):hover,
  .territorio-real .rail-btn:not(.rail-primary).active {
    background: rgba(231, 241, 234, .86);
  }
  .territorio-real .rail-primary {
    min-height: 53px;
    margin-bottom: 16px;
  }
  .territorio-real .rail { gap: 7px; }
}

@media (min-width: 1101px) {
  body.territorio-real {
    --rail-w: 17.5vw;
    --right-w: 36vw;
  }
  .territorio-real .topbar-search { width: min(640px, 50vw); }
}

@media (min-width: 901px) and (max-width: 1050px) {
  .territorio-real .rail-btn:not(.rail-primary),
  .territorio-real .rail-primary { min-height: 43px; margin-bottom: 0; }
  .territorio-real .rail { gap: 3px; }
}

@media (max-width: 900px) {
  body.territorio-real {
    --mobile-nav-height: 64px;
    --mobile-legal-height: 16px;
  }

  .territorio-real.embed-mode .embed-open-full {
    top: 10px;
    right: 54px;
    min-height: 32px;
    padding: 6px 9px;
    font-size: 10px;
  }

  .territorio-real.embed-mode .embed-title {
    top: 10px;
    left: 10px;
    max-width: calc(100% - 176px);
    min-height: 32px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .territorio-real.embed-mode .embed-notice {
    top: 50px;
    left: 10px;
    max-width: calc(100% - 20px);
  }

  .territorio-real .rail-btn { min-height: 44px; }

  .territorio-real .territorio-locality-label {
    font-size: 9.5px;
    line-height: 1.08;
  }

  .territorio-real .localities-list {
    gap: 4px;
    padding-top: 9px;
  }

  .territorio-real .locality-nav-btn {
    min-height: 42px;
    padding: 8px 10px;
  }

  .territorio-real #rb-localities span {
    font-size: 8.5px;
    letter-spacing: -.02em;
  }

  .territorio-real .topbar { z-index: 80; }
  .territorio-real #addr-results {
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    max-height: min(220px, calc(100vh - 92px));
    box-sizing: border-box;
    padding: 3px;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 7px;
  }
  .territorio-real #addr-results li {
    min-width: 0;
    padding: 7px 8px;
    overflow: hidden;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .mobile-credits {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--mobile-nav-height);
    z-index: 45;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    box-sizing: border-box;
    height: var(--mobile-legal-height);
    padding: 0 8px 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #3b5961;
    box-shadow: none;
    pointer-events: none;
  }

  .mobile-credits .leaflet-control-attribution {
    float: none;
    clear: none;
    box-sizing: border-box;
    width: auto;
    max-width: none;
    margin: 0 !important;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    color: inherit !important;
    box-shadow: none;
    font-size: 8px !important;
    line-height: 1;
    white-space: nowrap;
    pointer-events: auto;
  }
  .mobile-credits .leaflet-control-attribution a { color: #245e7a !important; }
  .public-modules-no-rail .mobile-credits { bottom: 0; }

  .territorio-real #map .legal-mini { display: none !important; }

  .territorio-real .drawer {
    bottom: calc(var(--mobile-nav-height) + var(--mobile-legal-height));
    animation: mobile-sheet-in-safe .18s ease-out;
  }

  @keyframes mobile-sheet-in-safe {
    from { transform: translateY(-6px); opacity: 0; }
    to { transform: none; opacity: 1; }
  }

  #list-panel .lp-legal {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    box-sizing: border-box;
    padding: 3px 10px 4px;
    border-top: 1px solid rgba(36, 94, 122, .14);
    background: #faf9f4;
    color: #607077;
    font-size: 8.5px;
    line-height: 1.2;
  }

  #list-panel #lp-list { padding-bottom: 22px; }
}

/* ============================================================
   TUTORIAL DE "MI UBICACIÓN"
   Cartel blanco que señala la mira del buscador (primera visita).
   Azules propios de Territorio: el del mar para la flecha y el aro,
   uno más profundo para el botón. El naranja queda para "Reportar".
   ============================================================ */
.geo-tip {
  --geo-blue: #1f7399;
  --geo-blue-hover: #185f80;
  --geo-sky: #58b0d6;
  position: fixed; z-index: 90; box-sizing: border-box;
  padding: 18px 20px 20px;
  background: #fff; color: #183447;
  border: 1px solid rgba(36, 94, 122, .14); border-radius: 16px;
  box-shadow: 0 16px 40px rgba(25, 57, 79, .22), 0 2px 8px rgba(25, 57, 79, .10);
  font-size: 15px; line-height: 1.45;
  animation: geo-tip-in .18s ease-out;
}
@keyframes geo-tip-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .geo-tip { animation: none; } }

.geo-tip-head { display: flex; align-items: center; gap: 12px; padding-right: 40px; }
.geo-tip-pin { flex: none; width: 30px; height: 30px; }
.geo-tip-pin path { fill: var(--geo-blue); }
.geo-tip-pin circle { fill: #fff; }
.geo-tip h2 { margin: 0; font-size: 21px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; color: #183447; }
.geo-tip p { margin: 10px 0 0; }
.geo-tip .geo-tip-note { margin-top: 6px; color: #607077; }

.geo-tip-close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px;
  display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: #607077; cursor: pointer;
}
.geo-tip-close:hover { background: #eef2f1; color: #183447; }
.geo-tip-close .ic { width: 18px; height: 18px; }

.geo-tip-actions { display: flex; gap: 10px; margin-top: 18px; }
.geo-tip-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border: 0; border-radius: 10px; background: #e6edef; color: #183447;
  font: inherit; font-weight: 700; cursor: pointer;
}
.geo-tip-btn:hover { background: #dae4e7; }
.geo-tip-btn.is-primary { flex: 1 1 auto; background: var(--geo-blue); color: #fff; }
.geo-tip-btn.is-primary:hover { background: var(--geo-blue-hover); }
.geo-tip-btn .ic { width: 18px; height: 18px; flex: none; }
.geo-tip-close:focus-visible, .geo-tip-btn:focus-visible { outline: 3px solid var(--geo-sky); outline-offset: 2px; }

/* La flecha (decorativa) nace en el cartel y termina justo debajo de la mira. */
.geo-tip-arrow {
  position: absolute; width: 86px; height: 74px; pointer-events: none;
  left: calc(var(--geo-tip-x, 300px) - 73px); top: calc(-1 * var(--geo-tip-gap, 46px) - 8px);
  fill: none; stroke: var(--geo-sky); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
}
.geo-tip-caret { display: none; }

/* La mira real, resaltada mientras el cartel está a la vista. */
.territorio-real .topbar-search #btn-geo.geo-tip-target {
  color: #fff; background: rgba(88, 176, 214, .22);
  box-shadow: 0 0 0 2px #58b0d6, 0 0 0 7px rgba(88, 176, 214, .22);
}

/* Celular: cartel compacto debajo de la cabecera; la flecha se reduce a un pico que marca la mira. */
.geo-tip.is-compact { padding: 14px 16px 16px; font-size: 14.5px; }
.geo-tip.is-compact h2 { font-size: 18px; }
.geo-tip.is-compact .geo-tip-pin { width: 26px; height: 26px; }
.geo-tip.is-compact .geo-tip-arrow { display: none; }
.geo-tip.is-compact .geo-tip-caret {
  display: block; position: absolute; top: -8px; left: calc(var(--geo-tip-x, 260px) - 8px);
  width: 16px; height: 16px; background: #fff; transform: rotate(45deg);
  border-left: 1px solid rgba(36, 94, 122, .14); border-top: 1px solid rgba(36, 94, 122, .14);
}
.geo-tip.is-compact .geo-tip-actions { margin-top: 14px; gap: 8px; }
.geo-tip.is-compact .geo-tip-btn { min-height: 44px; padding: 0 12px; }
/* Pantallas muy angostas (≈320 px): sin el ícono, "Usar mi ubicación" entra en un solo renglón. */
@media (max-width: 350px) { .geo-tip.is-compact .geo-tip-btn.is-primary .ic { display: none; } }

/* ---------- pulido: pantallas muy angostas ---------- */

/* Menos de 350 px de ancho (≈320 px): los seis botones de la barra inferior tenían un ancho mínimo de 52 px cada
   uno y sumaban 345 px; «Info» quedaba cortado y toda la página se deslizaba de costado. Sin ese mínimo y con
   menos margen, los seis entran. */
@media (max-width: 350px) {
  .territorio-real .rail { padding-left: 4px; padding-right: 4px; gap: 2px; }
  .territorio-real .rail-btn { min-width: 0; padding-left: 2px; padding-right: 2px; }
}

/* El aviso «Tocá en el mapa el lugar donde pasó» ocupa el ancho de la pantalla y puede usar dos renglones: en un
   solo renglón «Cancelar» quedaba cortado contra el borde. */
@media (max-width: 380px) {
  .territorio-real #place-hint {
    left: 12px; right: 12px; max-width: none; transform: none; animation: none;
    justify-content: space-between; white-space: normal; border-radius: 22px; line-height: 1.25;
  }
}

/* El campo del buscador ocupa todo el alto de su barra: antes sólo respondía al toque una franja de 14 px. */
.territorio-real #addr-search { align-self: stretch; }
