/* --------------------------------------------------------------------------
   ATR READING — hoja de estilo.

   Misma regla que ATR BOOK: la interfaz es gris, con los materiales, la
   tipografía y las curvas de iOS. El azul aparece sólo en lo seleccionado y
   en el botón principal. Lo único con color propio es la página que se lee.
   -------------------------------------------------------------------------- */

:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;

  /* Grises del sistema iOS (apariencia clara). */
  --bg: #f2f2f7;
  --bg-2: #ffffff;
  --bg-3: #f2f2f7;
  --bar: rgba(249, 249, 251, 0.92);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.2);
  --hairline: rgba(60, 60, 67, 0.18);
  --seg-on: #ffffff;
  --cover-ph: #e3e3e8;
  --shadow-cover: 0 1px 2px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.12);
  --scrim: rgba(0, 0, 0, 0.28);

  /* Sin color: el «acento» es un gris que contrasta con el fondo. */
  --accent: #3a3a3c;
  --on-accent: #ffffff;
  --danger: #1c1c1e;
  --switch-on: #636366;

  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  color-scheme: light;
}

/* Apariencia oscura: la del sistema, o la que impone el tema del lector. */
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --bg: #000000;
    --bg-2: #1c1c1e;
    --bg-3: #2c2c2e;
    --bar: rgba(22, 22, 24, 0.92);
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.36);
    --hairline: rgba(84, 84, 88, 0.6);
    --seg-on: #636366;
    --cover-ph: #2c2c2e;
    --shadow-cover: 0 1px 2px rgba(0, 0, 0, 0.5), 0 6px 16px rgba(0, 0, 0, 0.5);
    --scrim: rgba(0, 0, 0, 0.5);
    --accent: #e5e5ea;
    --on-accent: #1c1c1e;
    --danger: #f2f2f7;
    --switch-on: #8e8e93;
    color-scheme: dark;
  }
}
:root[data-scheme="dark"] {
  --bg: #000000;
  --bg-2: #1c1c1e;
  --bg-3: #2c2c2e;
  --bar: rgba(22, 22, 24, 0.92);
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);
  --fill: rgba(118, 118, 128, 0.24);
  --fill-2: rgba(118, 118, 128, 0.36);
  --hairline: rgba(84, 84, 88, 0.6);
  --seg-on: #636366;
  --cover-ph: #2c2c2e;
  --shadow-cover: 0 1px 2px rgba(0, 0, 0, 0.5), 0 6px 16px rgba(0, 0, 0, 0.5);
  --scrim: rgba(0, 0, 0, 0.5);
  --accent: #e5e5ea;
  --on-accent: #1c1c1e;
  --danger: #f2f2f7;
  --switch-on: #8e8e93;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: var(--bg);
  color: var(--label);
  font: 17px/1.3 var(--font-ui);
  letter-spacing: -0.41px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
button {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* =============================== Biblioteca =============================== */

.library {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.nav {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  padding: var(--sat) calc(16px + var(--sar)) 0 calc(16px + var(--sal));
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.nav.scrolled {
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--hairline);
}
.nav-row {
  height: 44px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.nav-title {
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.nav.scrolled .nav-title { opacity: 1; }
.nav-btn {
  color: var(--accent);
  justify-self: start;
  height: 44px;
  padding: 0 2px;
}
.nav-btn.bold { font-weight: 600; }
.nav-btn.icon {
  justify-self: end;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--fill);
  display: grid;
  place-items: center;
}
.nav-btn.icon svg { width: 18px; height: 18px; stroke-width: 2.4; }
.nav-btn:active { opacity: 0.4; }

.lib-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--sat) + 44px) calc(20px + var(--sar)) calc(var(--sab) + 32px) calc(20px + var(--sal));
}
.large-title {
  font: 700 34px/41px var(--font-display);
  letter-spacing: 0.37px;
  margin: 2px 0 14px;
}
.sec-title {
  font: 600 22px/28px var(--font-display);
  letter-spacing: 0.35px;
  margin: 18px 0 12px;
}

/* Portada */
.cover {
  position: relative;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  background: var(--cover-ph);
  box-shadow: var(--shadow-cover);
}
.cover img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
/* Brillo de lomo, como las portadas de Libros. */
.cover::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.12) 0, rgba(255,255,255,0.18) 2px, rgba(0,0,0,0) 7px);
  pointer-events: none;
}

/* Continuar leyendo */
.continue-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  text-align: left;
  background: var(--bg-2);
  border-radius: 14px;
  transition: transform 0.2s var(--spring);
}
.continue-card:active { transform: scale(0.98); }
.continue-card .cover { width: 72px; flex: none; }
.cc-info { flex: 1; min-width: 0; }
.cc-title {
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cc-author { color: var(--label-2); font-size: 15px; margin-top: 2px; }
.cc-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--fill-2);
  margin: 12px 0 7px;
  overflow: hidden;
}
.cc-progress div { height: 100%; background: var(--label); border-radius: 2px; }
.cc-meta { color: var(--label-2); font-size: 13px; letter-spacing: -0.08px; }
.chev { width: 14px; height: 14px; color: var(--label-3); flex: none; stroke-width: 2.6; }

