/* ============================================================
   DESIGN TOKENS — Mapeats
   Marca: verde-floresta (#1F4A2E) + lima (#C6F24E) sobre neutros sálvia.
   Tudo que é cor, raio, sombra ou movimento sai daqui; os
   componentes abaixo só consomem variáveis.
============================================================ */
:root {
  /* Marca (fixos nos dois temas) */
  --forest-900: #14211A;
  --forest-700: #1F4A2E;
  --forest-500: #2F6B43;
  --sage-200: #DCE5D3;
  --sage-100: #ECF0E7;
  --lime-400: #C6F24E;

  /* Tipografia */
  --f-body: "Geist", system-ui, -apple-system, sans-serif;
  --f-mono: "Geist Mono", ui-monospace, monospace;
  --f-serif: "Instrument Serif", Georgia, serif;

  /* Escala de espaçamento (4px) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;

  /* Raios */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* Movimento */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 0.15s;
  --t-med: 0.28s;

  /* Layout */
  --side-w: 360px;
  --side-w-collapsed: 68px;
}

/* ---------- Tema claro (padrão) ---------- */
:root,
:root[data-theme="light"] {
  --bg: #F4F6F1;
  --panel: #FFFFFF;
  --surface: #F4F6F1;
  --surface-2: #EAEEE5;
  --ink: #14211A;
  --muted: #5B6960;
  --subtle: #8D988F;
  --line: rgba(20, 33, 26, 0.08);
  --line-strong: rgba(20, 33, 26, 0.16);

  --brand: var(--forest-700);
  --brand-ink: #FFFFFF;
  --brand-soft: rgba(31, 74, 46, 0.09);
  --accent: var(--lime-400);
  --focus: rgba(31, 74, 46, 0.22);

  --shadow-sm: 0 1px 2px rgba(20, 33, 26, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 33, 26, 0.08), 0 1px 2px rgba(20, 33, 26, 0.06);
  --shadow-lg: 0 16px 40px rgba(20, 33, 26, 0.14);

  --map-bg: #EEF0EB;

  --rest: #D9583A;
  --bar: #3F6FD6;
  --comi: #C98A10;
  --bom: #7A5FD6;
  --cafe: #0E8A86;
  --michelin: #C8102E;
  --michelin-soft: rgba(200, 16, 46, 0.07);

  color-scheme: light;
}

/* ---------- Tema escuro ---------- */
:root[data-theme="dark"] {
  --bg: #0C110E;
  --panel: #111814;
  --surface: #17201B;
  --surface-2: #1D2822;
  --ink: #E8EEE7;
  --muted: #95A298;
  --subtle: #64716A;
  --line: rgba(232, 238, 231, 0.07);
  --line-strong: rgba(232, 238, 231, 0.14);

  --brand: var(--lime-400);
  --brand-ink: var(--forest-900);
  --brand-soft: rgba(198, 242, 78, 0.1);
  --accent: var(--lime-400);
  --focus: rgba(198, 242, 78, 0.22);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);

  --map-bg: #0E1311;

  --rest: #F0765A;
  --bar: #6F95F2;
  --comi: #EBB23B;
  --bom: #A58DF2;
  --cafe: #3FC7C1;
  --michelin: #FF6B7A;
  --michelin-soft: rgba(255, 107, 122, 0.1);

  color-scheme: dark;
}

/* ============================================================
   BASE
============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  transition: grid-template-columns var(--t-med) var(--ease);
}

:root[data-sidebar="collapsed"] .app {
  grid-template-columns: var(--side-w-collapsed) 1fr;
}

/* ============================================================
   BOTÃO DE ÍCONE (base compartilhada)
============================================================ */
.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* ============================================================
   BARRA LATERAL
============================================================ */
aside {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  z-index: 10;
  overflow: hidden;
}

/* Marca */
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-4) var(--s-3);
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: var(--forest-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-mark path {
  fill: var(--lime-400);
}

.brand-mark circle {
  fill: var(--forest-700);
}

.brand-name {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-name em {
  font-family: var(--f-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.12em;
  letter-spacing: 0;
}

.btn-collapse .chev {
  transition: transform var(--t-med) var(--ease);
  transform-origin: 14px 12px;
}

/* Atalhos do menu recolhido (ocultos com o menu aberto) */
.rail {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-2) 0;
}

.rail-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rest);
  border: 1.5px solid var(--panel);
}

