:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ece7dc;
  --ink: #1f2a24;
  --ink-2: #56625a;
  --line: #d9d2c3;
  --brand: #1F3A2E;
  --brand-ink: #ffffff;
  --accent: #E07A2E;
  --river: #2E7D7A;
  --gold: #E0A23A;
  --top: #1F3A2E;
  --top-ink: #F4F1EA;
  --hook: #6f777e;
  --good: #3f7d4e;
  --bad: #b2463a;
  --chip: #e6efe9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 40, 30, .08), 0 4px 14px rgba(30, 40, 30, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121714; --surface: #1a211d; --surface-2: #232c27; --ink: #e9eee9; --ink-2: #a3b0a7;
    --line: #2f3a33; --brand: #6fb3a0; --brand-ink: #0f1712; --accent: #ef9a5c; --hook: #aab2b8;
    --river: #5fb3ad; --gold: #E0A23A; --top: #16291f;
    --good: #7fc28f; --bad: #e57c6f; --chip: #24332b; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121714; --surface: #1a211d; --surface-2: #232c27; --ink: #e9eee9; --ink-2: #a3b0a7;
  --line: #2f3a33; --brand: #6fb3a0; --brand-ink: #0f1712; --accent: #ef9a5c; --hook: #aab2b8;
  --river: #5fb3ad; --gold: #E0A23A; --top: #16291f;
  --good: #7fc28f; --bad: #e57c6f; --chip: #24332b; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--brand); }

.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--top); color: var(--top-ink);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.top h1 { font-size: 19px; margin: 0; letter-spacing: .2px; font-weight: 700; }
.top h1 span { font-weight: 400; color: var(--gold); }

/* Logo: la mosca guru mira de lado a lado y parpadea; al tocarla se sorprende. */
.logo { flex: none; width: 42px; height: 42px; padding: 0; border: 0; background: none; border-radius: 50%; }
.logo svg { display: block; width: 100%; height: 100%; }
.logo .ojo { transform-box: fill-box; transform-origin: center; animation: parpadeo 7s infinite; }
.logo .pupila { animation: mirada 7s infinite ease-in-out; }
.logo.sorpresa .ojo { animation: sorpresa .9s ease-out; }
.logo.sorpresa .pupila { animation: giro .9s ease-in-out; }
@keyframes parpadeo { 0%, 21%, 24%, 84%, 86.5%, 89%, 91.5%, 100% { transform: scaleY(1); } 22.5%, 85.5%, 90% { transform: scaleY(.1); } }
@keyframes mirada {
  0%, 28% { transform: translate(-1.3px, 0); }
  34%, 50% { transform: translate(1.4px, -.3px); }
  56%, 76% { transform: translate(0, 1.1px); }
  82%, 100% { transform: translate(-1.3px, 0); }
}
@keyframes sorpresa { 0% { transform: scale(1); } 25%, 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes giro {
  0% { transform: translate(-1.3px, 0); } 25% { transform: translate(0, -1.4px); } 50% { transform: translate(1.4px, 0); }
  75% { transform: translate(0, 1.4px); } 100% { transform: translate(-1.3px, 0); }
}
@media (prefers-reduced-motion: reduce) { .logo .ojo, .logo .pupila { animation: none; } }
.top .sub { font-size: 12px; opacity: .8; }
.top .offline { margin-left: auto; font-size: 11px; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }

main { max-width: 860px; margin: 0 auto; padding: 14px 16px 24px; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 9px; font-size: 11.5px; color: var(--ink-2); text-decoration: none;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--brand); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-2); margin: 12px 0 6px; font-weight: 600; }
.label:first-child { margin-top: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 7px 12px; font-size: 14px; line-height: 1.2; user-select: none;
}
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.chip small { display: block; font-size: 11px; opacity: .75; }
.scroller { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px 2px; overscroll-behavior-x: contain; }
.scroller::-webkit-scrollbar { display: none; }
.scroller .chip { flex: none; }