/* Cuadrícula */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 42%), 1fr));
  gap: 26px 20px;
  align-items: end;
}
@media (max-width: 400px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 24px 18px; }
}
.card {
  position: relative;
  text-align: left;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.25s var(--spring);
}
.card:active, .card.pressed { transform: scale(0.96); }
.card-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.24px;
  margin-top: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  font-size: 13px;
  color: var(--label-2);
  margin-top: 2px;
  letter-spacing: -0.08px;
  font-variant-numeric: tabular-nums;
}
.card-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--fill-2);
  margin-top: 6px;
  overflow: hidden;
}
.card-bar div { height: 100%; background: var(--label-2); }
.card.importing .cover { display: grid; place-items: center; }
.card.importing .card-title { color: var(--label-2); }

.card .del {
  position: absolute;
  top: -8px; left: -8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #636366;
  color: #fff;
  display: grid;
  place-items: center;
  transform: scale(0);
  transition: transform 0.25s var(--spring);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  z-index: 2;
}
.card .del svg { width: 14px; height: 14px; stroke-width: 3; }
.library.editing .card .del { transform: scale(1); }
.library.editing .card .cover { animation: jiggle 0.28s ease-in-out infinite alternate; }
.library.editing .card:nth-child(2n) .cover { animation-delay: -0.14s; }
@keyframes jiggle { from { transform: rotate(-0.8deg); } to { transform: rotate(0.8deg); } }

.lib-footer {
  text-align: center;
  color: var(--label-3);
  font-size: 13px;
  margin: 36px 0 0;
}

/* Vacía */
.empty {
  text-align: center;
  padding: 12vh 20px 0;
  color: var(--label-2);
}
.empty-icon { width: 64px; height: 64px; stroke-width: 1.6; color: var(--label-3); }
.empty h2 { color: var(--label); font: 600 22px/28px var(--font-display); margin: 14px 0 8px; }
.empty p { margin: 0 auto 24px; max-width: 300px; font-size: 15px; line-height: 1.4; }
.btn-filled {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  padding: 14px 28px;
  border-radius: 14px;
}
.btn-filled:active { opacity: 0.75; }