.rail-count {
  margin-top: var(--s-2);
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 1px 7px;
}

/* Cabeçalho: busca + filtros */
.head {
  padding: var(--s-1) var(--s-4) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.filters-collapsible {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.filter-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--subtle);
}

.btn-reset {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}

.btn-reset:hover {
  color: var(--ink);
  background: var(--surface-2);
}

/* Chips (categorias e fontes usam o mesmo componente) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--r-pill);
  padding: 4px 10px 4px 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease, opacity var(--t-fast) ease;
  user-select: none;
}

.chip:hover {
  background: var(--surface);
}

.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
  flex-shrink: 0;
}

.chip .count {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--subtle);
}

.chip .m-link {
  color: var(--subtle);
  display: inline-flex;
  padding: 1px;
  margin-right: -3px;
  border-radius: 4px;
}

.chip .m-link:hover {
  color: var(--ink);
}

.chip[aria-pressed="false"] {
  opacity: 0.45;
  border-style: dashed;
  background: transparent;
}

.chip[aria-pressed="false"] .dot {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--c);
}

/* Fonte em destaque (Guia Michelin) */
.chip.featured {
  flex-basis: 100%;
  justify-content: flex-start;
  padding: 7px 12px;
  border-color: color-mix(in srgb, var(--michelin) 35%, transparent);
  background: var(--michelin-soft);
  color: var(--michelin);
  font-weight: 600;
}

.chip.featured:hover {
  background: color-mix(in srgb, var(--michelin) 12%, transparent);
}

.chip.featured .count {
  margin-left: auto;
  color: var(--michelin);
  opacity: 0.8;
}

.chip.featured .m-link {
  color: var(--michelin);
}

.chip.featured[aria-pressed="false"] {
  opacity: 0.5;
  background: transparent;
}

/* Busca */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--subtle);
  pointer-events: none;
}

input[type="search"] {
  font-family: var(--f-body);
  font-size: 13.5px;
  width: 100%;
  padding: 10px 36px 10px 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, background var(--t-fast) ease;
}

input[type="search"]::placeholder {
  color: var(--subtle);
}

input[type="search"]:focus {
  border-color: var(--brand);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--focus);
}

.search-wrap:focus-within .search-icon {
  color: var(--ink);
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--subtle);
  cursor: pointer;
  padding: 4px;
  display: flex;
  border-radius: 50%;
}

.search-clear svg {
  width: 16px;
  height: 16px;
}

.search-clear:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.results-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: calc(var(--s-1) * -1);
}

/* ============================================================
   LISTA DE CASAS
============================================================ */
.list-container {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: var(--s-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.item {
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
  gap: var(--s-3);
  padding: 10px var(--s-3);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  width: 100%;
  color: inherit;
  border-radius: var(--r-md);
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease;
}

.item::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--c);
  flex-shrink: 0;
}

.item:hover {
  background: var(--surface);
}

.item.active {
  background: var(--brand-soft);
  border-color: var(--line-strong);
}

