:root {
  --fondo: #f6f4ef;
  --tarjeta: #ffffff;
  --texto: #1d1d1b;
  --suave: #5f5d57;
  --acento: #1f5f8b;
  --acento-suave: #e3eef6;
  --borde: #dedad1;
  --ok: #2e7d4f;
  --error: #b3261e;
  --leyendo: #fff1b8;
  --menu-alto: 76px;
  --letra: 21px;
  color-scheme: light;
}
:root[data-tema="oscuro"] {
  --fondo: #151618;
  --tarjeta: #1f2124;
  --texto: #ecebe7;
  --suave: #a8a6a0;
  --acento: #6db3e6;
  --acento-suave: #22384a;
  --borde: #33363b;
  --ok: #6fcf97;
  --error: #ff8a80;
  --leyendo: #4a3f16;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --fondo: #151618;
    --tarjeta: #1f2124;
    --texto: #ecebe7;
    --suave: #a8a6a0;
    --acento: #6db3e6;
    --acento-suave: #22384a;
    --borde: #33363b;
    --ok: #6fcf97;
    --error: #ff8a80;
    --leyendo: #4a3f16;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  padding-bottom: calc(var(--menu-alto) + env(safe-area-inset-bottom));
}
h1 { font-size: 1.6rem; margin: .6rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
a { color: var(--acento); }
.oculto { position: absolute; left: -9999px; }

.barra {
  position: sticky; top: 0; z-index: 5;
  background: #1f5f8b; color: #fff;
  padding: .5rem 1rem; display: flex; align-items: center; justify-content: space-between;
}
.marca { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.25rem; }
.boton-tema {
  min-width: 48px; min-height: 48px; border: 0; border-radius: 12px;
  background: transparent; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.boton-tema:hover { background: rgba(255,255,255,.12); }

.contenido { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 1.5rem; }

/* Menú inferior: botones grandes al alcance del pulgar */
.menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--tarjeta); border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
}
.menu a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: var(--menu-alto);
  text-decoration: none; color: var(--suave); font-size: .8rem; gap: .1rem;
}
.menu a.activo { color: var(--acento); font-weight: 700; }

/* Formulario de guardar */
.formulario { display: flex; gap: .5rem; }
.formulario input {
  flex: 1; min-width: 0; min-height: 60px; font-size: 1rem; padding: 0 .9rem;
  border: 2px solid var(--borde); border-radius: 14px;
  background: var(--tarjeta); color: var(--texto);
}
.formulario input:focus { border-color: var(--acento); outline: none; }
.formulario button, .boton {
  min-height: 60px; padding: 0 1.3rem; font-size: 1rem; font-weight: 700;
  border: 0; border-radius: 14px; background: var(--acento); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
:root[data-tema="oscuro"] .formulario button, :root[data-tema="oscuro"] .boton { color: #0d2233; }
button:disabled, input:disabled { opacity: .5; cursor: not-allowed; }

.aviso { margin: .6rem 0 0; padding: .7rem 1rem; border-radius: 12px; background: var(--acento-suave); }
.aviso.ok { color: var(--ok); font-weight: 700; }
.aviso.error { color: var(--error); }
#aviso { min-height: .5rem; margin-bottom: .8rem; }

/* Pestañas */
.pestanas { display: flex; gap: .5rem; margin-bottom: 1rem; }
.pestanas button {
  flex: 1; min-height: 56px; font-size: .9rem;
  border: 2px solid var(--borde); border-radius: 12px;
  background: var(--tarjeta); color: var(--texto); cursor: pointer;
}
.pestanas button.activo { border-color: var(--acento); color: var(--acento); font-weight: 700; }

/* Lista */
ul.articulos, ul.temas { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--borde);
  border-radius: 16px; padding: .9rem 1rem;
}
.item { display: flex; gap: .9rem; align-items: center; text-decoration: none; color: var(--texto); min-height: 96px; }
.item:hover { border-color: var(--acento); }
.item strong { display: block; font-size: 1rem; line-height: 1.3; }
.item small { display: block; color: var(--suave); font-size: .78rem; margin-top: .2rem; overflow-wrap: anywhere; }
.item .texto-error { color: var(--error); }
.item.pendiente { opacity: .7; }
.mini {
  width: 76px; height: 76px; flex: none; border-radius: 10px;
  object-fit: cover; background: var(--borde);
}
.item-texto { min-width: 0; }
.fila { display: flex; justify-content: space-between; align-items: center; min-height: 60px; }
.contador {
  min-width: 2.2rem; text-align: center; padding: .1rem .6rem;
  border-radius: 999px; background: var(--fondo); color: var(--suave); font-weight: 700;
}
.vacio { color: var(--suave); text-align: center; padding: 1.5rem 0; }

.bloque { margin-bottom: 1rem; }
.bloque p { margin: .4rem 0; }
.nota { color: var(--suave); font-size: .85rem; }
.marcador { cursor: grab; }
.datos { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; }
.datos dt { color: var(--suave); }
.datos dd { margin: 0; word-break: break-all; }

/* ---------------- Lector ---------------- */
body.en-lector .menu { display: none; }
.herramientas {
  position: sticky; top: 64px; z-index: 4;
  display: flex; gap: .4rem; align-items: center; flex-wrap: wrap;
  background: var(--fondo); padding: .4rem 0 .6rem;
}
.herramientas .espacio { flex: 1; }
.control {
  min-width: 52px; min-height: 52px; padding: 0 .7rem;
  border: 2px solid var(--borde); border-radius: 12px;
  background: var(--tarjeta); color: var(--texto);
  font-size: 1rem; font-weight: 700; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
}
.control.grande { font-size: 1.2rem; }
.control.primario { background: var(--acento); border-color: var(--acento); color: #fff; }
:root[data-tema="oscuro"] .control.primario { color: #0d2233; }

.lectura { font-size: var(--letra); }
.lectura h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55em; line-height: 1.2; margin: .3em 0 .6em;
}
.lectura .meta { font-size: 16px; color: var(--suave); margin: 0; }
.lectura .portada, .lectura img {
  max-width: 100%; height: auto; border-radius: 12px; display: block; margin: 1em auto;
}
#texto { font-family: Georgia, "Times New Roman", serif; line-height: 1.65; }
#texto p, #texto li { margin: 0 0 1em; }
#texto h2, #texto h3, #texto h4 { font-size: 1.15em; line-height: 1.3; margin: 1.4em 0 .5em; }
#texto blockquote { margin: 1em 0; padding-left: 1em; border-left: 4px solid var(--borde); color: var(--suave); }
#texto table { border-collapse: collapse; width: 100%; font-size: .85em; display: block; overflow-x: auto; }
#texto td, #texto th { border: 1px solid var(--borde); padding: .3em .5em; }
#texto pre { overflow-x: auto; font-size: .8em; }
.leyendo { background: var(--leyendo); border-radius: 6px; box-shadow: 0 0 0 6px var(--leyendo); }

.acciones {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center;
  background: var(--tarjeta); border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
}
.accion {
  flex: 1; max-width: 150px; min-height: var(--menu-alto);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  border: 0; background: none; color: var(--texto); font-size: .75rem; font-family: inherit;
  cursor: pointer; text-decoration: none;
}
.accion.encendido { color: var(--ok); font-weight: 700; }
#btn-favorito.encendido { color: #c98a00; }
.accion.peligro { color: var(--error); }

/* ¿Cambió? */
.htmx-indicator { display: none; }
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { display: block; }
.revision { margin: .4rem 0 1rem; }
.revision p { margin: .3rem 0; }
.revision-titulo { font-weight: 700; font-size: 1.05rem; }
.revision-titulo.ok { color: var(--ok); }
.revision-titulo.error { color: var(--error); }
.aviso-cambio { color: #a15c00; }
:root[data-tema="oscuro"] .aviso-cambio { color: #ffb74d; }
.diferencias { list-style: none; padding: 0; margin: .6rem 0; display: grid; gap: .4rem; max-height: 50vh; overflow-y: auto; }
.diferencias li { padding: .5rem .7rem; border-radius: 10px; font-size: .9rem; }
.diferencias li.nuevo { background: rgba(46, 125, 79, .14); }
.diferencias li.quitado { background: rgba(179, 38, 30, .12); text-decoration: line-through; text-decoration-color: rgba(179, 38, 30, .5); }
.marca-dif { font-weight: 700; font-size: .75rem; text-transform: uppercase; margin-right: .3rem; text-decoration: none; display: inline-block; }
.botones-revision { display: flex; gap: .5rem; flex-wrap: wrap; }
.boton.secundario { background: var(--tarjeta); color: var(--texto); border: 2px solid var(--borde); }
:root[data-tema="oscuro"] .boton.secundario { color: var(--texto); }
.enlace-boton { background: none; border: 0; color: var(--acento); font-size: 1rem; text-decoration: underline; cursor: pointer; min-height: 44px; padding: 0; }

/* Ventanita del marcador */
body.ventanita { padding: 2rem 1.5rem; text-align: center; }
.grande-ok { font-size: 1.8rem; font-weight: 700; color: var(--ok); margin: .5rem 0; }
.grande-error { font-size: 1.6rem; font-weight: 700; color: var(--error); margin: .5rem 0; }

/* ---------------- Etapa 3: subir, pegar, tipos de ítem ---------------- */
.subir-fila { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .7rem 0 .3rem; }
.subir-fila .nota { margin: 0; flex: 1; min-width: 14rem; }
.boton.subir { min-height: 52px; gap: .4rem; cursor: pointer; }
kbd { font: inherit; font-size: .8em; padding: .05em .35em; border: 1px solid var(--borde); border-radius: 5px; background: var(--tarjeta); }
@media (pointer: coarse) { .solo-pc { display: none; } }

.soltar {
  display: none; position: fixed; inset: 0; z-index: 20;
  background: rgba(31, 95, 139, .85); color: #fff;
  align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 700;
  border: 6px dashed #fff;
}
body.soltando .soltar { display: flex; }

.icono-tipo {
  display: flex; align-items: center; justify-content: center;
  background: var(--acento-suave); color: var(--acento);
  font-family: Georgia, serif; font-size: 2.6rem; line-height: 1;
}
.icono-tipo.archivo { font-family: inherit; font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.texto-cita { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-style: italic; }

.cita-grande blockquote {
  margin: .5em 0 1em; padding: .4em 0 .4em 1em;
  border-left: 6px solid var(--acento); font-size: 1.15em;
}
.nota-item { font-size: 1rem; color: var(--suave); }
img.recorte { max-width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--borde); display: block; margin: 1rem 0; }
.reproductor { width: 100%; max-height: 70vh; margin: 1rem 0; border-radius: 12px; background: #000; }
audio.reproductor { background: none; }
.vista-titulo { font-size: 1rem; color: var(--suave); margin: 1.5rem 0 .5rem; font-family: system-ui, sans-serif; }
.vista-archivo { font-size: .85em; }
.vista-archivo table { display: block; overflow-x: auto; border-collapse: collapse; font-family: system-ui, sans-serif; }
.vista-archivo td { border: 1px solid var(--borde); padding: .25em .5em; white-space: nowrap; }
.vista-archivo h3 { font-family: system-ui, sans-serif; font-size: 1rem; }

.compartido { text-align: center; padding: 2rem 0; }
.centrados { justify-content: center; margin-top: 1.2rem; }

/* OCR de recortes */
.texto-ocr { font-size: .95em; line-height: 1.55; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: .8em 1em; }
.texto-ocr p { margin: 0 0 .8em; }
.corregir { margin: 1rem 0; }
.corregir summary { cursor: pointer; color: var(--acento); min-height: 44px; display: flex; align-items: center; font-size: 1rem; }
.corregir textarea {
  width: 100%; font: inherit; font-size: 1rem; line-height: 1.5; padding: .7rem;
  border: 2px solid var(--borde); border-radius: 12px; background: var(--tarjeta); color: var(--texto);
  margin: .5rem 0;
}

/* ---------------- Etapa 4: buscar y temas ---------------- */
.buscador { margin-bottom: 1rem; }
.filtros { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.filtros select {
  flex: 1; min-width: 9rem; min-height: 52px; font-size: 1rem; padding: 0 .7rem;
  border: 2px solid var(--borde); border-radius: 12px; background: var(--tarjeta); color: var(--texto);
}
mark { background: var(--leyendo); color: inherit; border-radius: 3px; padding: 0 .1em; }
.item .trozo { display: block; font-size: .85rem; color: var(--texto); margin-top: .35rem; line-height: 1.45; overflow-wrap: anywhere; }
.resultado-cuenta { margin: 0 0 .6rem; }
.ayuda ul { padding-left: 1.2rem; margin: .4rem 0; }
.ayuda li { margin: .4rem 0; }
code { font-size: .9em; padding: .05em .35em; border-radius: 6px; background: var(--fondo); border: 1px solid var(--borde); }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0 0; align-items: center; }
.chip {
  display: inline-flex; align-items: center; padding: .15rem .6rem; border-radius: 999px;
  background: var(--acento-suave); color: var(--acento); font-size: .75rem; font-weight: 700; text-decoration: none;
}
.temas-item { margin: 1.5rem 0 calc(var(--menu-alto) + 1rem); }
.temas-item .chip { font-size: .95rem; padding: .4rem .9rem; min-height: 40px; }
.casillas { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .3rem .8rem; margin: .5rem 0 1rem; }
.casilla { display: flex; align-items: center; gap: .6rem; min-height: 48px; font-size: 1rem; cursor: pointer; }
.casilla input { width: 24px; height: 24px; accent-color: var(--acento); }

ul.temas a.fila { text-decoration: none; color: var(--texto); }
ul.temas a.fila:hover { border-color: var(--acento); }
.volver { color: var(--acento); text-decoration: none; font-size: 1rem; }
.editar-tema { margin-top: 1.5rem; }
.editar-tema summary { cursor: pointer; color: var(--acento); min-height: 44px; display: flex; align-items: center; font-size: 1rem; font-weight: 700; }
.editar-tema label { display: block; margin: .8rem 0 .3rem; font-weight: 700; }
.editar-tema input, .editar-tema textarea {
  width: 100%; font: inherit; font-size: 1rem; padding: .7rem; min-height: 52px;
  border: 2px solid var(--borde); border-radius: 12px; background: var(--tarjeta); color: var(--texto);
}
.editar-tema textarea { line-height: 1.5; font-family: ui-monospace, Consolas, monospace; }
.editar-tema .boton { margin-top: .8rem; }
.boton.peligro { background: var(--tarjeta); color: var(--error); border: 2px solid var(--error); }
:root[data-tema="oscuro"] .boton.peligro { color: var(--error); }
.borrar-tema { margin: 1.2rem 0 0; }

/* Enlace original y videos de YouTube */
.enlace-original { overflow-wrap: anywhere; font-size: 14px !important; }
.enlace-original a { color: var(--acento); }
.video-enlace { position: relative; display: block; }
.video-enlace .play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 84px; height: 60px; border-radius: 16px; background: rgba(204, 0, 0, .9); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
}

/* Importar enlaces */
.caja-texto {
  width: 100%; font: inherit; font-size: .95rem; line-height: 1.45; padding: .7rem; margin: .4rem 0 .6rem;
  border: 2px solid var(--borde); border-radius: 12px; background: var(--tarjeta); color: var(--texto);
}

/* ---------------- Etapa 5: cuentas ---------------- */
.entrada { max-width: 460px; margin: 2rem auto; text-align: center; }
.entrada-icono { display: block; margin: 0 auto 1rem; border-radius: 22px; }
.entrada-icono.candado { color: var(--acento); }
.entrada h1 { margin: .2rem 0; }
.entrada-sub { color: var(--suave); margin: .3rem 0 1.5rem; }
.entrada-form { display: grid; gap: 1rem; justify-items: center; margin-bottom: 1.5rem; }
.boton.google { background: #fff; color: #1f1f1f; border: 2px solid var(--borde); gap: .7rem; min-width: 260px; }
:root[data-tema="oscuro"] .boton.google { color: #1f1f1f; }
.recordar { font-size: .85rem; color: var(--suave); min-height: 40px; }
.grande-boton { min-width: 280px; min-height: 68px; font-size: 1.1rem; }
.salir-chico { margin-top: 2rem; }
.lista-simple { list-style: none; padding: 0; margin: .5rem 0 1rem; display: grid; gap: .3rem; }
.lista-simple li { display: flex; flex-wrap: wrap; gap: .3rem .8rem; justify-content: space-between; align-items: center;
  padding: .5rem 0; border-bottom: 1px solid var(--borde); }
.lista-simple li.apagado { opacity: .55; }
.lista-simple form { margin: 0; }
.acciones-persona { display: flex; gap: .8rem; align-items: center; }
.enlace-respaldo { flex-basis: 100%; }
.fila-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.fila-form select { min-height: 52px; font-size: 1rem; padding: 0 .7rem; border: 2px solid var(--borde);
  border-radius: 12px; background: var(--tarjeta); color: var(--texto); }
.formulario.invitar { flex-wrap: wrap; margin-top: .8rem; }
.formulario.invitar input { min-width: 12rem; }
.centrado { text-align: center; }
.texto-legal h2 { font-size: 1.1rem; margin-top: 1.4rem; }
.texto-legal li { margin: .35rem 0; }
.texto-error { color: var(--error); }
body.sin-menu .contenido { padding-bottom: 2rem; }