/* Ruedita de iOS */
.spinner {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2.5px solid var(--fill-2);
  border-top-color: var(--label-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================= Lector ================================= */

.reader {
  --r-bg: #ffffff;
  --r-ink: #1c1c1e;
  --r-faint: rgba(60, 60, 67, 0.45);
  --r-bar: rgba(255, 255, 255, 0.82);
  --r-hair: rgba(0, 0, 0, 0.12);
  --r-ctl: rgba(60, 60, 67, 0.85);
  --r-track: rgba(60, 60, 67, 0.18);
  --r-canvas: #e9e9ee;
  --r-filter: none;

  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--r-bg);
  color: var(--r-ink);
  transform: translateX(100%);
  transition: transform 0.38s var(--spring), background 0.3s var(--ease);
}
.reader.open { transform: none; }

.reader[data-theme="sepia"] {
  --r-bg: #f5ecd9; --r-ink: #4a3b2a; --r-faint: rgba(90, 70, 45, 0.5);
  --r-bar: rgba(245, 236, 217, 0.86); --r-hair: rgba(90, 70, 45, 0.18);
  --r-ctl: rgba(90, 70, 45, 0.85); --r-track: rgba(90, 70, 45, 0.2);
  --r-canvas: #e9dfc9; --r-filter: sepia(0.35) brightness(0.97);
}
.reader[data-theme="gray"] {
  --r-bg: #3a3a3c; --r-ink: #e5e5ea; --r-faint: rgba(235, 235, 245, 0.45);
  --r-bar: rgba(58, 58, 60, 0.86); --r-hair: rgba(255, 255, 255, 0.12);
  --r-ctl: rgba(235, 235, 245, 0.85); --r-track: rgba(235, 235, 245, 0.2);
  --r-canvas: #2c2c2e; --r-filter: invert(0.86) hue-rotate(180deg);
}
.reader[data-theme="night"] {
  --r-bg: #000000; --r-ink: #d1d1d6; --r-faint: rgba(235, 235, 245, 0.4);
  --r-bar: rgba(22, 22, 24, 0.86); --r-hair: rgba(255, 255, 255, 0.12);
  --r-ctl: rgba(235, 235, 245, 0.85); --r-track: rgba(235, 235, 245, 0.2);
  --r-canvas: #000000; --r-filter: invert(0.9) hue-rotate(180deg);
}

.r-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ---- Modo Texto ---- */
.r-text {
  max-width: calc(38em + 2 * var(--r-margin));
  margin: 0 auto;
  padding: calc(var(--sat) + 44px) calc(var(--r-margin) + var(--sar)) calc(var(--sab) + 50vh) calc(var(--r-margin) + var(--sal));
  font-family: var(--r-font);
  font-size: var(--r-size);
  line-height: var(--r-lh);
  letter-spacing: 0;
  -webkit-hyphens: auto;
  hyphens: auto;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}
.reader[data-mode="pages"] .r-text { display: none; }
.reader.justify .r-text p { text-align: justify; }
.r-text p { margin: 0 0 0.75em; }
/* «Renglones»: cada línea del PDF en la suya, con un poco de aire entre ellas. */
.reader.lines .r-text p { text-align: left; margin-bottom: 1.4em; -webkit-hyphens: manual; hyphens: manual; }
.reader.lines .r-text .ln { display: block; margin-bottom: 0.45em; }
.reader.lines .r-text .ln:last-child { margin-bottom: 0; }
.r-text h2 {
  font-size: 1.32em;
  line-height: 1.25;
  font-weight: 600;
  margin: 1.8em 0 0.9em;
  text-align: left;
  -webkit-hyphens: manual;
  hyphens: manual;
  letter-spacing: -0.01em;
}
.r-text h2:first-child { margin-top: 0.4em; }
.r-text ::selection { background: rgba(142, 142, 147, 0.38); }
.r-end {
  text-align: center;
  color: var(--r-faint);
  font: 13px var(--font-ui);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 3em;
}

/* ---- Modo Original ---- */
.r-pages {
  padding: calc(var(--sat) + 8px) 8px calc(var(--sab) + 40vh);
  min-width: 100%;
}
.reader[data-mode="text"] .r-pages { display: none; }
.pg {
  position: relative;
  margin: 0 auto 10px;
  background: var(--r-canvas);
  box-shadow: 0 0 0 0.5px var(--r-hair);
}
.pg canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
.reader.pdf-colors .pg canvas { filter: var(--r-filter); }
.pg-n {
  position: absolute;
  top: 50%; left: 0; right: 0;
  text-align: center;
  font: 13px var(--font-ui);
  color: var(--r-faint);
}

/* ---- Barras ---- */
.r-top, .r-bottom {
  position: absolute;
  left: 0; right: 0;
  z-index: 3;
  background: var(--r-bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  transition: transform 0.32s var(--spring), opacity 0.25s var(--ease);
  opacity: 0;
  pointer-events: none;
}
.reader.chrome .r-top, .reader.chrome .r-bottom { opacity: 1; transform: none; pointer-events: auto; }
.r-top {
  top: 0;
  padding: var(--sat) calc(6px + var(--sar)) 0 calc(6px + var(--sal));
  height: calc(var(--sat) + 48px);
  display: flex;
  align-items: center;
  gap: 2px;
  box-shadow: 0 0.5px 0 var(--r-hair);
  transform: translateY(-100%);
}
.r-bottom {
  bottom: 0;
  padding: 12px calc(20px + var(--sar)) calc(var(--sab) + 10px) calc(20px + var(--sal));
  box-shadow: 0 -0.5px 0 var(--r-hair);
  transform: translateY(100%);
}
.r-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}
.r-btn {
  width: 40px; height: 44px;
  display: grid;
  place-items: center;
  color: var(--r-ctl);
  flex: none;
}
.r-btn:active { opacity: 0.4; }
.r-btn svg { width: 22px; height: 22px; }
.r-btn.back svg { stroke-width: 2.4; }
.r-btn.on svg { fill: currentColor; }

.r-pos {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--r-faint);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* Deslizador estilo iOS */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  margin: 0;
  --fill: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--r-ctl) var(--fill), var(--r-track) var(--fill));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.28), 0 3px 8px rgba(0, 0, 0, 0.12);
}

/* Página discreta cuando las barras están ocultas */
.r-mini {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  padding: 16px 0 calc(var(--sab) + 6px);
  background: linear-gradient(to bottom, transparent, var(--r-bg) 55%);
  text-align: center;
  font: 11px var(--font-ui);
  color: var(--r-faint);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
  z-index: 2;
}
.reader.chrome .r-mini { opacity: 0; }

.r-loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--r-bg);
  color: var(--r-faint);
  font-size: 15px;
}
.r-loading p { margin: 0; }
.r-loading .bar { width: 160px; height: 4px; border-radius: 2px; background: var(--r-track); overflow: hidden; }
.r-loading .bar div { height: 100%; background: var(--r-ctl); transition: width 0.2s linear; }
.r-loading .spinner { border-color: var(--r-track); border-top-color: var(--r-ctl); }

.toast {
  position: absolute;
  left: 50%;
  top: calc(var(--sat) + 60px);
  transform: translate(-50%, -10px);
  opacity: 0;
  z-index: 6;
  background: var(--r-bar);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: var(--r-ink);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 0.5px var(--r-hair);
  transition: opacity 0.2s var(--ease), transform 0.3s var(--spring);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================== Hojas modales ============================== */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.scrim.show { opacity: 1; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 21;
  max-width: 560px;
  margin: 0 auto;
  max-height: calc(100% - var(--sat) - 40px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--label);
  border-radius: 14px 14px 0 0;
  transform: translateY(105%);
  transition: transform 0.42s var(--spring);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.12);
}
.sheet.show { transform: translateY(0); }
.sheet.tall { height: calc(100% - var(--sat) - 40px); }
.grabber {
  width: 36px; height: 5px;
  border-radius: 3px;
  background: var(--label-3);
  margin: 6px auto 0;
  flex: none;
}
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 10px calc(16px + var(--sar)) calc(var(--sab) + 20px) calc(16px + var(--sal));
}
.sheet-head { padding: 4px 0 12px; }