.item-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.item-award-tag {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-award-tag .pos {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  margin-right: 2px;
}

.item-award-tag.first .pos,
.item-award-tag.star .pos {
  color: var(--comi);
}

.item-award-tag.michelin .pos,
.award .pos.michelin {
  color: var(--michelin);
}

.item-location {
  font-size: 12px;
  color: var(--subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.item-materias {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.item-materia-tag {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 0 5px;
  border-radius: 4px;
}

.item-materia-tag.featured,
.popup-materia-badge.featured {
  color: var(--michelin) !important;
  background: var(--michelin-soft);
  border-color: color-mix(in srgb, var(--michelin) 25%, transparent);
}

.empty-state {
  padding: 40px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  color: var(--muted);
}

.empty-state svg {
  width: 34px;
  height: 34px;
  color: var(--subtle);
}

.empty-state p {
  margin: 0;
  font-size: 13.5px;
}

.btn-clear-action {
  font-size: 13px;
  font-weight: 500;
  background: var(--brand);
  color: var(--brand-ink);
  border: 0;
  border-radius: var(--r-md);
  padding: 7px 14px;
  cursor: pointer;
}

/* ============================================================
   RODAPÉ DA BARRA: SELETOR DE TEMA
============================================================ */
.side-foot {
  flex-shrink: 0;
  padding: var(--s-3) var(--s-4) var(--s-4);
  border-top: 1px solid var(--line);
}

.theme-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}

.theme-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}

.theme-opt svg {
  width: 15px;
  height: 15px;
}

.theme-opt:hover {
  color: var(--ink);
}

:root[data-theme="light"] .theme-opt[data-theme-set="light"],
:root[data-theme="dark"] .theme-opt[data-theme-set="dark"] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   MENU RECOLHIDO
============================================================ */
:root[data-sidebar="collapsed"] .brand-row {
  flex-direction: column;
  padding: var(--s-4) 0 var(--s-2);
  gap: var(--s-3);
}

:root[data-sidebar="collapsed"] .brand-name,
:root[data-sidebar="collapsed"] .head,
:root[data-sidebar="collapsed"] .list-container,
:root[data-sidebar="collapsed"] .theme-opt span {
  display: none;
}

:root[data-sidebar="collapsed"] .btn-collapse .chev {
  transform: scaleX(-1);
}

:root[data-sidebar="collapsed"] .rail {
  display: flex;
  flex: 1;
}

:root[data-sidebar="collapsed"] .side-foot {
  padding: var(--s-3) 0 var(--s-4);
  display: flex;
  justify-content: center;
}

:root[data-sidebar="collapsed"] .theme-switch {
  flex-direction: column;
}

:root[data-sidebar="collapsed"] .theme-opt {
  padding: 7px;
}

/* ============================================================
   MAPA
============================================================ */
#mapwrap {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--map-bg);
}

#map {
  height: 100%;
  width: 100%;
  background: var(--map-bg);
}

.leaflet-container {
  font-family: var(--f-body);
}

/* Controles flutuantes (direita, embaixo) */
.map-controls {
  position: absolute;
  right: var(--s-4);
  bottom: 34px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.map-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-md);
  transition: background var(--t-fast) ease, color var(--t-fast) ease;
}

.map-btn.icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
}

.map-btn svg {
  width: 18px;
  height: 18px;
}

.map-btn:hover {
  background: var(--surface);
}

.zoom-group {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.zoom-group .map-btn {
  border-radius: 0;
  box-shadow: none;
}

.zoom-group .map-btn + .map-btn {
  border-top: 0;
}

.btn-locate.locating .locate-icon {
  animation: pulseLocate 1s ease-in-out infinite;
}

.btn-locate.located {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: transparent;
}

@keyframes pulseLocate {
  50% { opacity: 0.3; }
}

/* Marca e tema flutuantes: só no celular */
.map-brand-mobile,
.map-theme-mobile {
  display: none;
}

/* Pinos */
.pin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid var(--panel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s var(--ease);
  cursor: pointer;
}

.pin:hover,
.pin.active {
  transform: scale(1.5);
}

.pin.approx {
  background: var(--panel);
  border: 2px solid var(--c);
}

.user-location-pin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3B82F6;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.22), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Popup */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-lg) !important;
  padding: 0 !important;
  overflow: hidden;
  background: var(--panel) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: 300px !important;
  font-size: 13px;
  line-height: 1.45;
}

.leaflet-popup-tip {
  background: var(--panel) !important;
  box-shadow: none !important;
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--subtle) !important;
  top: 10px !important;
  right: 10px !important;
  width: 24px !important;
  height: 24px !important;
  line-height: 22px !important;
  border-radius: 50%;
  font-size: 18px !important;
  text-align: center;
}

.leaflet-container a.leaflet-popup-close-button:hover {
  color: var(--ink) !important;
  background: var(--surface-2);
}

.card .body {
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  padding: var(--s-4) var(--s-4) 0;
}

.card .tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
}

.card h2 {
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.015em;
  margin: -4px 0 0;
  line-height: 1.2;
  color: var(--ink);
  padding-right: 22px;
}

