:root {
  color-scheme: light;
  --bg: #fdf7f9;
  --surface: #ffffff;
  --surface-alt: #fbf3f6;
  --text: #2a1a23;
  --text-muted: #6b4756;
  --border: #efd9e3;
  --input-border: #d8a8be;
  --status-bg: #fce7f0;
  --status-text: #831843;
  --accent: #9d174d;
  --accent-bg: #fff1f5;
  --accent-hover: #fce4ec;
  --brand-pink: #ec4899;
  --brand-burgundy: #9d174d;
  --brand-cream: #fff8fb;
  --header-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --body-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --table-font: var(--body-font);
  font-family: var(--body-font);
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

#particles {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  transition: background 350ms ease, color 350ms ease;
  position: relative;
  min-height: 100vh;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

/* ─── Branding AM-143 ─── */
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none; color: inherit;
}
.brand img.brand-logo { height: 56px; width: auto; display: block; }
.brand .brand-tag {
  font-size: 0.78rem; color: var(--text-muted);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.brand-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  background: var(--brand-cream);
  border: 1px solid var(--brand-pink);
  border-radius: 999px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic; font-weight: 600;
  color: var(--brand-burgundy);
  font-size: 1rem;
}
.brand-pill::before { content: "♥"; color: var(--brand-pink); }

.app-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-family: var(--header-font);
}

.app-header p {
  margin: 0.35rem 0 1rem;
  color: var(--text-muted);
}

.controls {
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#q,
#filter-author,
#filter-genre {
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--input-border);
  border-radius: 0.5rem;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}

#q {
  flex: 1 1 220px;
}

#status,
#error,
#empty {
  margin: 0.75rem 0;
  padding: 0.65rem 0.8rem;
  border-radius: 0.5rem;
  transition: background 350ms ease, color 350ms ease;
}

#status {
  background: var(--status-bg);
  color: var(--status-text);
}

#status.error,
#error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

#empty {
  background: #fef3c7;
  color: #92400e;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  transition: background 350ms ease, border-color 350ms ease;
}

#books {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--table-font);
}

#books th,
#books td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

#books thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-alt);
  font-family: var(--header-font);
}

#books tbody tr:hover {
  background: var(--surface-alt);
}

#books tbody a {
  color: var(--text);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 0.75rem 0;
}

.page-btn {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--input-border);
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.page-btn:hover:not(:disabled) {
  background: var(--surface-alt);
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-info {
  color: var(--text-muted);
  min-width: 8em;
  text-align: center;
}

.quick-nav {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin: 1rem 0;
}
.nav-pill {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--input-border);
  background: var(--surface);
  color: var(--text);
  font: inherit; text-decoration: none; cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
}
.nav-pill:hover { background: var(--surface-alt); border-color: var(--accent); }

.nav-toggle {
  padding: 0.3rem 0.6rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 0.35rem;
  font: inherit; font-size: 1.1rem; line-height: 1;
  cursor: pointer;
}
.nav-toggle:hover { background: var(--surface-alt); border-color: var(--accent); }

.top-nav {
  position: fixed; top: 0.7rem; right: 0.7rem;
  z-index: 80;
}
.top-nav.top-nav-inline {
  position: relative; top: auto; right: auto;
}
@media (min-width: 1100px) {
  body .top-nav { right: calc(400px + 0.7rem); }
}
.top-nav .nav-toggle {
  background: rgba(15, 23, 42, 0.85); color: #f1f5f9;
  border-color: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  font-size: 1.15rem; padding: 0.35rem 0.7rem;
}
.top-nav .nav-toggle:hover {
  background: rgba(15, 23, 42, 0.98); border-color: var(--accent);
}
.top-nav .nav-menu { right: 0; }
.nav-menu a.active {
  background: var(--accent-bg); color: var(--accent);
  font-weight: 600;
}
.nav-menu {
  position: absolute; top: calc(100% + 0.4rem); right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 0.45rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 0.35rem;
  z-index: 60;
  display: flex; flex-direction: column; gap: 0.15rem;
}
.nav-menu[hidden] { display: none; }
.nav-menu a, .nav-menu button {
  display: block; text-align: left;
  padding: 0.5rem 0.7rem;
  border: 0; background: transparent;
  color: var(--text); text-decoration: none;
  font: inherit; font-size: 0.9rem;
  border-radius: 0.3rem; cursor: pointer;
  width: 100%;
}
.nav-menu a:hover, .nav-menu button:hover {
  background: var(--surface-alt);
}
.nav-menu hr {
  margin: 0.25rem 0; border: 0;
  border-top: 1px solid var(--border);
}