.group {
  background: var(--bg-2);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.group.pad { padding: 12px 14px 14px; }
.lbl {
  font-size: 13px;
  color: var(--label-2);
  margin: 2px 2px 8px;
  letter-spacing: -0.08px;
}
.lbl ~ .lbl { margin-top: 14px; }

.row {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  text-align: left;
  position: relative;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0; left: 16px; right: 0;
  height: 0.5px;
  background: var(--hairline);
}
.row:active { background: var(--fill); }
.row > span:first-child { flex: 1; }
.row svg { width: 20px; height: 20px; color: var(--label-2); flex: none; }
.row.danger { color: var(--danger); font-weight: 600; }
.row.danger svg { color: var(--danger); }

.row.font { font-size: 18px; letter-spacing: 0; }
.row .check { opacity: 0; color: var(--accent); stroke-width: 2.4; }
.row.on .check { opacity: 1; }

/* Índice */
.row.toc { padding-top: 12px; padding-bottom: 12px; }
.row.toc.d1 { padding-left: 32px; }
.row.toc.d2 { padding-left: 48px; }
.row.toc.d3 { padding-left: 64px; }
.row.toc.d1 .toc-t, .row.toc.d2 .toc-t, .row.toc.d3 .toc-t { color: var(--label-2); font-size: 15px; }
.toc-t { flex: 1; }
.toc-p { color: var(--label-3); font-size: 15px; font-variant-numeric: tabular-nums; }
.row.toc.current .toc-t { font-weight: 600; color: var(--label); }

.row.mark { align-items: flex-start; }
.mark-t { flex: 1; min-width: 0; }
.mark-t b { font-weight: 600; display: block; }
.mark-t span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  color: var(--label-2);
  margin-top: 3px;
}
.mark-del { width: 30px; height: 30px; display: grid; place-items: center; margin: -4px -6px 0 0; }
.mark-del svg { width: 16px; height: 16px; color: var(--label-3); }

.placeholder {
  text-align: center;
  color: var(--label-2);
  padding: 40px 20px;
  line-height: 1.5;
}
.placeholder .inline { width: 16px; height: 16px; vertical-align: -3px; }
.note {
  font-size: 13px;
  color: var(--label-2);
  margin: -6px 4px 16px;
  line-height: 1.4;
}

/* Control segmentado */
.seg {
  display: flex;
  background: var(--fill);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}