.award {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.award .award-row {
  font-size: 12.5px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.award .pos {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  min-width: 18px;
}

.award .pos.star {
  color: var(--comi);
}

.addr {
  font-size: 12.5px;
  color: var(--muted) !important;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  text-decoration: none;
}

.addr:hover span {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Horário de funcionamento (recolhível) */
.hours {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: -4px;
}

.hours summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
}

.hours summary::-webkit-details-marker {
  display: none;
}

.hours-status {
  color: var(--muted);
}

.hours-status.open {
  color: var(--bom);
  font-weight: 500;
}

:root[data-theme="light"] .hours-status.open,
:root:not([data-theme]) .hours-status.open {
  color: var(--forest-500);
}

:root[data-theme="dark"] .hours-status.open {
  color: var(--lime-400);
}

.hours-chev {
  transition: transform var(--t-fast) ease;
}

.hours[open] .hours-chev {
  transform: rotate(180deg);
}

.hours-list {
  margin: 6px 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hours-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.hours-row span:last-child {
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink);
  text-align: right;
}

.note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 !important;
}

.warn {
  font-size: 11.5px;
  color: var(--comi);
}

.popup-materias {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.popup-materia-badge {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--muted) !important;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.popup-materia-badge:hover {
  color: var(--ink) !important;
  border-color: var(--line-strong);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 2px;
}

.links a {
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink) !important;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background var(--t-fast) ease;
}

.links a:hover {
  background: var(--surface-2);
}

.links a.pri {
  background: var(--brand);
  border-color: transparent;
  color: var(--brand-ink) !important;
}

.links a.pri:hover {
  filter: brightness(1.08);
}

/* Atribuição discreta */
.leaflet-container .leaflet-control-attribution {
  background: transparent !important;
  color: var(--subtle) !important;
  font-size: 10px !important;
  padding: 2px 8px !important;
}

.leaflet-container .leaflet-control-attribution a {
  color: var(--muted) !important;
}

/* ============================================================
   CONTROLES MOBILE (OCULTOS NO DESKTOP)
============================================================ */
.mobile-bar {
  display: none;
}

/* ============================================================
   PRIVACIDADE: aviso, links e página de termos
============================================================ */
.side-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.legal-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

.legal-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Rodapé no fim da lista: créditos e link de privacidade (visível no celular) */
.list-foot {
  padding: var(--s-4) var(--s-3) var(--s-2);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--subtle);
  text-align: center;
}

.list-foot a {
  color: var(--muted);
}

.privacy-notice {
  position: absolute;
  left: var(--s-4);
  bottom: var(--s-4);
  z-index: 1001;
  width: min(440px, calc(100% - 96px));
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  line-height: 1.45;
}

.privacy-notice[hidden] {
  display: none;
}

.privacy-notice p {
  margin: 0;
  flex: 1;
}

.privacy-notice a {
  color: var(--brand);
  font-weight: 500;
}

.privacy-notice button {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
}

body.legal {
  overflow: auto;
  height: auto;
}

.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 64px;
  font-size: 15px;
  line-height: 1.65;
}

.legal-back {
  margin-bottom: var(--s-6);
}

.legal-page h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 var(--s-1);
}

.legal-page h2 {
  font-size: 17px;
  margin: 32px 0 var(--s-2);
}

.legal-page p,
.legal-page ul {
  margin: 0 0 var(--s-3);
}

.legal-page ul {
  padding-left: 20px;
}

.legal-page li + li {
  margin-top: var(--s-1);
}

.legal-page a {
  color: var(--brand);
}

.legal-page code {
  font-family: var(--f-mono);
  font-size: 13px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: var(--r-sm);
}

.legal-updated {
  color: var(--muted);
  font-size: 13px;
}

.legal-lead {
  font-size: 16px;
  color: var(--ink);
  padding: var(--s-4);
  background: var(--brand-soft);
  border-radius: var(--r-lg);
}

.legal-foot {
  margin-top: 40px;
}

