:root {
  --azul: #1f4e79;
  --azul-claro: #e8f0f8;
  --verde: #2e7d32;
  --rojo: #c62828;
  --texto: #1a1a1a;
  --texto-suave: #5a5a5a;
  --fondo: #f6f7f9;
  --tarjeta: #ffffff;
  --borde: #d6dbe1;
  --radio: 16px;
}

* { box-sizing: border-box; }

html { font-size: 20px; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  line-height: 1.4;
  padding-bottom: 120px;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; cursor: pointer; }

.cabecera {
  background: var(--azul);
  color: #fff;
  padding: calc(20px + env(safe-area-inset-top)) 20px 18px;
}
.cabecera h1 { margin: 0; font-size: 1.5rem; }
.fecha { margin: 4px 0 0; opacity: .9; font-size: .9rem; }
.fecha::first-letter { text-transform: uppercase; }

/* Pestañas */
.pestanas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px;
  background: var(--tarjeta);
  border-bottom: 1px solid var(--borde);
  position: sticky;
  top: 0;
  z-index: 2;
}
.pestana {
  padding: 14px 8px;
  border: 2px solid var(--borde);
  background: var(--tarjeta);
  border-radius: 12px;
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  color: var(--texto-suave);
}
.pestana.activa {
  border-color: var(--azul);
  background: var(--azul-claro);
  color: var(--azul);
}
.contador:not(:empty) {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--azul);
  color: #fff;
  font-size: .8rem;
}

main { padding: 16px; max-width: 700px; margin: 0 auto; }

/* Listas */
.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 16px;
}
.item .contenido {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
}
.item .contenido > div { flex: 1; min-width: 0; }
.flecha { font-size: 1.8rem; color: var(--texto-suave); flex: none; }
.item .texto-item {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1.05rem;
}
.item .cuando { margin: 6px 0 0; font-size: .75rem; color: var(--texto-suave); }

.check {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--azul);
  background: #fff;
  font-size: 1.6rem;
  color: #fff;
  display: grid;
  place-items: center;
}
.check.marcado { background: var(--verde); border-color: var(--verde); }

.item.hecha .texto-item { color: var(--texto-suave); }

.item .cuando.hecha-en { color: var(--verde); font-weight: 600; }

.vacio { text-align: center; color: var(--texto-suave); padding: 32px 0; font-size: 1.05rem; }

.hechas { margin-top: 24px; }
.hechas summary {
  padding: 14px 4px;
  font-weight: 600;
  color: var(--texto-suave);
  font-size: 1rem;
}
.hechas .lista { margin-bottom: 16px; }

/* Botón grande de añadir */
.boton-nuevo {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 668px;
  margin: 0 auto;
  padding: 20px;
  border: 0;
  border-radius: 999px;
  background: var(--azul);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(31, 78, 121, .35);
}
.boton-nuevo:active { transform: scale(.98); }

/* Ventanas */
.editor {
  width: min(94vw, 600px);
  border: 0;
  border-radius: 20px;
  padding: 24px 20px;
  color: var(--texto);
}
.editor::backdrop { background: rgba(0, 0, 0, .45); }
.editor h2 { margin: 0 0 14px; font-size: 1.3rem; }
.editor textarea {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  padding: 14px;
  border: 2px solid var(--borde);
  border-radius: 12px;
  resize: vertical;
}
.editor textarea:focus { outline: none; border-color: var(--azul); }

/* Ficha */
.ficha { max-height: 92vh; overflow-y: auto; }
.ficha-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.estado {
  padding: 6px 14px;
  border-radius: 99px;
  font-size: .8rem;
  font-weight: 700;
  background: var(--azul-claro);
  color: var(--azul);
}
.estado.hecha { background: #e3f2e4; color: var(--verde); }
.boton-cerrar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--borde);
  background: var(--fondo);
  font-size: 1.2rem;
}
.ficha-texto { margin: 0; font-size: 1.15rem; white-space: pre-wrap; word-break: break-word; }
.ficha-fechas { margin: 10px 0 0; font-size: .85rem; color: var(--texto-suave); white-space: pre-line; }
.ficha h3 { margin: 20px 0 10px; font-size: 1rem; }

.fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fotos:empty { display: none; }
.fotos button {
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--fondo);
}
.fotos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sin-fotos { margin: 0; color: var(--texto-suave); font-size: .9rem; }

.botones-foto { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.boton-grande {
  width: 100%;
  padding: 16px 10px;
  border-radius: 12px;
  border: 2px solid var(--azul);
  background: var(--azul);
  color: #fff;
  font-weight: 700;
  margin-top: 12px;
}
.botones-foto .boton-grande { margin-top: 0; }
.boton-grande.claro { background: var(--azul-claro); color: var(--azul); }
.boton-grande.verde { background: var(--verde); border-color: var(--verde); margin-top: 20px; }
.boton-grande.whatsapp { background: #25d366; border-color: #25d366; color: #0b3d1f; }
.boton-grande.deshacer { background: #fff; border-color: var(--borde); color: var(--texto); }

/* Visor de foto */
.visor {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 16px;
  border: 0;
  background: #000;
}
.visor[open] { display: flex; flex-direction: column; justify-content: center; }
.visor img { width: 100%; max-height: calc(100vh - 120px); object-fit: contain; }
.visor .acciones { padding-bottom: env(safe-area-inset-bottom); }

.boton-dictar {
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  border-radius: 12px;
  border: 2px dashed var(--azul);
  background: var(--azul-claro);
  color: var(--azul);
  font-weight: 600;
}
.boton-dictar.escuchando {
  border-style: solid;
  background: var(--rojo);
  border-color: var(--rojo);
  color: #fff;
}

.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }

.boton-principal, .boton-secundario, .boton-peligro {
  padding: 16px;
  border-radius: 12px;
  font-weight: 700;
  border: 2px solid transparent;
}
.boton-principal { background: var(--azul); color: #fff; }
.boton-peligro { background: var(--rojo); color: #fff; }
.boton-secundario { background: #fff; border-color: var(--borde); color: var(--texto); }
.hechas .boton-secundario { width: 100%; }

.texto-confirmar {
  background: var(--fondo);
  padding: 12px;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 30vh;
  overflow: auto;
}

/* Aviso inferior */
.aviso {
  position: fixed;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--texto);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  display: flex;
  gap: 14px;
  align-items: center;
  white-space: nowrap;
}
.aviso.visible { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.aviso button {
  background: none;
  border: 0;
  color: #9fd0ff;
  font-weight: 700;
  padding: 4px;
}