.seg button {
  flex: 1;
  height: 32px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.15px;
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.seg button.on {
  background: var(--seg-on);
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
.seg button:disabled { opacity: 0.35; }
.seg.small button { height: 30px; font-size: 13px; }

/* Botones − / + */
.stepper {
  display: flex;
  align-items: center;
  height: 52px;
}
.stepper button {
  flex: 1;
  height: 100%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 500;
}
.stepper button:active { background: var(--fill); }
.stepper button svg { width: 20px; height: 20px; color: var(--label); }
.stepper-val {
  width: 76px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--label-2);
  font-size: 15px;
  border-left: 0.5px solid var(--hairline);
  border-right: 0.5px solid var(--hairline);
  line-height: 28px;
}

/* Temas */
.themes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.theme { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.swatch {
  width: 100%;
  max-width: 56px;
  aspect-ratio: 1;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font: 600 18px ui-serif, "New York", Georgia, serif;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.15);
  transition: box-shadow 0.15s var(--ease);
}
.theme.on .swatch { box-shadow: 0 0 0 2.5px var(--bg-2), 0 0 0 4.5px var(--accent); }
.tname { font-size: 12px; color: var(--label-2); }
.theme.on .tname { color: var(--label); font-weight: 600; }
.t-auto .swatch { background: linear-gradient(135deg, #fff 50%, #1c1c1e 50%); color: #8e8e93; }
.t-light .swatch { background: #fff; color: #1c1c1e; }
.t-sepia .swatch { background: #f5ecd9; color: #4a3b2a; }
.t-gray .swatch { background: #3a3a3c; color: #e5e5ea; }
.t-night .swatch { background: #000; color: #d1d1d6; box-shadow: inset 0 0 0 0.5px rgba(255,255,255,0.2); }

/* Interruptor iOS */
.switch-row { cursor: pointer; }
.switch {
  -webkit-appearance: none;
  appearance: none;
  width: 51px; height: 31px;
  border-radius: 16px;
  background: var(--fill-2);
  position: relative;
  flex: none;
  margin: 0;
  transition: background 0.25s var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 27px; height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 3px 1px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s var(--spring);
}
.switch:checked { background: var(--switch-on); }
.switch:checked::after { transform: translateX(20px); }

/* Ficha del libro (pulsación larga) */
.book-head { display: flex; gap: 14px; align-items: center; padding-bottom: 16px; }
.book-head .cover { width: 54px; flex: none; }
.bh-title { font-weight: 600; }
.bh-meta { font-size: 13px; color: var(--label-2); margin-top: 3px; }

/* =============================== Alerta iOS =============================== */

.alert-wrap {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.alert-wrap.show { opacity: 1; }
.alert {
  width: 270px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-2) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  text-align: center;
  overflow: hidden;
  transform: scale(1.12);
  transition: transform 0.3s var(--spring);
}
.alert-wrap.show .alert { transform: scale(1); }
.alert-text { padding: 19px 16px 18px; }
.alert h3 { margin: 0; font-size: 17px; font-weight: 600; }
.alert p { margin: 4px 0 0; font-size: 13px; line-height: 1.35; letter-spacing: -0.08px; }
.alert-input {
  width: 100%;
  margin-top: 14px;
  padding: 7px 8px;
  font: 14px var(--font-ui);
  color: var(--label);
  background: var(--bg-2);
  border: 0.5px solid var(--hairline);
  border-radius: 7px;
  outline: none;
}
.alert-btns { display: flex; border-top: 0.5px solid var(--hairline); }
.alert-btns button { flex: 1; height: 44px; color: var(--accent); }
.alert-btns button + button { border-left: 0.5px solid var(--hairline); }
.alert-btns.stack { flex-direction: column; }
.alert-btns.stack button + button { border-left: 0; border-top: 0.5px solid var(--hairline); }
.alert-btns button.bold { font-weight: 600; }
.alert-btns button.danger { color: var(--danger); font-weight: 600; }
.alert-btns button:active { background: var(--fill); }

/* Mientras se lee, la biblioteca no se pinta (ahorra batería). */
body.reading .library { visibility: hidden; transition: visibility 0s 0.4s; }

/* ================================== OCR ================================== */

.ocr-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 6px;
}
.ocr-title svg { width: 20px; height: 20px; color: var(--label-2); }
.ocr-desc { font-size: 14px; line-height: 1.4; color: var(--label-2); margin: 0 0 12px; letter-spacing: -0.15px; }
.ocr-box .lbl { margin-top: 2px; }
.ocr-foot { font-size: 12px; line-height: 1.4; color: var(--label-3); margin: 10px 2px 0; letter-spacing: 0; }
.ocr-bar { height: 6px; border-radius: 3px; background: var(--fill-2); overflow: hidden; margin: 8px 0 8px; }
.ocr-bar div { height: 100%; background: var(--label-2); border-radius: 3px; transition: width 0.4s var(--ease); }
.ocr-stat {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.08px;
}
.btn-filled.wide, .btn-plain.wide { display: block; width: 100%; margin-top: 14px; padding: 13px; border-radius: 12px; }
.btn-plain { background: var(--fill); color: var(--accent); font-weight: 600; }
.btn-plain:disabled { opacity: 0.5; }
.btn-plain:active { opacity: 0.6; }
.link-btn {
  display: block;
  width: 100%;
  text-align: center;
  color: var(--accent);
  font-size: 14px;
  padding: 4px 0 16px;
}

/* Páginas que el OCR aún no ha leído, dentro del modo Texto */
.r-pending {
  margin: 1.2em 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px dashed var(--r-track);
  font: 14px/1.4 var(--font-ui);
  color: var(--r-faint);
  text-align: center;
  cursor: pointer;
}
.r-pending b { display: block; color: var(--r-ink); font-weight: 600; margin-bottom: 2px; }
.r-pending span { font-size: 13px; }

/* ===================== Libro paginado (modo Texto) =====================
   Cada columna CSS mide exactamente una pantalla: es una hoja.           */

.reader.paged .r-scroll { overflow: hidden; }
.reader.paged .r-text {
  position: absolute;
  left: 0;
  top: calc(var(--sat) + 40px);
  bottom: calc(var(--sab) + 34px);
  width: var(--pw, 100vw);
  max-width: none;
  margin: 0;
  padding: 0 var(--r-margin);
  column-width: calc(var(--pw, 100vw) - 2 * var(--r-margin));
  column-gap: calc(2 * var(--r-margin));
  column-fill: auto;
  will-change: transform;
  orphans: 2;
  widows: 2;
}
.reader.paged .r-text h2 { break-after: avoid; }
.reader.paged .r-pending { break-inside: avoid; }
.reader.paged .r-end { break-inside: avoid; margin-top: 2em; }
.reader.paged .r-mini { background: none; }

.layout-seg { margin-bottom: 16px; }

/* ================= Modo Original paginado: una página por pantalla ================= */

.pgw { display: contents; }
.reader.pdf-paged .r-scroll { overflow: hidden; }
.reader.pdf-paged .r-pages {
  position: absolute;
  left: 0;
  top: calc(var(--sat) + 6px);
  bottom: calc(var(--sab) + 26px);
  display: flex;
  padding: 0;
  min-width: 0;
  will-change: transform;
}
.reader.pdf-paged .pgw {
  display: flex;
  flex: 0 0 var(--pw, 100vw);
  width: var(--pw, 100vw);
  height: 100%;
  overflow: hidden;
}
/* Con zoom, la página actual se puede recorrer con el dedo. */
.reader.pdf-paged .pgw.cur {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.reader.pdf-paged .pg {
  flex: none;
  margin: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--r-hair);
}

/* Respaldo (al pie de la biblioteca) */
.backup-box { margin: 28px auto 0; max-width: 560px; }
.backup-box .group { background: var(--bg-2); }
.backup-box .row { color: var(--accent); }
.backup-box .row svg { color: var(--accent); }
.backup-box .row:disabled { color: var(--label-2); }
.backup-note { font-size: 13px; line-height: 1.4; color: var(--label-2); margin: -8px 16px 0; text-align: left; }
.backup-note.warn { color: var(--label); font-weight: 500; }

/* Notas al pie (de PDF etiquetados): debajo de su párrafo, en pequeño */
.r-text p.r-note {
  font-size: 0.8em;
  line-height: 1.45;
  color: var(--r-faint);
  margin: -0.3em 0 0.9em;
  padding-left: 0.9em;
  border-left: 2px solid var(--r-track);
  text-align: left;
}

/* Cada capítulo empieza en hoja nueva (modo Páginas) */
.reader.paged .r-text h2.chap {
  -webkit-column-break-before: always;
  break-before: column;
  margin-top: 2.2em;
}
.reader.pdf-paged .pgw { scrollbar-width: none; }
.reader.pdf-paged .pgw::-webkit-scrollbar { display: none; }

/* «Página X de N» se puede tocar para escribir el número */
#rPos { cursor: pointer; padding: 6px 8px 6px 0; margin: -6px 0; }
#rPos:active { opacity: 0.5; }

/* ==========================================================================
   ESTÉTICA ATR BOOK

   La misma piel que la app de escritorio: grises del sistema en apariencia
   oscura, rellenos blancos casi transparentes, líneas de medio píxel,
   rectángulos redondeados, un filo de luz arriba de cada pieza («edge») y
   sombras sobrias. La interfaz siempre es gris oscuro; lo único que cambia
   de color es la página que se lee (como en ATR BOOK sólo la hoja es clara).
   ========================================================================== */

html:root:not(.x) {
  --bg: #1c1c1e;                         /* --win-bg */
  --bg-2: rgba(255, 255, 255, 0.055);    /* --fill-1: tarjetas y grupos */
  --bg-3: #2e2e30;                       /* --sheet-bg: hojas y paneles */
  --bar: rgba(28, 28, 30, 0.82);         /* --bar-bg */
  --popover: rgba(54, 54, 57, 0.94);
  --sunken: rgba(0, 0, 0, 0.22);
  --label: rgba(255, 255, 255, 0.92);
  --label-2: rgba(235, 235, 245, 0.62);
  --label-3: rgba(235, 235, 245, 0.36);
  --fill: rgba(255, 255, 255, 0.095);    /* --fill-2 */
  --fill-2: rgba(255, 255, 255, 0.14);   /* --fill-3 */
  --hairline: rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.16);
  --seg-on: rgba(255, 255, 255, 0.14);
  --cover-ph: rgba(255, 255, 255, 0.055);
  --scrim: rgba(0, 0, 0, 0.5);
  --accent: #98989d;                     /* paleta «gris» de ATR BOOK */
  --on-accent: #1c1c1e;
  --accent-bright: #aeaeb2;
  --accent-deep: #7c7c80;
  --danger: rgba(255, 255, 255, 0.92);
  --switch-on: #98989d;
  --edge: inset 0 0.5px 0 rgba(255, 255, 255, 0.14);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-modal: 0 24px 68px rgba(0, 0, 0, 0.62), 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-popover: 0 10px 32px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.35);
  --shadow-cover: 0 1px 3px rgba(0, 0, 0, 0.35), 0 8px 22px rgba(0, 0, 0, 0.4);
  --radius-sm: 5px;
  --radius: 7px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  color-scheme: dark;
}

/* ---- Botones: los de ATR BOOK ---- */
.btn-filled, .btn-plain {
  border-radius: 9px;
  font-weight: 500;
  transition: background 0.14s var(--ease), transform 0.14s var(--spring);
}
.btn-filled {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: 0 0.5px 2px rgba(0, 0, 0, 0.35), var(--edge);
}
.btn-filled:active { background: var(--accent-deep); transform: scale(0.97); opacity: 1; }
.btn-plain {
  background: var(--fill);
  color: var(--label);
  box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.3), inset 0 0 0 0.5px var(--hairline-strong), var(--edge);
}
.btn-plain:active { background: var(--fill-2); transform: scale(0.97); opacity: 1; }
.btn-filled.wide, .btn-plain.wide { border-radius: 10px; padding: 13px; }
.link-btn { color: var(--label-2); }

/* ---- Biblioteca ---- */
.nav.scrolled {
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 var(--hairline);
}
.nav-btn.glass {
  background: var(--fill);
  box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.3), inset 0 0 0 0.5px var(--hairline-strong), var(--edge);
  color: var(--label);
  transition: background 0.14s var(--ease), transform 0.14s var(--spring);
}
.nav-btn.glass:active { background: var(--fill-2); transform: scale(0.95); opacity: 1; }
.nav-btn.pill { height: 32px; padding: 0 14px; border-radius: var(--radius); font-size: 15px; font-weight: 500; }
.nav-btn.icon.round { width: 34px; height: 32px; border-radius: var(--radius); display: grid; place-items: center; }
.nav-btn.icon.round svg { width: 17px; height: 17px; stroke-width: 2.2; }
.edge-top { display: none; }

.cover { border-radius: 4px; }
.continue-card, .backup-box .group {
  background: var(--bg-2);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}
/* Reflejo suave en la esquina, como las tarjetas de ATR BOOK. */
.continue-card { position: relative; overflow: hidden; }
.continue-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0) 46%);
  pointer-events: none;
}
.backup-box .row, .backup-box .row svg { color: var(--label); }
.card .del { background: #48484a; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), var(--edge); }

/* ---- Lector: barras como la de ATR BOOK (oscuras sobre cualquier página) ---- */
.reader {
  --r-bar: rgba(28, 28, 30, 0.94);
  --r-ctl: rgba(235, 235, 245, 0.62);
}
.r-top {
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--sat) + 50px);
  padding: var(--sat) 8px 0;
  gap: 2px;
  background: var(--r-bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.09);
  transform: translateY(-100%);
}
.r-top .glass, .r-group {
  background: none;
  border: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.r-title-wrap { flex: 1; }
.r-title { display: none; }
.r-group { display: flex; align-items: center; gap: 2px; padding: 0; height: auto; }
/* Botón de barra: sin marco; sólo se sombrea al tocarlo. */
.r-btn, .r-group .r-btn, .r-btn.round {
  width: 40px;
  height: 38px;
  border-radius: var(--radius);
  color: rgba(235, 235, 245, 0.62);
  display: grid;
  place-items: center;
  transition: background 0.14s var(--ease), color 0.14s var(--ease), transform 0.16s var(--spring);
}
.r-btn:active, .r-group .r-btn:active {
  opacity: 1;
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.92);
}
.r-btn.on { color: rgba(255, 255, 255, 0.92); }
.r-btn svg { width: 21px; height: 21px; }
.r-btn.back svg { stroke-width: 2.3; }
.r-btn.aa { display: grid; place-items: center; }
.aa-icon { stroke-width: 1.9; display: block; }