.chat-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 400px;
  background: var(--surface);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0,0,0,0.06);
  z-index: 50;
}
.chat-close-btn {
  display: none;
  background: transparent; border: 0;
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  color: var(--text-muted); padding: 0 0.4rem;
  margin-left: auto;
}
.chat-close-btn:hover { color: var(--text); }

.chat-fab {
  position: fixed; right: 18px; bottom: 18px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-bg);
  border: 0; font-size: 1.6rem; line-height: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer; z-index: 60;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.chat-fab:hover { transform: scale(1.05); box-shadow: 0 8px 22px rgba(0,0,0,0.22), 0 3px 6px rgba(0,0,0,0.12); }
.chat-fab:active { transform: scale(0.95); }

.chat-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 55;
  opacity: 0;
  transition: opacity 200ms ease;
}
.chat-backdrop.visible { opacity: 1; }
.chat-backdrop[hidden] { display: none; }

/* DESKTOP: panel embebido a la derecha, FAB y backdrop ocultos */
@media (min-width: 1100px) {
  body { padding-right: 400px; }
  .chat-fab { display: none !important; }
  .chat-backdrop { display: none !important; }
  .chat-close-btn { display: none; }
  .chat-panel { transform: none !important; }
}

/* MOBILE: panel oculto fuera de pantalla; abre como bottom-sheet con FAB */
@media (max-width: 1099px) {
  body { padding-right: 0; }
  .chat-panel {
    position: fixed; top: auto; right: 0; left: 0; bottom: 0;
    width: 100%;
    height: 88vh; max-height: 88vh;
    border-left: 0; border-top: 1px solid var(--border);
    border-top-left-radius: 16px; border-top-right-radius: 16px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
    z-index: 60;
    transform: translateY(100%);
    transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
  }
  .chat-panel.open { transform: translateY(0); }
  .chat-fab[data-mobile="1"] { display: flex; align-items: center; justify-content: center; }
  .chat-close-btn { display: inline-flex; }
  .chat-header strong { font-size: 0.95rem; }
  body.chat-open { overflow: hidden; }
}
.chat-scope {
  font-size: 0.78rem; color: var(--text-muted);
  padding: 0.15rem 0.55rem; border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.chat-focus-bar {
  padding: 0.55rem 0.7rem;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 0.85rem;
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
}
.chat-focus-bar[hidden] { display: none; }
.chat-focus-bar .focus-title { font-weight: 600; color: var(--text); }
.chat-focus-bar select {
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--input-border); border-radius: 0.3rem;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.85rem;
}
.chat-focus-bar .focus-clear {
  margin-left: auto;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border); border-radius: 0.3rem;
  background: transparent; color: var(--text-muted);
  font: inherit; font-size: 0.78rem; cursor: pointer;
}
.chat-focus-bar .focus-clear:hover { background: var(--surface); color: var(--text); }
.btn-chat {
  padding: 0.3rem 0.55rem;
  background: transparent; border: 1px solid var(--border);
  border-radius: 0.3rem; cursor: pointer; font-size: 0.95rem;
}
.btn-chat:hover { background: var(--accent-bg); border-color: var(--accent); }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.chat-mode-bar, .chat-chorus-bar {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  font-size: 0.9rem;
}
.chat-chorus-bar { background: var(--surface-alt); }
.chat-mode-bar label, .chat-chorus-bar label { display: inline-flex; align-items: center; gap: 0.4rem; }
.chat-mode-bar select, .chat-mode-bar input,
.chat-chorus-bar select, .chat-chorus-bar input {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--input-border);
  border-radius: 0.35rem;
  background: var(--surface); color: var(--text);
  font: inherit;
}

