@font-face {
  font-family: "Inter"; src: url("/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
}
:root {
  --bg: #08090c;
  --panel: rgba(14, 15, 20, 0.82);
  --panel-solid: #111218;
  --line: rgba(255, 255, 255, 0.09);
  --line-hi: rgba(255, 255, 255, 0.18);
  --text: #eeeae4;
  --dim: #9b968e;
  --faint: #67635c;
  --orange: #f7931a;
  --orange-hi: #ffb648;
  --red: #ff5a4e;
  --green: #3ccf6e;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
a { color: var(--orange-hi); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

#globo { position: fixed; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#ciudades { position: fixed; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
body.buy #globo { cursor: crosshair; }
body.dragging #globo { cursor: grabbing; }

/* cabecera */
.top { position: fixed; top: 16px; left: 18px; max-width: min(430px, calc(100vw - 36px)); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.back { display: inline-block; color: var(--dim); text-decoration: none; font-size: 12.5px; letter-spacing: .02em; margin-bottom: 6px; }
.back:hover { color: var(--text); }
.title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
.sub { margin: 6px 0 0; color: var(--dim); font-size: 13.5px; line-height: 1.45; max-width: 360px; }
.howto { margin-top: 10px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px 5px 6px;
  font-size: 12.5px; color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.howto > span:first-child { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(247,147,26,.18);
  color: var(--orange-hi); font-weight: 700; font-size: 11px; }
.howto:hover { border-color: var(--line-hi); }
.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--panel); }
.langs button { border: 0; background: none; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  letter-spacing: .06em; color: var(--dim); cursor: pointer; }
.langs button[aria-pressed="true"] { background: rgba(247,147,26,.16); color: var(--orange-hi); }

/* cifras */
.stats { position: fixed; top: 16px; right: 18px; width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; gap: 9px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stat.wide { flex-wrap: wrap; }
.stat.wide .v { white-space: normal; }
.stat .k { color: var(--dim); font-size: 12px; }
.stat .v { font-family: var(--mono); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { flex-basis: 100%; height: 4px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; min-width: 2px; background: var(--orange); border-radius: 4px; }

/* atribución del mapa */
.osm-attr { position: fixed; left: 8px; bottom: 6px; z-index: 4; padding: 1px 6px; border-radius: 4px; font-size: 10.5px; color: #333; background: rgba(255,255,255,.8); }
.osm-attr a { color: #333; }
/* pestaña lateral de feedback y su panel */
.fb-tab { position: fixed; right: 0; top: 38%; z-index: 6; transform: translateY(-50%) rotate(180deg); writing-mode: vertical-rl; display: flex; align-items: center; gap: 6px;
  padding: 12px 7px; background: var(--orange); color: #171006; border: 0; border-radius: 0 7px 7px 0; font: 650 11.5px/1 var(--font); letter-spacing: .03em; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.45); }
.fb-tab:hover { padding-right: 11px; background: var(--orange-hi); }
.fb-ico { writing-mode: horizontal-tb; transform: rotate(180deg); font-size: 13px; }
.fb { position: fixed; right: 0; top: 50%; z-index: 25; width: 320px; width: min(320px, calc(100vw - 24px)); max-height: 84vh; transform: translateY(-50%) translateX(110%); transition: transform .28s ease-in-out;
  background: var(--panel-solid); border: 1px solid var(--line-hi); border-right: 0; border-radius: 12px 0 0 12px; box-shadow: 0 12px 40px rgba(0,0,0,.55); display: flex; flex-direction: column; overflow: hidden; }
.fb.abierto { transform: translateY(-50%) translateX(0); }
.fb-cab { display: flex; align-items: center; gap: 9px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 18px; }
.fb-tit { font-weight: 650; font-size: 14px; }
.fb-sub { font-size: 11px; color: var(--dim); }
.fb-x { margin-left: auto; background: none; border: 0; color: var(--dim); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 2px; }
.fb-x:hover { color: var(--text); }
.fb form { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px 16px; overflow-y: auto; }
.fb-lab { display: block; font-size: 11px; font-weight: 600; color: var(--dim); margin: 8px 0 3px; }
.fb-lab:first-child { margin-top: 0; }
.fb-opc { font-weight: 400; color: var(--faint); }
.fb-cats { display: flex; gap: 8px; }
.fb-cats button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border: 1px solid var(--line-hi); border-radius: 8px; background: none; color: var(--dim); font-size: 11px; cursor: pointer; }
.fb-cats button i { font-style: normal; }
.fb-cats button span { font-size: 16px; }
.fb-cats button.on { border-color: var(--orange); color: var(--text); background: rgba(247,147,26,.1); }
.fb-fila { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-height: 16px; font-size: 11px; }
.fb-fila p { margin: 0; color: #ffb4ad; }
.fb-fila .mono { margin-left: auto; }
.fb #fb-enviar { margin-top: 12px; width: 100%; }
.fb-ok { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; text-align: center; }
.fb-okico { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgba(60,207,110,.15); color: var(--green); font-size: 22px; }
.fb-ok span { color: var(--dim); font-size: 12.5px; }
.trampa { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.contacto-sel { font-family: var(--mono); font-size: 12px; background: rgba(247,147,26,.07); border: 1px dashed rgba(247,147,26,.4); border-radius: 9px; padding: 8px 10px; margin: 8px 0 12px; line-height: 1.5; }
.contacto label { display: block; font-size: 12px; color: var(--dim); margin: 10px 0 4px; }

/* barra de herramientas */
.toolbar { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center; padding: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); max-width: calc(100vw - 20px); }
.toolbar button { display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent; background: none;
  padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 13.5px; font-weight: 500; white-space: nowrap; color: var(--text); }
.toolbar button:hover { background: rgba(255,255,255,.06); }
.toolbar button[aria-pressed="true"] { background: rgba(247,147,26,.15); color: var(--orange-hi); border-color: rgba(247,147,26,.35); }
.toolbar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.toolbar .capas-btn { display: none; }
.toolbar .seg { display: inline-flex; gap: 2px; padding-right: 6px; border-right: 1px solid var(--line); }
#mine-count { background: var(--orange); color: #111; font-size: 11px; border-radius: 999px; padding: 1px 6px; font-weight: 700; }
.hint { position: fixed; left: 50%; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 62px); transform: translateX(-50%);
  margin: 0; color: #c9c4bb; font-size: 12.5px; text-align: center; width: max-content; max-width: calc(100vw - 32px);
  background: rgba(8,9,12,.78); padding: 5px 12px; border-radius: 999px; pointer-events: none; }

/* selección */
.sel { position: fixed; right: 18px; bottom: 18px; width: 300px; background: var(--panel-solid); border: 1px solid rgba(247,147,26,.35);
  border-radius: var(--r); padding: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.5); display: grid; gap: 8px; }
.sel-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.sel-price { display: flex; align-items: baseline; gap: 10px; }
.sel-price .mono { font-size: 22px; color: var(--orange-hi); font-weight: 600; }
.sel-meta { font-size: 12px; line-height: 1.5; }
.sel-more { width: 100%; margin-top: 8px; }
.sel-warn { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.sel-warn li { font-size: 12px; line-height: 1.4; color: #ffcf9a; background: rgba(247,147,26,.08); border-radius: 8px; padding: 6px 8px; }
.sel-warn li.bad { color: #ffb4ad; background: rgba(255,90,78,.1); }
.sel-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

.primary, .ghost { border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 13.5px; cursor: pointer; border: 1px solid transparent; }
.primary { background: var(--orange); color: #141008; }
.primary:hover { background: var(--orange-hi); }
.primary:disabled { background: #3a3630; color: #8a847a; cursor: not-allowed; }
.ghost { background: none; border-color: var(--line-hi); color: var(--text); }
.ghost:hover { background: rgba(255,255,255,.06); }
.small { padding: 6px 10px; font-size: 12.5px; }

/* tooltip */
.tip { position: fixed; z-index: 5; pointer-events: none; background: rgba(10,10,14,.92); border: 1px solid var(--line-hi);
  border-radius: 9px; padding: 7px 9px; font-size: 12px; line-height: 1.45; white-space: nowrap; transform: translate(14px, 14px); }
.tip b { font-weight: 600; }
.tip .mono { color: var(--dim); font-size: 11px; }

/* carga */
.loading { position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--dim); background: var(--bg); z-index: 20; transition: opacity .4s; }
.loading.done { opacity: 0; pointer-events: none; }
.spin { width: 34px; height: 34px; border: 2px solid rgba(255,255,255,.12); border-top-color: var(--orange); border-radius: 50%; animation: giro 0.9s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }

/* modales */
.modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 30; background: rgba(4,4,8,.66); display: grid; place-items: center; padding: 16px; }
.box { position: relative; width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel-solid);
  border: 1px solid var(--line-hi); border-radius: 16px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.box.wide { width: min(640px, 100%); }
.box h2 { margin: 0 30px 12px 0; font-size: 19px; letter-spacing: -0.015em; }
.box h3 { margin: 18px 0 6px; font-size: 14.5px; }
.box p, .box li { color: #d6d1c9; line-height: 1.55; font-size: 13.5px; }
.box ol { padding-left: 20px; }
.box .fine { color: var(--faint); font-size: 12px; }
.x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 8px; border: 0; background: none;
  font-size: 22px; line-height: 1; color: var(--dim); cursor: pointer; }
.x:hover { background: rgba(255,255,255,.07); color: var(--text); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 12px; width: min(280px, 100%); margin: 6px auto 12px; }
.qr svg, .qr img { width: 100%; height: auto; display: block; }
.invoice { font-family: var(--mono); font-size: 11px; color: var(--dim); word-break: break-all; background: rgba(255,255,255,.04);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 64px; overflow: auto; }
.status { display: flex; align-items: center; gap: 9px; margin: 12px 0 4px; font-size: 13.5px; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); animation: latido 1.4s ease-in-out infinite; }
.status.ok .dot { background: var(--green); animation: none; }
.status.ko .dot { background: var(--faint); animation: none; }
@keyframes latido { 50% { opacity: .3; } }
.keybox { font-family: var(--mono); font-size: 12.5px; background: rgba(247,147,26,.07); border: 1px dashed rgba(247,147,26,.4);
  border-radius: 9px; padding: 10px; word-break: break-all; color: var(--orange-hi); margin: 8px 0; user-select: all; }
.field { width: 100%; background: rgba(255,255,255,.04); border: 1px solid var(--line-hi); border-radius: 9px; color: var(--text);
  padding: 9px 10px; font: inherit; font-size: 13px; }
textarea.field { min-height: 70px; resize: vertical; }
.list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 10px; }
.list .what { display: grid; gap: 2px; font-size: 13px; }
.list .what small { color: var(--dim); font-size: 11.5px; }
.swatch { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line-hi); image-rendering: pixelated; flex: none; background: #fff; }
.tag { font-size: 11px; color: #ffcf9a; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 6px 0 12px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12.5px; }
.note { font-size: 12.5px; color: var(--dim); margin: 6px 0; }
.ok-text { color: var(--green); }
.err-text { color: #ffb4ad; }

/* editor */
.editor { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 40; background: #0b0c10; display: grid; grid-template-rows: auto auto 1fr; }
.ed-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ed-head h2 { margin: 0; font-size: 17px; }
.ed-head p { margin: 0; color: var(--dim); font-size: 12px; flex: 1; }
.ed-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #0e0f14; }
.ed-tools .grp { display: inline-flex; gap: 3px; padding-right: 8px; margin-right: 2px; border-right: 1px solid var(--line); align-items: center; }
.ed-tools button { display: inline-flex; align-items: center; gap: 5px; border: 1px solid transparent; background: none; padding: 6px 8px;
  border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--text); }
.ed-tools button:hover { background: rgba(255,255,255,.06); }
.ed-tools button[aria-pressed="true"] { background: rgba(247,147,26,.15); color: var(--orange-hi); border-color: rgba(247,147,26,.35); }
.ed-tools button:disabled { opacity: .35; cursor: default; }
.ed-tools svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pal { display: inline-grid; grid-template-columns: repeat(12, 18px); gap: 3px; }
.pal button { width: 18px; height: 18px; padding: 0; border-radius: 4px; border: 1px solid rgba(255,255,255,.2); }
.pal button[aria-pressed="true"] { outline: 2px solid var(--orange); outline-offset: 1px; }
.ed-color { width: 34px; height: 30px; border: 1px solid var(--line-hi); border-radius: 7px; background: none; padding: 2px; cursor: pointer; }
.ed-stage { overflow: auto; display: grid; place-items: center; padding: 18px; position: relative; }
.ed-stage canvas { image-rendering: pixelated; touch-action: none; box-shadow: 0 0 0 1px var(--line-hi), 0 20px 60px rgba(0,0,0,.6); cursor: crosshair; }
.ed-stage.hand canvas { cursor: grab; }
.ed-msg { font-size: 12.5px; color: var(--dim); min-width: 120px; text-align: right; }
.ed-save { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }

@media (max-width: 760px) {
  .top { top: 10px; left: 10px; padding: 8px 12px 10px; }
  .hint { display: none; }
  .list li { flex-wrap: wrap; }
  .list li > .row { width: 100%; justify-content: flex-end; }
  h1 { font-size: 20px; }
  .sub { display: none; }
  .howto { margin-top: 6px; padding: 3px 10px 3px 4px; font-size: 12px; }
  .stats { top: auto; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 62px); right: 12px; left: 12px; width: auto;
    grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 9px 12px; }
  .stat.wide { grid-column: 1 / -1; }
  .stat { flex-direction: column; align-items: flex-start; gap: 1px; }
  .stat.wide { flex-direction: row; align-items: baseline; gap: 2px 8px; }
  .stat .v { text-align: left; font-size: 12px; white-space: normal; }
  body.buy .stats, body.sel-open .stats { display: none; }
  .toolbar { bottom: max(10px, env(safe-area-inset-bottom)); gap: 2px; padding: 4px; }
  .toolbar button { padding: 8px 9px; font-size: 12.5px; gap: 5px; }
  .toolbar .opt { display: none; }
  .toolbar .capas-btn { display: inline-flex; }
  .toolbar.capas { flex-wrap: wrap; justify-content: center; width: max-content; max-width: calc(100vw - 16px); }
  .toolbar.capas .opt { display: inline-flex; }
  body.capas-abiertas .stats { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 100px); }
  body.capas-abiertas .sel { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 96px); }
  .osm-attr { top: 112px; left: 12px; bottom: auto; }
  .fb textarea, .fb input, .contacto .field { font-size: 16px; } /* por debajo de 16 px el móvil amplía la página al escribir */
  .sel { left: 12px; right: 12px; width: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 58px); padding: 12px; }
  .ed-head p { display: none; }
  .pal { grid-template-columns: repeat(12, 16px); }
  .pal button { width: 16px; height: 16px; }
}
@media (max-width: 380px) {
  .toolbar button span { font-size: 12px; }
  .toolbar .seg svg { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .spin, .status .dot { animation: none; }
}
@media (max-width: 760px) {
  .ed-tools .grp button span { display: none; }
  .ed-save { margin-left: 0; }
}