.r-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  border: 0;
  border-radius: 0;
  padding: 12px calc(20px + var(--sar)) calc(var(--sab) + 10px) calc(20px + var(--sal));
  background: var(--r-bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -0.5px 0 rgba(255, 255, 255, 0.09);
  transform: translateY(100%);
}
.r-pos { color: rgba(235, 235, 245, 0.62); margin-top: 6px; }

/* Deslizador: el de ATR BOOK (fino, con bolita clara), algo mayor para el dedo. */
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #98989d var(--fill), rgba(255, 255, 255, 0.14) var(--fill));
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.3);
}
input[type="range"]::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: linear-gradient(#fdfdfd, #e9e9ec);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 0 0 0.5px rgba(0, 0, 0, 0.35);
}

.toast {
  background: var(--popover);
  color: var(--label);
  border: 0.5px solid var(--hairline-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover), var(--edge);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
}

/* ---- Hojas: el panel de ATR BOOK ---- */
.sheet, .sheet.glass-sheet {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(100% - var(--sat) - 30px);
  background: var(--bg-3);
  border: 0.5px solid var(--hairline-strong);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  box-shadow: var(--shadow-modal), var(--edge);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transform: translateY(105%);
}
.sheet.glass-sheet.show, .sheet.show { transform: translateY(0); }
.sheet.glass-sheet.tall, .sheet.tall { height: calc(100% - var(--sat) - 30px); }
.sheet .sheet-body { padding: 10px calc(16px + var(--sar)) calc(var(--sab) + 20px) calc(16px + var(--sal)); }
.grabber { background: rgba(235, 235, 245, 0.3); width: 36px; margin-top: 6px; }
.group, .sheet .group {
  background: var(--bg-2);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-xl);
}
.row:active { background: var(--fill); }
.row .check { color: var(--label); }
.scrim {
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* ---- Control segmentado: hundido, con la pastilla que se desliza ---- */
.seg {
  position: relative;
  display: flex;
  background: var(--sunken);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 2px;
  gap: 0;
  isolation: isolate;
}
.seg button {
  position: relative;
  z-index: 1;
  height: 32px;
  border-radius: 8px;
  color: var(--label-2);
  font-weight: 500;
  background: none !important;
  box-shadow: none !important;
  transition: color 0.18s var(--ease);
}
.seg button.on { color: var(--label); font-weight: 600; }
.seg.small button { height: 30px; }
.seg-thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  border-radius: 8px;
  background: var(--fill-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), var(--edge);
  transition: transform 0.34s var(--spring), width 0.34s var(--spring), opacity 0.2s;
  pointer-events: none;
}

/* ---- Interruptor: el de los Ajustes de macOS, a tamaño de dedo ---- */
.switch {
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: var(--fill);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.3);
  transition: background 0.28s var(--spring);
}
.switch::after {
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.32s var(--spring), width 0.2s var(--spring);
}
.switch:checked { background: var(--switch-on); }
.switch:checked::after { transform: translateX(18px); }

/* ---- Alertas: el panel de ATR BOOK ---- */
.alert {
  width: min(320px, 88vw);
  background: var(--bg-3);
  border: 0.5px solid var(--hairline-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal), var(--edge);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  text-align: left;
}
.alert-text { padding: 20px 20px 4px; }
.alert h3 { font-size: 16px; font-weight: 640; letter-spacing: -0.014em; }
.alert p { font-size: 13.5px; line-height: 1.5; color: var(--label-3); margin-top: 4px; }
.alert-input {
  margin-top: 14px;
  padding: 9px 11px;
  font-size: 16px;
  border-radius: var(--radius);
  background: var(--sunken);
  border: 0.5px solid var(--hairline-strong);
  color: var(--label);
}
.alert-btns { border-top: 0; gap: 8px; padding: 16px 20px 18px; justify-content: flex-end; }
.alert-btns button {
  flex: 1;
  height: 38px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  color: var(--label);
  background: var(--fill);
  box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.3), inset 0 0 0 0.5px var(--hairline-strong), var(--edge);
  transition: background 0.14s var(--ease), transform 0.14s var(--spring);
}
.alert-btns button + button { border-left: 0; }
.alert-btns.stack button + button { border-top: 0; }
.alert-btns button.bold {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: 0 0.5px 2px rgba(0, 0, 0, 0.35), var(--edge);
}
.alert-btns button.danger { font-weight: 700; }
.alert-btns button:active { transform: scale(0.97); background: var(--fill-2); }
.alert-btns button.bold:active { background: var(--accent-deep); }