select.sel { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
input.search { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }

.narr { border-left: 3px solid var(--accent); padding: 2px 0 2px 10px; margin: 0; }
.warn { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 10px; }

.mix { display: flex; height: 14px; border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.mix span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin-top: 10px; }
.kv b { color: var(--ink-2); font-weight: 600; }

.list { display: grid; gap: 10px; }
.fly {
  display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; text-decoration: none; color: inherit; box-shadow: var(--shadow); position: relative;
}
.fly:active { transform: scale(.99); }
.art { background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 70%, #bcd 10%), var(--surface-2)); border-radius: 10px; }
.fly .art { width: 112px; height: 64px; }
.fly h3 { margin: 0; font-size: 16px; }
.fly .meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; color: #fff; vertical-align: 2px; }
.why { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.why span { font-size: 11.5px; background: var(--chip); border-radius: 6px; padding: 2px 6px; }
.rank { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 5px; }
.inbox { color: var(--good); font-weight: 600; font-size: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.tile .art { height: 86px; }
.tile .art svg { width: 100%; height: 100%; }
.tile h3 { font-size: 14px; margin: 6px 2px 2px; }
.tile .meta { font-size: 12px; color: var(--ink-2); margin: 0 2px; }
.fly .art svg { width: 100%; height: 100%; }

.hero { padding: 0; overflow: hidden; }
.hero .art { border-radius: 0; aspect-ratio: 2 / 1; }
.hero .art svg { width: 100%; height: 100%; }
.hero .body { padding: 14px; }
.hero h2 { font-size: 22px; margin: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-size: 14px; margin-bottom: 10px; }

.real { display: flex; align-items: flex-end; justify-content: center; min-height: 90px; padding: 14px; background: repeating-linear-gradient(90deg, transparent 0 calc(var(--mm) * 5 - 1px), var(--line) calc(var(--mm) * 5 - 1px) calc(var(--mm) * 5)); border-radius: 10px; border: 1px dashed var(--line); }
.compare { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 10px 0 0; }
.compare figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.compare figcaption { font-size: 11.5px; color: var(--ink-2); }
.compare figure.on figcaption { color: var(--accent); font-weight: 700; }
.compare figure.off { opacity: .45; }

.cal { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin-top: 6px; }
.cal div { text-align: center; font-size: 10.5px; padding: 6px 0; border-radius: 5px; background: var(--surface-2); color: var(--ink-2); }
.cal .b { background: color-mix(in srgb, var(--brand) 35%, var(--surface)); color: var(--ink); }
.cal .p { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.cal .now { outline: 2px solid var(--accent); outline-offset: 1px; }
.bars { display: grid; gap: 6px; margin-top: 6px; }
.bar { display: grid; grid-template-columns: 1fr 90px; gap: 8px; align-items: center; font-size: 13.5px; }
.bar .t { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar .t span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: 12.5px; padding: 3px 9px; border-radius: 99px; background: var(--chip); }
.tag.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.block { width: 100%; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.qty button { width: 42px; height: 42px; border: 0; background: var(--surface-2); font-size: 20px; }
.qty span { min-width: 44px; text-align: center; font-weight: 700; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; }

.calib { height: 54px; background: linear-gradient(135deg, #3a6b8c, #22465e); border-radius: 6px; margin: 10px 0; color: #fff; font-size: 12px; display: flex; align-items: flex-end; padding: 6px 8px; }
input[type=range] { width: 100%; accent-color: var(--brand); }
.cons { display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.fuentes { font-size: 12px; line-height: 1.4; color: var(--ink-2); padding: 4px 4px 8px; }
.fuentes ol { margin: 8px 0; padding-left: 18px; }
.fuentes li { margin-bottom: 5px; }
.fuentes p { margin: 6px 0 0; }
.consbar { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink); }
.consbar .t { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.consbar .t span { display: block; height: 100%; background: var(--accent); }
.rio { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.rio > div { flex: 1; min-width: 0; }
.rio h3 { margin: 0; font-size: 16px; }
.rio .meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.rio .chev { font-size: 22px; color: var(--ink-2); }
.why .hot { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg a { text-align: center; padding: 9px 6px; border-radius: 9px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 14.5px; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.form label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; }
.form input, .form select, .form textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; font-weight: 400; color: var(--ink); }
.form textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bar2 { grid-template-columns: 1fr 90px 24px; }
.bar2 b { text-align: right; font-size: 13px; }
.mapa-wrap { position: relative; }
.mapa { height: calc(100vh - 290px); height: calc(100dvh - 290px); min-height: 320px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); z-index: 0; }
.mapa.mini { height: 190px; min-height: 0; border: 0; border-radius: 0; cursor: pointer; }
.mapa-yo { position: absolute; right: 10px; bottom: 26px; z-index: 500; width: 46px; height: 46px; padding: 0; border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,.25); font-size: 20px; }
.leaflet-popup-content { font: 13.5px/1.4 system-ui, sans-serif; }
.leaflet-popup-content a { font-weight: 600; }
.gps { background: var(--surface-2); border-radius: 10px; padding: 9px 12px; margin: -2px 0 12px; font-size: 13.5px; }
.gps-row { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.lnk { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; font-size: inherit; text-decoration: underline; }
.coment { font-size: 13px; color: var(--ink-2); font-style: italic; margin-top: 6px; }
.instalar {
  position: fixed; left: 12px; right: 12px; z-index: 30;
  bottom: calc(70px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; padding: 12px 40px 12px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 28px rgba(0,0,0,.2);
  max-width: 560px; margin: 0 auto;
}
.instalar img { border-radius: 11px; flex: none; }
.instalar .txt { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.35; }
.instalar .txt b:first-child { display: block; font-size: 15px; margin-bottom: 1px; }
.instalar .btn { padding: 9px 14px; flex: none; }
.instx { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border: 0; background: none; color: var(--ink-2); font-size: 15px; border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) { .instalar { animation: subir .25s ease-out; } @keyframes subir { from { transform: translateY(20px); opacity: 0; } } }
.empty { text-align: center; padding: 30px 10px; color: var(--ink-2); }

@media (min-width: 720px) {
  .fly { grid-template-columns: 150px 1fr; }
  .fly .art { width: 150px; height: 80px; }
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  .fly, .tile, .chip { transition: transform .12s ease, background-color .15s ease; }
}
