:root {
  --fondo: #1b1d1c;
  --barra: #111312;
  --texto: #ecebe6;
  --tenue: #9a9c97;
  --acento: #1f8a4c;
  --alto-barra: 52px;
  --alto-pie: 40px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--fondo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

button, a { font: inherit; color: inherit; }

/* Barra superior */
.barra {
  height: var(--alto-barra);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--barra);
}
.titulo {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acciones { display: flex; gap: 4px; flex-shrink: 0; }
.acciones button, .acciones a {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.acciones button:hover, .acciones a:hover, .acciones .activo { background: rgba(255,255,255,.1); }
.acciones svg { width: 20px; height: 20px; fill: currentColor; }

/* Escenario del libro */
.escenario {
  position: relative;
  height: calc(100% - var(--alto-barra) - var(--alto-pie));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 56px;
}
.libro-marco {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#libro { display: flex; align-items: center; justify-content: center; }
.pagina { background: #fff; overflow: hidden; }
.pagina img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; pointer-events: none; }

.flecha {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 44px;
  height: 64px;
  border: 0;
  border-radius: 8px;
  background: rgba(0,0,0,.35);
  font-size: 40px;
  line-height: 1;
  cursor: pointer;
}
.flecha:hover { background: rgba(0,0,0,.6); }
.flecha:disabled { opacity: .2; cursor: default; }
.flecha-izq { left: 6px; }
.flecha-der { right: 6px; }

/* Pantalla de carga */
.cargando {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.cargando-texto { color: var(--tenue); font-size: 14px; }
.progreso { width: min(260px, 70%); height: 4px; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; }
#progreso-barra { height: 100%; width: 0; background: var(--acento); transition: width .15s; }

.pie {
  height: var(--alto-pie);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tenue);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Miniaturas */
.miniaturas {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: rgba(10,11,10,.95);
  padding: 12px 16px;
}
.miniaturas-lista {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.miniatura {
  flex: 0 0 auto;
  width: 120px;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 0;
  background: none;
  cursor: pointer;
  text-align: center;
}
.miniatura img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #2a2d2b; border-radius: 2px; }
.miniatura span { display: block; font-size: 11px; color: var(--tenue); padding-top: 3px; }
.miniatura.actual { border-color: var(--acento); }

/* Zoom */
.zoom {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #0b0c0b;
  display: flex;
  flex-direction: column;
}
.zoom-controles {
  height: var(--alto-barra);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.zoom-controles button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,.1);
  font-size: 20px;
  cursor: pointer;
}
#zoom-nivel { min-width: 56px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
#zoom-cerrar { margin-left: 16px; }
.zoom-area { flex: 1; overflow: auto; cursor: grab; touch-action: pan-x pan-y; }
.zoom-area.arrastrando { cursor: grabbing; }
.zoom-contenido { display: flex; width: max-content; margin: 0 auto; padding: 16px; }
.zoom-contenido img { display: block; user-select: none; -webkit-user-drag: none; }

.aviso {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  z-index: 40;
  background: #2a2d2b;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
}

[hidden] { display: none !important; }

/* Móvil: menos margen lateral, flechas más discretas */
@media (max-width: 700px) {
  .escenario { padding: 8px 16px; }
  .flecha { width: 32px; height: 52px; font-size: 30px; background: rgba(0,0,0,.25); }
  .flecha-izq { left: 2px; }
  .flecha-der { right: 2px; }
  .miniatura { width: 90px; }
}