/* Con una hoja abierta, las barras del lector se apartan. */
body.sheet-open .reader.chrome .r-top,
body.sheet-open .reader.chrome .r-bottom { opacity: 0; pointer-events: none; }

/* ========================= Biblioteca: minimalista =========================

   Plana y oscura: fondo negro liso, sin degradados ni sombras. Todos los
   libros miden lo mismo (2:3) y cada fila descansa sobre una línea fina,
   como una repisa dibujada. La portada es lo único con color.             */

.library {
  --font-book: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --line: #262626;
  background: #000;
}
.library .nav.scrolled { background: #000; -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 0.5px 0 var(--line); }

.library .large-title {
  font: 600 34px/1.1 var(--font-book);
  letter-spacing: 0;
  margin: 10px 0 8px;
}
.lib-count {
  display: block;
  font: 400 15px/1.3 var(--font-ui);
  letter-spacing: -0.2px;
  color: #6e6e73;
  margin-top: 6px;
}
.library .sec-title {
  font: 500 13px/1 var(--font-ui);
  letter-spacing: 0;
  color: #8e8e93;
  margin: 32px 0 14px;
}

/* ---- Continuar leyendo ---- */
.library .continue-card {
  background: #111;
  border: 0;
  border-radius: 16px;
  box-shadow: none;
  padding: 16px;
  gap: 16px;
}
.library .continue-card::before { display: none; }
.library .continue-card .cover { width: 64px; aspect-ratio: 2 / 3 !important; }
.library .cc-title { font: 600 17px/1.3 var(--font-book); letter-spacing: 0; }
.library .cc-author { color: #8e8e93; font-size: 14px; }
.library .cc-progress { background: #2c2c2e; height: 2px; margin: 12px 0 8px; }
.library .cc-progress div { background: #f2f2f7; }
.library .cc-meta { color: #6e6e73; }

/* ---- Estantería ---- */
.library .grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 18px;
  align-items: start;
}
@media (min-width: 560px) {
  .library .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
.library .card { min-width: 0; padding-bottom: 28px; }
.slot {
  position: relative;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin: 0 -9px;
  padding-left: 9px;
  padding-right: 9px;
}
.book { position: relative; width: 100% !important; }
.library .card .cover {
  aspect-ratio: 2 / 3 !important;
  border-radius: 3px;
  background: #1c1c1e;
  box-shadow: none;
}
.library .cover::after { display: none; }
.cover-ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  text-align: center;
  font: 500 12px/1.3 var(--font-book);
  color: #8e8e93;
  overflow: hidden;
}

.library .card-title {
  font: 500 13px/1.3 var(--font-ui);
  letter-spacing: -0.1px;
  margin-top: 10px;
  color: #e5e5ea;
  overflow-wrap: anywhere;
}
.library .card-meta { font-size: 12px; color: #6e6e73; }
.library .card-bar { height: 2px; background: #2c2c2e; margin-top: 6px; border-radius: 1px; }
.library .card-bar div { background: #aeaeb2; }

.library .card .del { top: -8px; left: -8px; z-index: 3; box-shadow: none; }

.library .lib-footer { color: #48484a; }
.library .empty-icon { color: #48484a; }
.library .empty h2 { font-family: var(--font-book); font-weight: 600; }