.chat-msg-chorus {
  align-self: flex-end;
  max-width: 80%;
  background: rgba(168, 85, 247, 0.08);
  border: 1px dashed rgba(168, 85, 247, 0.5);
  border-radius: 0.6rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
}
.chorus-head {
  margin-bottom: 0.3rem;
  color: #6b21a8;
  font-size: 0.82rem;
}
.chorus-from { color: var(--text-muted); font-weight: 400; }
.chorus-text { font-style: italic; line-height: 1.45; }
.chat-header button {
  background: transparent; border: 0;
  font-size: 1.1rem; cursor: pointer; color: var(--text-muted);
}
.chat-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 1rem;
}
.chat-help {
  color: var(--text-muted); font-size: 0.9rem;
  background: var(--surface-alt); padding: 0.7rem;
  border-radius: 0.4rem;
}
#chat-history { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 1rem; }
.chat-msg {
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem; max-width: 90%;
  white-space: pre-wrap; line-height: 1.5;
}
.chat-msg-user {
  align-self: flex-end;
  background: var(--accent); color: var(--accent-bg);
}
.chat-msg-assistant {
  align-self: flex-start;
  background: var(--surface-alt); color: var(--text);
  border: 1px solid var(--border);
}
.chat-text {
  line-height: 1.55;
}
.chat-text > *:first-child { margin-top: 0; }
.chat-text > *:last-child { margin-bottom: 0; }
.chat-text h2, .chat-text h3, .chat-text h4 {
  font-family: "Cormorant Garamond", Georgia, serif;
  margin: 0.9rem 0 0.4rem; line-height: 1.25;
  color: var(--accent);
}
.chat-text h2 { font-size: 1.25rem; }
.chat-text h3 { font-size: 1.1rem; }
.chat-text h4 { font-size: 1rem; font-weight: 600; }
.chat-text p { margin: 0.5rem 0; }
.chat-text strong { color: var(--text); }
.chat-text em { color: var(--text-muted); font-style: italic; }
.chat-text ul, .chat-text ol {
  margin: 0.4rem 0; padding-left: 1.2rem;
}
.chat-text li { margin: 0.15rem 0; }
.chat-text code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.88em;
  padding: 0.05em 0.35em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}
.chat-text .dlg {
  margin: 0.4rem 0 0.4rem 0.6rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--accent);
  color: var(--text);
}
.chat-text .cite-ref {
  display: inline-block;
  font-size: 0.7em;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 0 0.35em;
  border-radius: 999px;
  margin-left: 0.15em;
  font-weight: 600;
  vertical-align: super;
  line-height: 1.4;
}
.chat-text .cite-ref:hover { background: var(--accent); color: var(--accent-bg); }
.chat-sources {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}
.chat-source {
  display: inline-flex; gap: 0.3rem; align-items: baseline;
  padding: 0.3rem 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  text-decoration: none; color: var(--text);
  font-size: 0.78rem;
}
.chat-source-num { color: var(--accent); font-weight: 700; }
.chat-source-author { color: var(--text-muted); }
.chat-source:hover { background: var(--accent-bg); border-color: var(--accent); }
.chat-form {
  border-top: 1px solid var(--border);
  padding: 0.6rem;
  display: flex; gap: 0.5rem; align-items: flex-end;
  background: var(--surface-alt);
}
.chat-form textarea {
  flex: 1;
  padding: 0.6rem;
  border: 1px solid var(--input-border);
  border-radius: 0.4rem;
  font: inherit; resize: vertical;
  background: var(--surface); color: var(--text);
}
.chat-form button {
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-bg);
  font: inherit; font-weight: 600; cursor: pointer;
  font-size: 1.1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.chat-form button:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 4px 10px rgba(157,23,77,0.3); }
.chat-form button:disabled { opacity: 0.4; cursor: wait; transform: none; }

.ann-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.78rem;
  font-weight: 600;
  vertical-align: middle;
  border: 1px solid #fde047;
}
.src-mark {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.85rem; line-height: 1;
  cursor: help; user-select: none;
  opacity: 0.7;
  vertical-align: middle;
}
.src-mark:hover { opacity: 1; }
.src-gutenberg { color: #15803d; }
.src-internet_archive { color: #1d4ed8; }
.src-standard_ebooks { color: #6b21a8; }
.src-pratham { color: #db2777; }
.src-gdl { color: #ea580c; }
.src-annas { color: #64748b; }

.book-title-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dashed transparent;
  transition: border-color 200ms ease, color 200ms ease;
}
.book-title-link:hover {
  color: var(--brand-burgundy);
  border-bottom-color: var(--brand-pink);
}

.btn-email {
  display: inline-block;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 0.4rem;
  background: var(--accent-bg);
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
  white-space: nowrap;
}
.btn-email:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-bg);
}
.btn-email:disabled { opacity: 0.7; cursor: wait; }

.btn-download {
  display: inline-block;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 0.4rem;
  text-decoration: none;
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.btn-download:hover {
  background: var(--accent-hover);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 599px) {
  .app-shell {
    padding: 0.75rem;
  }

  #books,
  #books thead,
  #books tbody,
  #books tr,
  #books th,
  #books td {
    display: block;
    width: 100%;
  }

  #books thead {
    display: none;
  }

  #books tr {
    border-bottom: 1px solid var(--border);
    padding: 0.25rem 0;
  }

  #books td {
    border-bottom: 0;
    padding: 0.35rem 0.7rem;
  }
}

