:root {
  --bg: #F2F5F4;
  --surface: #FFFFFF;
  --surface-2: #E6ECEA;
  --ink: #16272B;
  --ink-2: #4A5C61;
  --muted: #7A8B8F;
  --line: #CFD9D6;
  --accent: #0E6E7A;
  --accent-ink: #FFFFFF;
  --accent-soft: #D7ECEE;
  --warn: #B8552B;
  --warn-soft: #F5E3DA;
  --ok: #2F7D4F;
  --ok-soft: #DCEEE2;
  --danger: #A83232;
  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1A1E; --surface: #16252A; --surface-2: #1E3037; --ink: #E4ECEA; --ink-2: #B3C2C3;
    --muted: #7F9297; --line: #2C3F46; --accent: #5FC3CE; --accent-ink: #0F1A1E; --accent-soft: #163B41;
    --warn: #E5926A; --warn-soft: #3A251B; --ok: #7CC59A; --ok-soft: #1C3527; --danger: #E07A7A;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(70px + var(--safe-b));
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.15; text-wrap: balance; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.barra {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.6rem + env(safe-area-inset-top, 0px)) 1rem .6rem;
  background: var(--accent); color: var(--accent-ink);
}
.marca { display: flex; align-items: center; gap: .5rem; font-weight: 700; letter-spacing: .02em; font-size: 1.05rem; }
.marca-pez { width: 22px; height: 14px; background: currentColor; border-radius: 50% 40% 40% 50% / 50% 50% 50% 50%; position: relative; }
.marca-pez::after { content: ""; position: absolute; right: -8px; top: 0; border-left: 9px solid currentColor; border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.barra-estado { font-size: .85rem; opacity: .9; }

.vista { max-width: 720px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs a { display: grid; justify-items: center; gap: 2px; padding: .5rem 0 .4rem; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; }
.tabs a .ico { font-size: 1.25rem; line-height: 1; }
.tabs a.activa { color: var(--accent); }

.tarjeta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.tarjeta.destacada { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.fila { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }
.apilado { display: grid; gap: .75rem; }
.silencio { color: var(--muted); font-size: .9rem; }
.mini { font-size: .8rem; }

.campo { display: grid; gap: .3rem; }
.campo label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.campo input, .campo select, .campo textarea {
  width: 100%; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
}
.campo input[type="number"] { font-variant-numeric: tabular-nums; }
.campos-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; }
.check input { width: 1.2rem; height: 1.2rem; margin-top: .15rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .7rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600;
}
.btn.primario { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.peligro { color: var(--danger); }
.btn.grande { width: 100%; padding: .9rem 1rem; font-size: 1.05rem; }
.btn.chico { padding: .4rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }

.pill { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: .2em .55em; border-radius: 4px; white-space: nowrap; }
.pill.si { background: var(--warn-soft); color: var(--warn); }
.pill.posible { background: var(--accent-soft); color: var(--accent); }
.pill.no { background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.mal { background: var(--warn-soft); color: var(--danger); }

.captura { display: grid; grid-template-columns: 72px 1fr auto; gap: .75rem; align-items: center; padding: .6rem 0; border-top: 1px solid var(--line); }
.captura:first-of-type { border-top: 0; }
.captura img, .captura .sinfoto { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.captura .sinfoto { display: grid; place-items: center; color: var(--muted); font-size: 1.5rem; }
.captura .nombre { font-weight: 700; }
.captura .datos { font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.hoja {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto;
  padding: calc(1rem + env(safe-area-inset-top, 0px)) 1rem calc(2rem + var(--safe-b));
}
.hoja .contenido { max-width: 720px; margin: 0 auto; display: grid; gap: 1rem; }
.hoja-cabecera { display: flex; align-items: center; justify-content: space-between; }

.lienzo-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; touch-action: none; }
.lienzo-wrap canvas { display: block; width: 100%; height: auto; }
.pasos-medida { display: grid; gap: .4rem; font-size: .9rem; }
.pasos-medida li.hecho { color: var(--ok); }
.pasos-medida li.actual { font-weight: 700; color: var(--accent); }

.candidatos { display: grid; gap: .5rem; }
.candidato { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: left; }
.candidato.elegido { border-color: var(--accent); background: var(--accent-soft); }
.candidato .conf { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: .85rem; }
.barra-conf { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; width: 90px; }
.barra-conf > div { height: 100%; background: var(--accent); }

.regla { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: .7rem .9rem; border-radius: 0 8px 8px 0; font-size: .92rem; }
.regla.si { border-color: var(--warn); background: var(--warn-soft); }
.regla.no { border-color: var(--line); background: var(--surface-2); }

pre.texto-declaracion { white-space: pre-wrap; background: var(--surface-2); padding: .8rem; border-radius: 8px; font-size: .85rem; line-height: 1.4; font-family: ui-monospace, Menlo, monospace; margin: 0; }
.cuenta-atras { font-variant-numeric: tabular-nums; font-weight: 700; }
.cuenta-atras.urgente { color: var(--danger); }

.aviso { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); z-index: 30; background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 8px; font-size: .9rem; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }

.lista-especies { display: grid; gap: .4rem; }
.especie-item { display: grid; grid-template-columns: 1fr auto; gap: .5rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.especie-item .ci { font-style: italic; color: var(--muted); font-size: .85rem; }

.vacio { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.auth { max-width: 420px; margin: 1rem auto; }
.tabs-auth { display: flex; gap: .5rem; margin-bottom: 1rem; }
.tabs-auth button { flex: 1; }

.regla .pill { white-space: normal; display: inline; line-height: 1.6; }
.hoja, .vista { overflow-x: hidden; }

/* Guía visual de especies */
.rejilla-especies { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: max-content; align-content: start; gap: .5rem; max-height: 52vh; overflow-y: auto; padding: 2px; }
.esp-card { display: grid; gap: .25rem; padding: 0 0 .4rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: center; overflow: hidden; }
.esp-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--surface-2); }
.esp-card .esp-nombre { font-weight: 700; font-size: .82rem; line-height: 1.15; padding: 0 .3rem; }
.esp-card .pill { justify-self: center; font-size: .62rem; }
.esp-card.elegida { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.especie-item { grid-template-columns: 84px 1fr auto; }
.especie-item img { width: 84px; height: 63px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.credito { color: var(--muted); font-size: .7rem; }
.credito a { color: inherit; }