/* ============================================================
   RESPONSIVIDADE (MOBILE / TABLET)
============================================================ */
@media (max-width: 820px) {
  /* No celular o mapa ocupa a tela inteira e a lista vira um painel
     que desliza por cima dele. Alturas do painel: --sheet-peek (só a alça),
     metade da tela e quase a tela toda. */
  :root {
    --sheet-peek: calc(72px + env(safe-area-inset-bottom, 0px));
    --sheet-h: 50dvh;
  }

  .app[data-mobile-view="map"] { --sheet-h: var(--sheet-peek); }
  .app[data-mobile-view="split"] { --sheet-h: 50dvh; }
  .app[data-mobile-view="list"] { --sheet-h: calc(100dvh - 64px); }

  .app,
  :root[data-sidebar="collapsed"] .app {
    display: block;
    position: relative;
    height: 100vh;
    height: 100dvh;
  }

  #mapwrap {
    position: absolute;
    inset: 0;
  }

  aside {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--sheet-h);
    z-index: 1000;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.14);
    transition: height var(--t-med) var(--ease);
  }

  /* Durante o arrasto a altura segue o dedo, sem animação */
  .app.sheet-dragging aside,
  .app.sheet-dragging .map-controls,
  .app.sheet-dragging .map-theme-mobile,
  .app.sheet-dragging .leaflet-bottom {
    transition: none;
  }

  /* Com o painel baixo, mostra só a alça e as abas */
  .app[data-mobile-view="map"] .head,
  .app[data-mobile-view="map"] .list-container {
    visibility: hidden;
  }

  /* Créditos do mapa ficam acima do painel */
  #mapwrap .leaflet-bottom {
    bottom: var(--sheet-h);
    transition: bottom var(--t-med) var(--ease);
  }

  /* No celular o menu nunca fica recolhido */
  .brand-row,
  .rail,
  .side-foot,
  :root[data-sidebar="collapsed"] .rail,
  :root[data-sidebar="collapsed"] .side-foot {
    display: none;
  }

  :root[data-sidebar="collapsed"] .head,
  :root[data-sidebar="collapsed"] .list-container {
    display: flex;
  }

  .map-brand-mobile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    top: max(10px, env(safe-area-inset-top, 10px));
    left: 10px;
    z-index: 999;
    padding: 5px 12px 5px 5px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-md);
    color: var(--ink);
  }

  .map-brand-mobile .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 50%;
  }

  .map-brand-mobile .brand-mark svg {
    width: 16px;
    height: 16px;
  }

  .map-brand-mobile .brand-name {
    font-size: 16px;
  }

  .map-theme-mobile {
    display: inline-flex;
    position: absolute;
    left: 10px;
    bottom: calc(var(--sheet-h) + 14px);
    z-index: 999;
    transition: bottom var(--t-med) var(--ease);
  }

  :root[data-theme="light"] .map-theme-mobile .i-sun,
  :root[data-theme="dark"] .map-theme-mobile .i-moon {
    display: none;
  }

  .map-controls {
    right: 10px;
    bottom: calc(var(--sheet-h) + 14px);
    transition: bottom var(--t-med) var(--ease);
  }

  .zoom-group {
    display: none;
  }

  .mobile-bar {
    display: flex;
    flex-direction: column;
    padding: 6px 14px 8px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    gap: 6px;
  }

  .mobile-handle-area {
    display: flex;
    justify-content: center;
    padding: 4px 0 2px;
    cursor: grab;
  }

  /* A barra superior do painel recebe o arrasto, não a rolagem da página */
  .mobile-bar {
    touch-action: none;
  }

  .mobile-pill {
    width: 38px;
    height: 4px;
    border-radius: var(--r-pill);
    background: var(--line-strong);
  }

  .mobile-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .mobile-view-tabs {
    display: inline-flex;
    background: var(--surface);
    padding: 3px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
  }

  .m-tab {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 7px;
    cursor: pointer;
  }

  .m-tab.active {
    background: var(--panel);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
  }

  .btn-toggle-filters {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    color: var(--ink);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 11px;
    border-radius: var(--r-md);
    cursor: pointer;
  }

  .btn-toggle-filters[aria-expanded="false"] .chevron-icon {
    transform: rotate(180deg);
  }

  .btn-toggle-filters.has-active-filter {
    border-color: var(--brand);
    background: var(--brand-soft);
  }

  .head {
    padding: 10px 14px 8px;
    gap: 10px;
  }

  .filters-collapsible.collapsed {
    display: none;
  }

  /* Evita auto-zoom do iOS Safari ao focar no campo de busca */
  input[type="search"] {
    font-size: 16px;
    padding: 9px 36px;
  }

  .list {
    padding: 6px 8px calc(14px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }

  .leaflet-popup-content {
    width: min(280px, calc(100vw - 44px)) !important;
  }

  .privacy-notice {
    top: calc(max(10px, env(safe-area-inset-top, 10px)) + 50px);
    bottom: auto;
    left: 16px;
    width: calc(100% - 32px);
  }
}
