:root {
  --sign: #153e30;
  --sign-ink: #235c45;
  --ink: #172b23;
  --muted: #4f6057;
  --line: #d9e3dc;
  --surface: #fff;
  --surface-subtle: #f4f8f5;
  --map-bg: #dce7e3;
  --focus: #185ac4;
  --notice: #fff5d9;
  --notice-border: #d1b568;
  --radius: 6px;
  --space: 16px;
  --c0: #9aa3ad;
  --c1: #f4c20d;
  --c2: #e63946;
  --c3: #7b2cbf;
  --c4: #111;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 16px/1.45 system-ui, sans-serif; color: var(--ink); background: var(--surface); }
button, input { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
a { color: var(--sign-ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip { position: absolute; left: 8px; top: -60px; z-index: 1200; background: var(--surface); padding: 10px 14px; }
.skip:focus { top: 8px; }
.top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: env(safe-area-inset-top, 0px) max(var(--space), env(safe-area-inset-right)) 0 max(var(--space), env(safe-area-inset-left));
  background: var(--sign);
  color: var(--surface);
}
.top :focus-visible { outline-color: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; color: inherit; text-decoration: none; }
.logo { width: 34px; height: 34px; border-radius: var(--radius); flex: none; }
.brand-text { font-size: 17px; font-weight: 680; line-height: 1.2; }
.brand-text small { display: block; margin-top: 2px; color: #dbe8e0; font-size: 12px; font-weight: 450; }
.nav { display: flex; align-items: center; flex: none; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--surface); font-size: 14px; text-underline-offset: 4px; }

/* The list and map each own their scroll and focus area. */
body.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.layout { display: grid; grid-template-columns: clamp(285px, 29vw, 386px) minmax(0, 1fr); flex: 1; min-height: 0; }
.panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-inline-end: 1px solid var(--line); }
.panel-head { flex: none; padding: 20px var(--space) 0; }
.panel-head h2 { margin: 0; font-size: 28px; line-height: 1.16; }
.sub { margin: 6px 0 20px; font-size: 14px; color: var(--muted); }
.panel-head label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 670; }
#buscarTramo {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #879b8f;
  border-radius: var(--radius);
  background: var(--surface);
}
#buscarTramo::placeholder { color: var(--muted); opacity: 1; }
.list-status { margin: 12px 0 10px; min-height: 1.45em; font-size: 13px; color: var(--muted); }
.panel-body { flex: 1; min-height: 0; padding: 0 var(--space) var(--space); overflow: auto; }
.ranking, .quietos ul { list-style: none; margin: 0; padding: 0; }
.ranking li, .quietos li { border-block-start: 1px solid var(--line); }
.rk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 11px 4px;
  text-align: start;
  background: none;
  border: 0;
}
.rk:hover, .rk:active { background: var(--surface-subtle); }
.rk:focus-visible { outline-offset: -3px; }
.nm b { display: block; font-size: 14px; line-height: 1.3; font-weight: 690; }
.nm small { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); }
.nivel { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.nivel .swatch { width: 9px; height: 9px; border-radius: 50%; }
.quietos { margin-top: 6px; border-block-start: 1px solid var(--line); }
.quietos summary { min-height: 44px; padding: 11px 4px; font-size: 14px; font-weight: 650; }
.quietos summary:hover { background: var(--surface-subtle); }
.quietos .rk { grid-template-columns: minmax(0, 1fr); }
.view-switch { display: none; }

.mapwrap { position: relative; min-height: 0; min-width: 0; background: var(--map-bg); }
#map { position: absolute; inset: 0; z-index: 0; background: var(--map-bg); }
#map:focus-visible { outline-offset: -3px; }
.leaflet-tile-pane { filter: saturate(.82); }
.leaflet-container .leaflet-control-zoom a { width: 44px; height: 44px; line-height: 44px; }
.leaflet-container .leaflet-control-attribution { background: #fffffff2; font-size: 11px; }
/* Aviso discreto en la esquina, junto a la atribución de Leaflet. Sin banner. */
.aviso-mapa { color: #222; font-weight: 600; }
.aviso-mapa a { color: inherit; text-decoration: none; }
.aviso-mapa a:hover, .aviso-mapa a:focus-visible { text-decoration: underline; }
.map-tools { position: absolute; top: 12px; right: max(12px, env(safe-area-inset-right)); z-index: 2; display: flex; align-items: flex-start; gap: 8px; }
.map-tools > button, .legend summary {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #879b8f;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  font-weight: 650;
}
.map-tools > button:hover, .legend summary:hover, .legend[open] summary { background: var(--surface-subtle); }
.legend-body {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(296px, calc(100vw - 24px));
  max-height: min(26rem, calc(100dvh - 205px));
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 3px 12px #18352822;
  font-size: 13px;
}
.legend-note { margin: 0 0 10px; }
.levels, .sym { list-style: none; margin: 0; padding: 0; }
.levels li, .sym li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.levels li span { margin-inline-start: auto; color: var(--muted); }
.swatch, .lvl { display: inline-block; flex: none; width: 14px; height: 12px; border: 1px solid #0004; border-radius: 2px; vertical-align: -2px; }
.swatch-gris { background: var(--c0); }
.swatch-amarillo { background: var(--c1); }
.swatch-rojo { background: var(--c2); }
.swatch-morado { background: var(--c3); }
.swatch-negro { background: var(--c4); }
.sym { margin-top: 10px; border-block-start: 1px solid var(--line); padding-top: 8px; }
.sym svg { flex: none; color: var(--sign-ink); }
.symbol-line { flex: none; width: 18px; border-block-start: 2px solid var(--c0); }
.symbol-area { flex: none; width: 18px; height: 18px; border: 2px dotted var(--muted); border-radius: 50%; }
.chk { display: flex; min-height: 44px; align-items: center; gap: 8px; margin-top: 8px; border-block-start: 1px solid var(--line); cursor: pointer; }
.chk input { width: 18px; height: 18px; margin: 0; accent-color: var(--sign-ink); }
.map-notice, .load-error, .noscript-aviso {
  border: 1px solid var(--notice-border);
  border-radius: var(--radius);
  background: var(--notice);
  color: var(--ink);
  font-size: 14px;
}
.map-notice, .load-error { position: absolute; inset-inline: 12px; max-width: 28rem; margin: 0; padding: 9px 12px; }
.map-notice { bottom: 32px; z-index: 1; }
.load-error { top: 12px; z-index: 2; }
.noscript-aviso { margin: 8px var(--space); padding: 8px 12px; }

.foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 20px;
  padding: 6px max(var(--space), env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(var(--space), env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
}
.freshness { color: #795009; }

.leaflet-container .leaflet-popup-content { margin: 13px 16px; font: 14px/1.45 system-ui, sans-serif; color: var(--ink); }
.leaflet-container .leaflet-popup-close-button { width: 34px; height: 34px; line-height: 34px; }
.leaflet-popup-content .pp h2 { margin: 0 16px 6px 0; font-size: 16px; line-height: 1.28; }
.pp .popup-meta, .pp .note { font-size: 13px; color: var(--muted); }
.pp .popup-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pp dl { margin: 10px 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }
.pp dt { color: var(--muted); }
.pp dd { margin: 0; }
.pp .btn { display: flex; align-items: center; min-height: 44px; border-top: 1px solid var(--line); color: var(--sign-ink); font-weight: 670; }
.pp ul.inc { list-style: none; margin: 8px 0; padding: 0; }
.pp blockquote { margin: 10px 0; padding: 7px 10px; border-inline-start: 3px solid #c5cbd6; border-radius: 4px; background: var(--surface-subtle); color: var(--ink); font-size: 13px; max-height: 132px; overflow: auto; }
.pp blockquote:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.inc-link {
  min-height: 40px;
  width: 100%;
  padding: 5px 0;
  border: 0;
  border-top: 1px solid var(--line);
  text-align: start;
  color: var(--sign-ink);
  background: transparent;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.inc-link:hover { background: var(--surface-subtle); }
.inc-link:focus-visible { outline-offset: -3px; }
.pin { background: none; border: none; }

.doc-main { max-width: 760px; margin: 0 auto; padding: 24px var(--space) 56px; line-height: 1.6; }
.doc-main h1 { margin: 0; color: var(--sign); font-size: 32px; line-height: 1.2; }
.doc-main h2 { margin: 28px 0 8px; color: var(--sign); font-size: 21px; }
.doc-main p { margin: 8px 0 14px; }
.doc-main table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; }
.doc-main th, .doc-main td { border: 1px solid var(--line); padding: 6px; text-align: start; }
.doc-main th, .formula, .callout { background: var(--surface-subtle); }
.formula { padding: 12px 16px; border-inline-start: 3px solid var(--sign-ink); font-size: 18px; font-weight: 650; }
.callout { padding: 10px 14px; border-inline-start: 3px solid var(--sign-ink); }
.callout ul { margin: 0; padding-inline-start: 18px; }
.doc-main li + li { margin-top: 6px; }
.refs { overflow-wrap: anywhere; }
.upd { color: var(--muted); font-size: 14px; }

@media (max-width: 760px) {
  .top { min-height: 54px; gap: 8px; }
  .logo { width: 30px; height: 30px; }
  .brand-text { font-size: 15px; }
  .nav a { font-size: 13px; }
  .view-switch { display: flex; flex: none; padding: 0 var(--space); border-bottom: 1px solid var(--line); }
  .view-switch button {
    flex: 1;
    min-height: 46px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: var(--surface);
    font-weight: 650;
  }
  .view-switch button[aria-pressed="true"] { border-bottom-color: var(--sign-ink); color: var(--sign-ink); background: var(--surface-subtle); }
  .view-switch button:focus-visible { outline-offset: -3px; }
  .layout { display: flex; }
  .panel, .mapwrap { flex: 1; }
  .layout[data-vista="mapa"] .panel, .layout[data-vista="tramos"] .mapwrap { display: none; }
  .panel { overflow: auto; border: 0; }
  .panel-head { padding-top: 14px; }
  .panel-head h2 { font-size: 23px; }
  .sub { margin-bottom: 12px; }
  .panel-body { flex: 0 0 auto; overflow: visible; }
  .foot .src { flex-basis: 100%; }
  .leaflet-container .leaflet-popup-content { max-width: calc(100vw - 72px); }
  /* Atribución y aviso a la derecha, en dos líneas, sin tapar los botones del mapa. */
  .leaflet-container .leaflet-control-attribution { font-size: 12px; line-height: 1.35; white-space: normal; max-width: min(250px, calc(100vw - 24px)); text-align: right; }
  .doc-main h1 { font-size: 27px; }
  .doc-main table { font-size: 12px; }
  .doc-main th, .doc-main td { padding: 4px 3px; }
}

@media (max-height: 520px) {
  .leaflet-container .leaflet-popup-content { max-height: max(62px, calc(100dvh - 282px)); overflow: auto; }
}
