:root {
  --tinta: #2a2522;
  --tinta-2: #6b625c;
  --papel: #fbf8f3;
  --linha: #e7e0d6;
  --tasco: #b8501f;
  --restaurante: #1f5f9e;
  --visitado: #2f8a52;
  --estrela: #e2a50b;
  --perigo: #b42318;
  --raio: 14px;
  --sombra: 0 4px 18px rgba(42, 37, 34, .16);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--tinta);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--papel); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.sub { color: var(--tinta-2); margin: 0; font-size: .92rem; }
small { color: var(--tinta-2); font-weight: 400; }

/* ---------- Botões ---------- */
.btn {
  border: 1px solid var(--linha); background: #fff; border-radius: 999px;
  padding: .55rem 1rem; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: #f3eee7; }
.btn.primario { background: var(--tinta); border-color: var(--tinta); color: #fff; }
.btn.primario:hover { background: #443c37; }
.btn.perigo { color: var(--perigo); border-color: #f0c9c4; }
.btn.ativo-visita { background: var(--visitado); border-color: var(--visitado); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.redondo { width: 42px; height: 42px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; font-weight: 600; }

/* ---------- Login ---------- */
.ecra-login { position: fixed; inset: 0; display: grid; place-items: center; padding: 1rem; background: var(--papel); }
.cartao { width: min(380px, 100%); background: #fff; border-radius: 20px; box-shadow: var(--sombra); padding: 2rem 1.5rem; display: grid; gap: .9rem; text-align: center; }
.cartao img { margin: 0 auto; border-radius: 16px; }
label { display: grid; gap: .3rem; text-align: left; font-weight: 600; font-size: .92rem; }
input, select, textarea { border: 1px solid var(--linha); border-radius: 10px; padding: .6rem .7rem; background: #fff; font-weight: 400; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--restaurante); outline-offset: -1px; }
.erro { color: var(--perigo); min-height: 1.2em; margin: 0; font-size: .9rem; }

/* ---------- Mapa e topo ---------- */
#mapa { position: fixed; inset: 0; z-index: 0; }
.topo { position: fixed; top: 0; left: 0; right: 0; z-index: 500; padding: calc(env(safe-area-inset-top) + .6rem) .6rem 0; pointer-events: none; }
.topo > * { pointer-events: auto; }
.linha { display: flex; gap: .5rem; max-width: 640px; }
#pesquisa { flex: 1; border-radius: 999px; padding: .65rem 1rem; box-shadow: var(--sombra); border: 0; }
#btn-perfil { background: #fff; border: 0; box-shadow: var(--sombra); cursor: pointer; font-size: 1.1rem; }
.filtros { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; overflow-x: auto; scrollbar-width: none; padding-bottom: .4rem; }
.filtros::-webkit-scrollbar { display: none; }
.seg { display: inline-flex; background: #fff; border-radius: 999px; box-shadow: var(--sombra); padding: 3px; flex: none; }
.seg button { border: 0; background: none; padding: .4rem .8rem; border-radius: 999px; cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--tinta-2); white-space: nowrap; }
.seg button.ativo { background: var(--tinta); color: #fff; }
.contagem { flex: none; background: rgba(255,255,255,.92); border-radius: 999px; padding: .35rem .7rem; font-size: .82rem; font-weight: 600; box-shadow: var(--sombra); }

.flutuantes { position: fixed; z-index: 500; left: .6rem; bottom: calc(env(safe-area-inset-bottom) + .8rem); display: flex; gap: .5rem; }
.flutuante { box-shadow: var(--sombra); border: 0; }
.aviso { position: fixed; z-index: 600; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 4.2rem); background: var(--tinta); color: #fff; padding: .6rem 1rem; border-radius: 999px; box-shadow: var(--sombra); font-size: .92rem; white-space: nowrap; }
.leaflet-bottom.leaflet-right { margin-bottom: env(safe-area-inset-bottom); }
.mapa-a-adicionar .leaflet-container { cursor: crosshair; }

/* ---------- Marcadores ---------- */
.pin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); position: relative; transition: transform .12s; }
.pin.tasco { background: var(--tasco); }
.pin.restaurante { background: var(--restaurante); }
.pin.visitado::after { content: "✓"; position: absolute; top: -7px; right: -7px; width: 16px; height: 16px; border-radius: 50%; background: var(--visitado); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid #fff; }
.pin.selecionado { transform: scale(1.3); }
.marker-cluster { background: rgba(42, 37, 34, .25); border-radius: 50%; }
.marker-cluster div { background: var(--tinta); color: #fff; width: 30px; height: 30px; margin: 5px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .82rem; }

/* ---------- Painel (ficha) ---------- */
.painel {
  position: fixed; z-index: 700; background: #fff; box-shadow: var(--sombra); overflow-y: auto; overscroll-behavior: contain;
  left: 0; right: 0; bottom: 0; max-height: 78vh; border-radius: 20px 20px 0 0;
  transform: translateY(105%); transition: transform .22s ease; padding: 0 1.1rem calc(env(safe-area-inset-bottom) + 1.2rem);
}
.painel.aberto { transform: none; }
@media (min-width: 780px) {
  .painel { left: auto; top: .6rem; right: .6rem; bottom: .6rem; width: 410px; max-height: none; border-radius: 20px; transform: translateX(110%); }
  .topo { right: 430px; }
}
.ficha-cab { position: sticky; top: 0; background: #fff; padding: 1rem 0 .6rem; display: flex; gap: .6rem; align-items: flex-start; z-index: 1; }
.ficha-cab h2 { font-size: 1.3rem; flex: 1; }
.fechar { border: 0; background: #f1ece5; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; flex: none; font-size: .95rem; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #fff; padding: .15rem .5rem; border-radius: 6px; margin-bottom: .3rem; }
.badge.tasco { background: var(--tasco); }
.badge.restaurante { background: var(--restaurante); }
.resumo { display: flex; flex-wrap: wrap; gap: .3rem 1rem; color: var(--tinta-2); font-size: .92rem; margin-bottom: .9rem; }
.resumo b { color: var(--tinta); }
.acoes { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .4rem; }
.acoes a.btn { text-decoration: none; color: inherit; }
.notas-local { background: #f7f3ed; padding: .7rem .8rem; border-radius: 10px; font-size: .92rem; white-space: pre-wrap; margin: .6rem 0 0; }
.seccao { border-top: 1px solid var(--linha); margin-top: 1.1rem; padding-top: 1rem; }
.seccao h3 { font-size: 1rem; margin-bottom: .6rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

.estrelas { display: flex; gap: .2rem; align-items: center; flex-wrap: wrap; }
.estrelas button { border: 0; background: none; font-size: 1.75rem; line-height: 1; cursor: pointer; color: #d8d0c4; padding: 0 .05rem; }
.estrelas button.on { color: var(--estrela); }
.estrelas .zero { font-size: .85rem; font-weight: 700; border: 1px solid var(--linha); border-radius: 999px; padding: .3rem .6rem; color: var(--tinta-2); margin-right: .3rem; }
.estrelas .zero.on { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.notas-grupo { list-style: none; padding: 0; margin: .7rem 0 0; font-size: .9rem; color: var(--tinta-2); display: grid; gap: .2rem; }
.mini-estrelas { color: var(--estrela); letter-spacing: 1px; }

.fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.fotos button { border: 0; padding: 0; aspect-ratio: 1; background: #eee center/cover no-repeat; border-radius: 6px; cursor: pointer; }
.carregar { position: relative; overflow: hidden; font-size: .88rem; padding: .4rem .8rem; }
.carregar input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.comentarios { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.comentarios li { font-size: .95rem; }
.comentarios .meta { font-size: .8rem; color: var(--tinta-2); display: flex; gap: .5rem; align-items: center; }
.comentarios p { margin: .2rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.novo-comentario { display: grid; gap: .5rem; margin-top: .9rem; }
.novo-comentario textarea { min-height: 70px; resize: vertical; }
.novo-comentario .btn { justify-self: end; }
.vazio { color: var(--tinta-2); font-size: .9rem; margin: 0; }
.carregando { color: var(--tinta-2); padding: 1rem 0; }
.editar { display: grid; gap: .7rem; }

/* ---------- Diálogos ---------- */
.dlg { border: 0; border-radius: 20px; padding: 0 1.2rem 1.2rem; width: min(440px, calc(100% - 1.5rem)); box-shadow: var(--sombra); max-height: 85vh; }
.dlg::backdrop { background: rgba(30, 26, 23, .45); }
.dlg form { display: grid; gap: .9rem; }
.dlg-cab { display: flex; justify-content: space-between; align-items: center; gap: .6rem; position: sticky; top: 0; background: #fff; padding: 1rem 0 .4rem; }
.botoes { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .3rem; }
.lista { list-style: none; padding: 0; margin: 0; }
.lista li button { width: 100%; text-align: left; border: 0; background: none; padding: .7rem .2rem; border-bottom: 1px solid var(--linha); cursor: pointer; display: flex; gap: .6rem; align-items: center; }
.lista .ponto { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.lista .nome { flex: 1; font-weight: 600; }
.lista .extra { color: var(--tinta-2); font-size: .85rem; white-space: nowrap; }
.dlg-foto { width: min(900px, calc(100% - 1rem)); }
.dlg-foto img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; background: #111; display: block; }

.toast { position: fixed; z-index: 2000; left: 50%; top: calc(env(safe-area-inset-top) + 1rem); transform: translate(-50%, -150%); background: var(--tinta); color: #fff; padding: .65rem 1.1rem; border-radius: 12px; box-shadow: var(--sombra); transition: transform .2s; max-width: calc(100% - 2rem); font-size: .92rem; }
.toast.mostrar { transform: translate(-50%, 0); }
.toast.erro { background: var(--perigo); }