/* ---------- Modal "ingresar requerido" ---------- */
.lr-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.lr-modal[hidden] { display: none; }
body.lr-open { overflow: hidden; }
.lr-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.lr-card {
  position: relative; z-index: 1;
  width: min(440px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 1.8rem 1.6rem 1.4rem;
  text-align: center;
}
.lr-close {
  position: absolute; top: 8px; right: 10px;
  background: transparent; border: 0;
  font-size: 1.2rem; cursor: pointer;
  color: var(--text-muted); line-height: 1;
  width: 30px; height: 30px; border-radius: 50%;
}
.lr-close:hover { background: var(--surface-alt); color: var(--text); }
.lr-icon { font-size: 2.4rem; margin-bottom: 0.4rem; }
.lr-card h2 {
  margin: 0 0 0.6rem;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.4rem; line-height: 1.25;
  color: var(--accent);
}
.lr-msg {
  margin: 0 0 0.6rem;
  color: var(--text-muted);
  font-size: 0.92rem; line-height: 1.55;
}
.lr-book {
  margin: 0.6rem 0 1.1rem;
  font-style: italic;
  color: var(--text);
  font-size: 0.88rem;
}
.lr-actions {
  display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap;
}
.lr-btn {
  flex: 1 1 auto; min-width: 140px;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600; font-size: 0.95rem;
  border: 1px solid var(--accent);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.lr-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(157,23,77,0.18); }
.lr-btn-primary { background: var(--accent); color: var(--accent-bg); }
.lr-btn-secondary { background: transparent; color: var(--accent); }

.chat-progress {
  display: inline-block;
  font-size: 0.92rem;
  color: var(--text-muted);
  font-style: italic;
  font-variant-numeric: tabular-nums;
}
.chat-progress.cache {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Paginación numerada ---------- */
.page-info {
  display: inline-flex; align-items: center; gap: 0.25rem;
  flex-wrap: wrap; justify-content: center;
}
.page-num {
  min-width: 2.2em; padding: 0.35rem 0.55rem;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 0.4rem;
  font: inherit; cursor: pointer;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.page-num:hover {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--accent);
}
.page-current {
  min-width: 2.2em; padding: 0.4rem 0.7rem;
  background: var(--accent); color: var(--accent-bg);
  border: 1px solid var(--accent); border-radius: 0.4rem;
  font-weight: 700;
  cursor: default;
  box-shadow: 0 2px 8px rgba(157,23,77,0.25);
}
.page-sep {
  color: var(--text-muted); padding: 0 0.2rem; user-select: none;
}
/* Las flechas (anterior/siguiente) más chicas para que no compitan con la pág actual */
.pagination .page-btn {
  min-width: 2em; padding: 0.35rem 0.55rem;
  font-size: 1.1rem; line-height: 1;
}

/* ---------- Selector de modo de búsqueda ---------- */
.search-mode-bar {
  display: flex; gap: 0.3rem; flex-wrap: wrap;
  margin-right: 0.4rem;
}
.search-mode {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--input-border); border-radius: 999px;
  background: var(--surface); color: var(--text-muted);
  font: inherit; font-size: 0.85rem; cursor: pointer;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.search-mode:hover { background: var(--surface-alt); color: var(--text); }
.search-mode.active {
  background: var(--accent); color: var(--accent-bg);
  border-color: var(--accent);
  font-weight: 600;
}

/* ---------- Botón "libros similares" + badge personaje ---------- */
.btn-similar {
  padding: 0.3rem 0.55rem;
  background: transparent; border: 1px solid var(--border);
  border-radius: 0.3rem; cursor: pointer; font-size: 0.95rem;
}
.btn-similar:hover { background: var(--accent-bg); border-color: var(--accent); }

.char-match-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.12);
  color: #6b21a8;
  border: 1px solid rgba(168, 85, 247, 0.4);
  font-size: 0.75rem; font-weight: 600;
  vertical-align: middle;
}

/* ---------- Modal "libros similares" (extiende lr-modal) ---------- */
.sim-card { max-width: 540px; text-align: left; padding: 1.4rem 1.4rem 1.2rem; }
.sim-card h2 { margin: 0 0 0.4rem; font-size: 1.2rem; }
.sim-source {
  margin: 0 0 1rem;
  color: var(--text-muted); font-size: 0.9rem;
}
.sim-source em { color: var(--text); font-style: italic; }
.sim-list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 60vh; overflow-y: auto; }
.sim-row {
  display: flex; gap: 0.7rem; align-items: center;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border); border-radius: 0.4rem;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.sim-row:hover { background: var(--surface-alt); border-color: var(--accent); }
.sim-score {
  flex: 0 0 auto;
  padding: 0.25rem 0.5rem;
  background: var(--accent-bg); color: var(--accent);
  border-radius: 999px; font-weight: 600; font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  min-width: 2.8em; text-align: center;
}
.sim-meta { flex: 1; min-width: 0; }
.sim-title-line {
  font-weight: 600; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sim-author { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }
