/* Audiolibros — sala de lectura: verde biblioteca, bronce de lámpara, papel salvia. De noche, verde casi negro. */
:root {
  --papel: #E8ECE3;
  --superficie: #F5F7F1;
  --tinta: #16211C;
  --tinta-suave: #4C5B53;
  --verde: #24493A;
  --verde-suave: #D5DFD5;
  --bronce: #A8741F;
  --bronce-texto: #7A5311;
  --sobre-bronce: #16211C;
  --sello: #A9372B;
  --linea: #C9D2C5;
  --sombra: 0 1px 2px rgba(22, 33, 28, .12), 0 6px 18px rgba(22, 33, 28, .08);
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --alto-pestanas: 62px;
  --alto-mini: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --papel: #0E1813;
    --superficie: #16231C;
    --tinta: #E3E9E1;
    --tinta-suave: #A2B1A8;
    --verde: #8EC0A6;
    --verde-suave: #1F3229;
    --bronce: #D8A54A;
    --bronce-texto: #E3B866;
    --sobre-bronce: #0E1813;
    --sello: #E37A69;
    --linea: #2A3B32;
    --sombra: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-tema="oscuro"] {
  --papel: #0E1813;
  --superficie: #16231C;
  --tinta: #E3E9E1;
  --tinta-suave: #A2B1A8;
  --verde: #8EC0A6;
  --verde-suave: #1F3229;
  --bronce: #D8A54A;
  --bronce-texto: #E3B866;
  --sobre-bronce: #0E1813;
  --sello: #E37A69;
  --linea: #2A3B32;
  --sombra: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font: 17px/1.5 var(--sans);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--alto-pestanas) + env(safe-area-inset-bottom) + 24px);
}
body.con-mini { padding-bottom: calc(var(--alto-pestanas) + var(--alto-mini) + env(safe-area-inset-bottom) + 24px); }
body.rep-abierto { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--verde); }
:focus-visible { outline: 3px solid var(--bronce); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 0;
}

/* ---------- Encabezado ---------- */
.cabeza {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 22px;
}
.marca { font: 600 18px/1 var(--serif); color: var(--verde); letter-spacing: .01em; text-decoration: none; }
.cuenta {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--verde-suave); color: var(--verde);
  font: 700 16px/1 var(--sans); text-decoration: none;
}
h1 { font: 600 30px/1.15 var(--serif); margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font: 600 21px/1.25 var(--serif); margin: 34px 0 12px; }
h3 { font: 600 17px/1.3 var(--serif); margin: 0; }
.bajada { color: var(--tinta-suave); margin: 0 0 18px; }
.suave { color: var(--tinta-suave); }
.chico { font-size: 14px; }

/* ---------- Botones ---------- */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border: 0; border-radius: 23px;
  background: var(--verde); color: var(--papel);
  font-weight: 700; text-decoration: none;
}
.boton.bronce { background: var(--bronce); color: var(--sobre-bronce); }
.boton.secundario { background: transparent; color: var(--verde); box-shadow: inset 0 0 0 1.5px var(--verde); }
.boton.peligro { background: transparent; color: var(--sello); box-shadow: inset 0 0 0 1.5px var(--sello); }
.boton:disabled { opacity: .45; cursor: default; }
.boton-texto { border: 0; background: none; color: var(--verde); font-weight: 700; padding: 8px 4px; }
.boton-icono { border: 0; background: none; width: 44px; height: 44px; display: grid; place-items: center; color: var(--tinta); border-radius: 50%; }
.fila-botones { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Tapas ---------- */
.tapa {
  position: relative; display: block; aspect-ratio: 2 / 3; width: 100%;
  border-radius: 3px 7px 7px 3px;
  overflow: hidden; background: var(--verde);
  box-shadow: var(--sombra);
}
.tapa img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tapa::after { /* lomo */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 6px;
  background: linear-gradient(90deg, rgba(0,0,0,.22), rgba(0,0,0,0));
}
.tapa-texto {
  position: absolute; inset: 0; padding: 14% 12% 12% 16%;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #F3EFE4;
}
.tapa-texto b { font: 600 1em/1.15 var(--serif); overflow-wrap: anywhere; }
.tapa-texto i { font: italic 400 .72em/1.2 var(--serif); opacity: .85; }
.tapa .sello {
  position: absolute; right: 6%; bottom: 9%;
  transform: rotate(-9deg);
  padding: 2px 8px;
  border: 2px solid var(--sello); border-radius: 4px;
  background: color-mix(in srgb, var(--superficie) 88%, transparent);
  color: var(--sello);
  font: 700 12px/1.4 var(--sans); letter-spacing: .04em;
}

.barra { height: 4px; border-radius: 2px; background: var(--linea); overflow: hidden; }
.barra > span { display: block; height: 100%; background: var(--bronce); border-radius: 2px; }

/* ---------- Mi biblioteca ---------- */
.destacado {
  display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: start;
  padding: 18px; border-radius: 16px;
  background: var(--superficie); box-shadow: var(--sombra);
}
.destacado .tapa { font-size: 15px; }
.destacado h1 { font-size: 25px; margin-bottom: 2px; }
.destacado .donde { margin: 10px 0 6px; font-size: 15px; color: var(--tinta-suave); }
.destacado .fila-botones { margin-top: 16px; }
@media (max-width: 420px) {
  .destacado { grid-template-columns: 92px 1fr; gap: 14px; padding: 14px; }
  .destacado h1 { font-size: 21px; }
  .destacado .fila-botones { grid-column: 1 / -1; }
  .destacado .fila-botones .boton { flex: 1 1 100%; }
}

.lista { list-style: none; margin: 0; padding: 0; }
.fila {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--linea);
}
.fila:last-child { border-bottom: 0; }
.fila .tapa { font-size: 8px; }
.fila a.titulo { color: var(--tinta); text-decoration: none; font: 600 17px/1.3 var(--serif); display: block; }
.fila .meta { font-size: 14px; color: var(--tinta-suave); margin-top: 2px; }
.fila .barra { margin-top: 8px; }

.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 18px 14px; }
.ficha { text-decoration: none; color: var(--tinta); display: block; }
.ficha .tapa { font-size: 13px; }
.ficha .nombre { font: 600 15px/1.25 var(--serif); margin-top: 8px; display: block; }
.ficha .autor { font-size: 13px; color: var(--tinta-suave); display: block; }

.vacio {
  padding: 26px 20px; border-radius: 16px; text-align: center;
  border: 1.5px dashed var(--linea);
}
.vacio p { margin: 0 0 16px; }

/* ---------- Biblioteca Mayor ---------- */
.buscar {
  width: 100%; height: 46px; padding: 0 16px;
  border: 1.5px solid var(--linea); border-radius: 23px;
  background: var(--superficie);
}
.estante-cabeza { margin: 30px 0 12px; }
.estante-cabeza h2 { margin: 0; }
.estante-cabeza > span { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 2px; }
.estante-cabeza .boton-texto { padding: 4px 0; }
.estante {
  display: grid; grid-auto-flow: column; grid-auto-columns: 112px; gap: 16px;
  overflow-x: auto; scroll-snap-type: x proximity;
  padding: 4px 16px 16px; margin: 0 -16px;
  border-bottom: 2px solid var(--linea);
  scrollbar-width: thin;
}
.estante > * { scroll-snap-align: start; }
.estante .ficha .orden { font-size: 13px; color: var(--bronce-texto); font-weight: 700; display: block; margin-top: 6px; }
.estado-libro { font-size: 13px; color: var(--bronce-texto); display: block; margin-top: 2px; }
.estado-libro.error { color: var(--sello); }
.guardar {
  margin-top: 6px; border: 0; background: none; padding: 4px 0;
  color: var(--verde); font-size: 14px; font-weight: 700;
}
.guardar[aria-pressed="true"] { color: var(--tinta-suave); }

/* ---------- Libro ---------- */
.libro-cabeza { display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: end; }
.libro-cabeza .tapa { font-size: 18px; }
.libro-cabeza .grupo { color: var(--bronce-texto); font-weight: 700; font-size: 15px; margin: 0 0 6px; }
@media (max-width: 420px) {
  .libro-cabeza { grid-template-columns: 110px 1fr; gap: 16px; }
  .libro-cabeza h1 { font-size: 24px; }
}
.datos { color: var(--tinta-suave); font-size: 15px; margin: 8px 0 0; }
.acciones { margin: 22px 0 6px; display: flex; flex-direction: column; gap: 10px; }
.acciones .boton { width: 100%; }
.acciones .fila-botones .boton { flex: 1 1 auto; white-space: nowrap; font-size: 16px; padding: 0 16px; }
.generando {
  margin: 20px 0 0; padding: 14px 16px; border-radius: 14px;
  background: var(--verde-suave);
}
.generando p { margin: 0 0 10px; font-size: 15px; }
.generando.error { background: color-mix(in srgb, var(--sello) 14%, var(--papel)); }
.capitulos li, .senaladores li { border-bottom: 1px solid var(--linea); }
.capitulos li:last-child, .senaladores li:last-child { border-bottom: 0; }
.capitulos button, .senaladores .ir {
  width: 100%; display: flex; justify-content: space-between; gap: 14px; align-items: baseline;
  padding: 12px 2px; border: 0; background: none; text-align: left;
}
.capitulos button:disabled { opacity: .5; cursor: default; }
.capitulos .t, .senaladores .t { color: var(--tinta-suave); font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; }
.capitulos .actual { color: var(--bronce-texto); font-weight: 700; }
.senaladores li { display: flex; align-items: center; }
.senaladores .ir { flex: 1; }
.senaladores .nota { font-family: var(--serif); }

/* ---------- Formularios ---------- */
.campo { display: block; margin: 0 0 16px; }
.campo > span { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.campo input, .campo select, .campo textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1.5px solid var(--linea); border-radius: 12px;
  background: var(--superficie);
}
.campo textarea { min-height: 320px; font: 15px/1.55 var(--serif); resize: vertical; }
.campo small { display: block; color: var(--tinta-suave); font-size: 14px; margin-top: 6px; }
.dos { display: grid; grid-template-columns: 1fr 110px; gap: 12px; }
.error-form { color: var(--sello); font-weight: 700; margin: 0 0 14px; }
.tarjeta { padding: 18px; border-radius: 16px; background: var(--superficie); box-shadow: var(--sombra); margin-bottom: 18px; }

.ingreso { max-width: 380px; margin: 12vh auto 0; }
.ingreso .marca { font-size: 34px; display: block; margin-bottom: 8px; }

/* ---------- Subir ---------- */
.soltar {
  display: grid; place-items: center; text-align: center; gap: 10px;
  min-height: 260px; padding: 28px 20px; border-radius: 20px;
  border: 2px dashed var(--verde); background: var(--superficie);
  cursor: pointer;
}
.soltar.encima { background: var(--verde-suave); border-style: solid; }
.soltar svg { width: 44px; height: 44px; color: var(--verde); }
.soltar b { font: 600 22px/1.25 var(--serif); display: block; }
.soltar input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.leyendo { padding: 22px 0; }
.leyendo .barra { height: 6px; margin-top: 12px; }
.subida-cabeza { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.portada-previa { width: 84px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 3px 7px 7px 3px; box-shadow: var(--sombra); flex: none; }
.lista-caps { max-height: 220px; overflow: auto; margin: 0 0 16px; padding: 6px 14px 6px 34px; border-radius: 12px; background: var(--superficie); border: 1.5px solid var(--linea); font-family: var(--serif); font-size: 15px; }
.lista-caps li { padding: 4px 0; }

/* ---------- Usuarios ---------- */
.usuarios li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--linea); flex-wrap: wrap; }
.usuarios .etiqueta { font-size: 13px; color: var(--bronce-texto); font-weight: 700; margin-left: 6px; }
.tema { display: flex; gap: 8px; flex-wrap: wrap; }
.tema label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 20px; border: 1.5px solid var(--linea); }
.tema input { accent-color: var(--verde); }

/* ---------- Pestañas ---------- */
#pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--alto-pestanas) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--papel) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--linea);
}
#pestanas a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--tinta-suave); font-size: 12px; font-weight: 700;
}
#pestanas a[aria-current="page"] { color: var(--verde); }
#pestanas a[aria-current="page"] svg { stroke-width: 2.3; }

/* ---------- Mini reproductor ---------- */
#mini {
  position: fixed; left: 8px; right: 8px; z-index: 19;
  bottom: calc(var(--alto-pestanas) + env(safe-area-inset-bottom) + 6px);
  height: var(--alto-mini);
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 4px;
  padding: 0 8px 0 0; border-radius: 14px;
  background: var(--superficie); box-shadow: var(--sombra);
  overflow: hidden;
  max-width: 744px; margin: 0 auto;
}
.mini-barra { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--linea); }
.mini-barra span { display: block; height: 100%; width: 0; background: var(--bronce); }
.mini-abrir { display: flex; align-items: center; gap: 12px; min-width: 0; height: 100%; padding: 0 0 0 10px; border: 0; background: none; text-align: left; }
.mini-tapa { width: 34px; flex: none; }
.mini-tapa .tapa { font-size: 5px; box-shadow: none; }
.mini-textos { min-width: 0; display: flex; flex-direction: column; }
.mini-titulo { font: 600 15px/1.25 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-cap { font-size: 13px; color: var(--tinta-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-boton { width: 44px; height: 44px; border: 0; background: none; border-radius: 50%; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.mini-play { background: var(--bronce); color: var(--sobre-bronce); display: grid; place-items: center; }
.mini-play svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }

/* ---------- Reproductor ---------- */
#reproductor {
  position: fixed; inset: 0; z-index: 30;
  background: var(--papel);
  overflow-y: auto; overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top) + 6px) 16px calc(env(safe-area-inset-bottom) + 24px);
  animation: subir .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes subir { from { transform: translateY(30%); opacity: 0; } to { transform: none; opacity: 1; } }
.rep-cabeza { display: flex; justify-content: space-between; align-items: center; max-width: 520px; margin: 0 auto; }
.rep-cabeza svg { width: 28px; height: 28px; }
.rep-cuerpo { max-width: 460px; margin: 0 auto; text-align: center; }
.rep-tapa { width: min(62vw, 250px, 34vh); margin: 6px auto 20px; }
.rep-tapa .tapa { font-size: 24px; }
.rep-titulo { font: 600 25px/1.2 var(--serif); margin: 0; }
.rep-autor { margin: 4px 0 0; color: var(--tinta-suave); }
.rep-capitulo {
  margin: 10px auto 0; max-width: 100%;
  border: 0; background: var(--verde-suave); color: var(--verde);
  padding: 6px 14px; border-radius: 16px; font-size: 15px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rep-linea { margin: 22px 0 8px; }
#rep-barra { width: 100%; accent-color: var(--bronce); height: 28px; margin: 0; }
.rep-tiempos { display: flex; justify-content: space-between; font-size: 14px; color: var(--tinta-suave); font-variant-numeric: tabular-nums; }
.rep-generando { font-size: 14px; color: var(--bronce-texto); margin: 6px 0 0; }
.rep-controles { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; margin: 14px 0 22px; }
.saltos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.saltos button {
  height: 44px; border: 0; border-radius: 12px;
  background: var(--superficie); box-shadow: inset 0 0 0 1px var(--linea);
  font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums;
}
.saltos button:active { background: var(--verde-suave); }
.play {
  width: 88px; height: 88px; border-radius: 50%; border: 0;
  background: var(--bronce); color: var(--sobre-bronce);
  display: grid; place-items: center; box-shadow: var(--sombra);
}
.play svg, .mini-play svg { fill: currentColor; stroke: none; }
.play svg { width: 38px; height: 38px; }
.play:active { transform: scale(.96); }
.rep-extras { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 0 14px; border-radius: 21px; border: 0;
  background: var(--superficie); box-shadow: inset 0 0 0 1px var(--linea);
  font-size: 15px; font-weight: 700;
}
.chip select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.chip-valor { color: var(--verde); font-weight: 700; }
.chip:focus-within { outline: 3px solid var(--bronce); outline-offset: 2px; }
.chip.activo { box-shadow: inset 0 0 0 2px var(--bronce); }
.chip-nombre { color: var(--tinta-suave); font-weight: 400; }
.rep-senalar { margin: 16px 0 0; text-align: left; padding: 14px; border-radius: 14px; background: var(--superficie); box-shadow: inset 0 0 0 1px var(--linea); }
.rep-senalar input { width: 100%; min-height: 44px; margin: 8px 0 12px; padding: 8px 12px; border: 1.5px solid var(--linea); border-radius: 10px; background: var(--papel); }
.rep-panel { margin: 20px 0 0; text-align: left; }
.rep-panel h3 { margin: 0 0 6px; }

/* ---------- Fin del libro ---------- */
.fin-libro { padding: 20px; border-radius: 16px; background: var(--superficie); box-shadow: var(--sombra); text-align: left; }
.fin-libro p { margin: 0 0 14px; }

/* ---------- Aviso ---------- */
#aviso {
  position: fixed; left: 50%; z-index: 40;
  bottom: calc(var(--alto-pestanas) + var(--alto-mini) + env(safe-area-inset-bottom) + 18px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--tinta); color: var(--papel); font-weight: 700; font-size: 15px;
  transition: opacity .2s, transform .2s;
}
#aviso.visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
