/* Biblioteca home: isolated bookshelf component (no dependency on app/theme CSS).
   All selectors are prefixed with .bib-shelf-* to avoid collisions. */

.bib-page-title-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.bib-page-settings {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, color .12s ease;
}
.bib-page-settings:hover {
  transform: translateY(-1px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.bib-shelf-wrap {
  width: 100%;
  border-radius: 16px;
  /* Local tokens (keep this component isolated from the app theme variables). */
  --bib-border: rgba(0,0,0,.08);
  --bib-bg: radial-gradient(1200px 260px at 50% 0%, rgba(250,250,250,.94), rgba(233,233,233,.92));
  --bib-shadow: 0 14px 40px rgba(0,0,0,.08);
  --bib-text: #0b0b0b;
  --bib-muted: rgba(0,0,0,.55);
  --bib-surface: #f4f4f4;
  --bib-surface-2: #ededed;
  --bib-ink: rgba(0,0,0,.68);
  --bib-ink-2: rgba(0,0,0,.76);
  --bib-book-border: rgba(0,0,0,.06);
  --bib-book-bg: linear-gradient(180deg, #ffffff, #f3f3f3);
  --bib-book-shadow: 0 14px 30px rgba(0,0,0,.10);
  --bib-scroll-thumb: rgba(0,0,0,.16);

  border: 1px solid var(--bib-border);
  overflow: hidden;
  background: var(--bib-bg);
  box-shadow: var(--bib-shadow);
}

[data-theme="dark"] .bib-shelf-wrap {
  --bib-border: rgba(255,255,255,.10);
  --bib-bg: radial-gradient(1200px 260px at 50% 0%, rgba(30,30,30,.96), rgba(16,16,16,.94));
  --bib-shadow: 0 22px 90px rgba(0,0,0,.55);
  --bib-text: rgba(255,255,255,.92);
  --bib-muted: rgba(255,255,255,.62);
  --bib-surface: #1b1b1b;
  --bib-surface-2: #151515;
  --bib-ink: rgba(255,255,255,.72);
  --bib-ink-2: rgba(255,255,255,.78);
  --bib-book-border: rgba(255,255,255,.10);
  --bib-book-bg: linear-gradient(180deg, rgba(255,255,255,.92), rgba(235,235,235,.86));
  --bib-book-shadow: 0 18px 50px rgba(0,0,0,.42);
  --bib-scroll-thumb: rgba(255,255,255,.14);
}

[data-theme="light"] .bib-shelf-wrap,
:root:not([data-theme="dark"]) .bib-shelf-wrap {
  background: var(--bib-bg);
}

[data-theme="dark"] .bib-book-ico {
  color: rgba(0,0,0,.55);
}

.bib-shelf-head {
  padding: 16px 18px 8px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 12px;
}

.bib-shelf-title {
  font-weight: 900;
  letter-spacing: .01em;
  color: var(--bib-text);
  font-size: 18px;
  line-height: 1.1;
}

.bib-shelf-sub {
  color: var(--bib-muted);
  font-size: 12px;
  font-weight: 700;
}

.bib-shelf-stage {
  position: relative;
  padding: 12px 18px 22px 18px;
}

.bib-shelf-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.bib-plank--mid {
  margin-top: 0;
  margin-bottom: 14px;
  opacity: 1;
}

.bib-shelf-layout {
  display: grid;
  /* 50/50 split between shelf (left) and welcome/preview (right). */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}
@media (max-width: 1100px) {
  .bib-shelf-layout {
    grid-template-columns: 1fr;
  }
}
.bib-shelf-left {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* Bookends (inline, part of the row so layout doesn't "float") */
[data-bib-shelf] .bib-bookend-inline {
  flex: 0 0 98px;
  width: 98px;
  height: 126px;
  align-self: flex-end;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center bottom;
  pointer-events: none;
  user-select: none;
  opacity: 0.98;
}
[data-bib-shelf] .bib-bookend-inline[data-side="left"] {
  margin-right: 0;
  /* Hug the books: many "left" PNGs are drawn near the right edge. */
  background-position: right bottom;
}
[data-bib-shelf] .bib-bookend-inline[data-side="right"] {
  margin-left: 12px;
  /* Hug the books: many "right" PNGs are drawn near the left edge. */
  background-position: left bottom;
}
[data-bib-shelf] .bib-bookend-inline--left {
  background-image: url("../img/sujetalibros/girego_01_izquierdo.png");
  margin-right: 0;
}
[data-bib-shelf] .bib-bookend-inline--right {
  background-image: url("../img/sujetalibros/girego_01_derecho.png");
  margin-left: 0;
}

/* Decoracion (inline, sits on the same shelf row as books/bookends) */
[data-bib-shelf] .bib-deco-inline {
  flex: 0 0 auto;
  width: auto;
  height: 100%;
  /* Match the shelf row height so the decoration can use full vertical space. */
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  user-select: none;
  opacity: 0.98;
}
[data-bib-shelf] .bib-deco-inline img {
  display: block;
  height: 100%;
  width: auto; /* preserve aspect ratio, no cropping */
}
[data-bib-shelf] .bib-deco-inline[data-side="left"] {
  margin-right: 0;
  justify-content: flex-end;
}
[data-bib-shelf] .bib-deco-inline[data-side="right"] {
  margin-left: 10px;
  justify-content: flex-start;
}

@media (max-width: 1100px) {
  [data-bib-shelf] .bib-bookend-inline[data-side="right"] { margin-left: 6px; }
  [data-bib-shelf] .bib-deco-inline[data-side="right"] { margin-left: 6px; }
}

@media (max-width: 980px) {
  [data-bib-shelf] .bib-bookend-inline { display: none; }
  [data-bib-shelf] .bib-deco-inline { display: none; }
}

/* Tablet tuning: reduce welcome scale to avoid overlap/interposition in iPad widths. */
@media (max-width: 1100px) {
  .bib-preview {
    min-height: 150px;
    gap: 10px;
  }
  .bib-preview-title {
    font-size: 22px;
    line-height: 1.12;
  }
  .bib-preview-desc {
    font-size: 16px;
    line-height: 1.32;
  }
}

/* Settings button (top-right of shelf widget) */
[data-bib-shelf] .bib-shelf-head {
  align-items: center;
}
[data-bib-shelf] .bib-shelf-settings {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: rgba(0,0,0,.70);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, opacity .12s ease;
}
[data-theme="dark"] [data-bib-shelf] .bib-shelf-settings {
  color: rgba(255,255,255,.80);
}
[data-bib-shelf] .bib-shelf-settings:hover {
  transform: translateY(-1px);
  background: rgba(0,0,0,.05);
}
[data-theme="dark"] [data-bib-shelf] .bib-shelf-settings:hover {
  background: rgba(255,255,255,.08);
}

/* Settings modal (isolated, only for Consultas shelf) */
.bib-settings-modal[hidden] { display: none; }
.bib-settings-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}
.bib-settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}
.bib-settings-panel {
  position: relative;
  width: min(900px, 96vw);
  max-height: 86vh;
  overflow: hidden;
  background: var(--bg-secondary, #fff);
  border: 1px solid var(--border-color, rgba(0,0,0,.10));
  border-radius: 14px;
  box-shadow: 0 20px 80px rgba(0,0,0,.30);
  display: flex;
  flex-direction: column;
}
.bib-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,.10));
  background: var(--bg-tertiary, rgba(0,0,0,.03));
}
.bib-settings-title {
  font-weight: 900;
  color: var(--text-primary, #111);
}
.bib-settings-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-secondary, rgba(0,0,0,.65));
  cursor: pointer;
}
.bib-settings-close:hover {
  background: rgba(0,0,0,.05);
}
[data-theme="dark"] .bib-settings-close:hover {
  background: rgba(255,255,255,.08);
}
.bib-settings-body {
  padding: 14px;
  overflow: auto;
}

/* Tabs (settings modal) */
.bib-tabs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bib-tabs-nav {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border-color, rgba(0,0,0,.10));
  border-radius: 12px;
  background: rgba(255,255,255,.55);
}
[data-theme="dark"] .bib-tabs-nav {
  background: rgba(0,0,0,.22);
  border-color: rgba(255,255,255,.12);
}
.bib-tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 900;
  color: var(--text-secondary, rgba(0,0,0,.70));
  cursor: pointer;
  transition: background .12s ease, color .12s ease, transform .12s ease;
  white-space: nowrap;
}
[data-theme="dark"] .bib-tab {
  color: rgba(255,255,255,.75);
}
.bib-tab:hover {
  background: rgba(0,0,0,.05);
}
[data-theme="dark"] .bib-tab:hover {
  background: rgba(255,255,255,.08);
}
.bib-tab.is-active,
.bib-tab[aria-selected="true"] {
  background: rgba(0,0,0,.08);
  color: var(--text-primary, rgba(0,0,0,.92));
}
[data-theme="dark"] .bib-tab.is-active,
[data-theme="dark"] .bib-tab[aria-selected="true"] {
  background: rgba(255,255,255,.10);
  color: rgba(255,255,255,.92);
}
.bib-tabs-panels {
  border: 1px solid var(--border-color, rgba(0,0,0,.10));
  border-radius: 12px;
  background: rgba(255,255,255,.35);
  padding: 12px;
}
[data-theme="dark"] .bib-tabs-panels {
  background: rgba(0,0,0,.16);
  border-color: rgba(255,255,255,.10);
}
.bib-tab-panel[hidden] { display: none; }
.bib-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 780px) {
  .bib-settings-grid { grid-template-columns: 1fr; }
}
.bib-settings-subtitle {
  font-size: 12px;
  font-weight: 900;
  color: var(--text-secondary, rgba(0,0,0,.65));
  margin-bottom: 8px;
}
.bib-settings-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 780px) {
  .bib-settings-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.bib-settings-opt {
  position: relative;
  border: 1px solid var(--border-color, rgba(0,0,0,.10));
  border-radius: 12px;
  background: var(--bg-primary, #fff);
  padding: 10px 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 110px;
}
.bib-settings-opt:hover {
  border-color: rgba(0,0,0,.18);
  transform: translateY(-1px);
}
.bib-settings-opt input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.bib-settings-thumb {
  width: 100%;
  height: 72px;
  border-radius: 10px;
  border: 1px dashed rgba(0,0,0,.12);
  background: rgba(0,0,0,.03);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
[data-theme="dark"] .bib-settings-thumb {
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
}
.bib-settings-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.bib-settings-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-primary, #111);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bib-settings-opt.is-selected {
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.bib-settings-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-color, rgba(0,0,0,.10));
  background: var(--bg-tertiary, rgba(0,0,0,.03));
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.bib-shelf-right {
  position: relative;
}

.bib-shelf-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 1px;
  min-height: 140px;
  /* Keep books sitting on the plank; avoid a "floating" gap. */
  padding-bottom: 0;
  overflow: visible; /* avoid clipping right-side bookend/deco on tablet widths */
}

/* (Scrollbar styles removed; row should not scroll) */

.bib-book {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  border-radius: 10px 10px 6px 6px;
  background: var(--bib-book-bg);
  border: 1px solid var(--bib-book-border);
  box-shadow: var(--bib-book-shadow);
  cursor: pointer;
  transform-origin: bottom center;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  user-select: none;
}

/* Flat, illustrated books (Biblioteca home only). Keep Manage Dashboard binders unaffected. */
[data-bib-shelf] .bib-book.bib-v0 { --bib-book-a: #0f766e; --bib-book-b: #115e59; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v1 { --bib-book-a: #d97706; --bib-book-b: #b45309; --bib-book-ink: rgba(0,0,0,.82); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v2 { --bib-book-a: #7c3aed; --bib-book-b: #9333ea; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v3 { --bib-book-a: #16a34a; --bib-book-b: #15803d; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v4 { --bib-book-a: #dc2626; --bib-book-b: #b91c1c; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v5 { --bib-book-a: #0f172a; --bib-book-b: #1f2937; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v6 { --bib-book-a: #0891b2; --bib-book-b: #0e7490; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v7 { --bib-book-a: #db2777; --bib-book-b: #be185d; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v8 { --bib-book-a: #2563eb; --bib-book-b: #1d4ed8; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v9 { --bib-book-a: #4338ca; --bib-book-b: #3730a3; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v10 { --bib-book-a: #65a30d; --bib-book-b: #4d7c0f; --bib-book-ink: rgba(0,0,0,.82); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v11 { --bib-book-a: #7c2d12; --bib-book-b: #9a3412; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v12 { --bib-book-a: #374151; --bib-book-b: #1f2937; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v13 { --bib-book-a: #6d28d9; --bib-book-b: #5b21b6; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v14 { --bib-book-a: #047857; --bib-book-b: #065f46; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }
[data-bib-shelf] .bib-book.bib-v15 { --bib-book-a: #be123c; --bib-book-b: #9f1239; --bib-book-ink: rgba(255,255,255,.92); --bib-book-radius: 4px 4px 3px 3px; }

[data-bib-shelf] .bib-book[class*="bib-v"] {
  border-radius: var(--bib-book-radius, 8px 8px 6px 6px);
  border-color: rgba(0,0,0,.08);
  box-shadow: none;
  /* Flat color (no gradients). */
  background: var(--bib-book-a, #111827);
  overflow: hidden;
}

[data-theme="dark"] [data-bib-shelf] .bib-book[class*="bib-v"] {
  border-color: rgba(255,255,255,.14);
  box-shadow: none;
}

/* Tone down the "neon" look: add a subtle dim overlay behind the spine text/icon. */
[data-bib-shelf] .bib-book[class*="bib-v"]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  background: rgba(0,0,0,.12);
}
[data-theme="dark"] [data-bib-shelf] .bib-book[class*="bib-v"]::after {
  background: rgba(0,0,0,.22);
}
[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine {
  position: absolute;
  z-index: 2;
}

[data-bib-shelf] .bib-book[class*="bib-v"]::before {
  /* Disable highlights: keep it flat. */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: none;
  opacity: 0;
  pointer-events: none;
}

/* Calmer hover for the Biblioteca books */
[data-bib-shelf] .bib-book[class*="bib-v"]:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 18px rgba(0,0,0,.14);
}
[data-theme="dark"] [data-bib-shelf] .bib-book[class*="bib-v"]:hover {
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
}

.bib-book:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 22px rgba(0,0,0,.14);
  border-color: rgba(0,0,0,.10);
}
[data-theme="dark"] .bib-book:hover {
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
  border-color: rgba(255,255,255,.14);
}

.bib-book:active { transform: translateY(0px) scale(.99); }

/* Leaning book: keep it "reclined" without overlapping the neighbor. */
.bib-book.is-lean {
  /* Lean into the previous book so it looks "resting" instead of floating. */
  transform: translateX(16px) translateY(1px) rotate(-10deg);
  transform-origin: 40% 100%;
  margin-left: 14px;
  z-index: 3;
}
.bib-book.is-lean:hover { transform: translateX(16px) translateY(-5px) rotate(-10deg); }

.bib-book::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(0,0,0,.10), rgba(0,0,0,0) 18%);
  pointer-events: none;
  opacity: .55;
}

.bib-book-spine {
  position: absolute;
  inset: 10px 8px 10px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
}

[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine {
  gap: 12px;
}

/* Separator line between icon and title (Biblioteca shelf only). */
[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine {
  gap: 10px;
}
[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine-sep {
  width: 14px;
  height: 1px;
  background: rgba(255,255,255,.35);
  flex: 0 0 auto;
}

[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine {
  /* Inner label panel: keep it "fit" but not tight to the title. */
  inset: 0 9px 0 9px;
  padding: 0;
  border-radius: 0;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: none;
}
[data-theme="dark"] [data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine {
  background: rgba(0,0,0,.18);
  border-color: rgba(255,255,255,.14);
}

[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine::before,
[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine::after {
  content: none;
}
[data-theme="dark"] [data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine::before,
[data-theme="dark"] [data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine::after {
  content: none;
}

.bib-book-spine-text {
  /* keep existing vertical writing, but let variants control ink color */
  color: rgba(0,0,0,.70);
}
[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine-text {
  color: var(--bib-book-ink, rgba(0,0,0,.74));
  font-weight: 950;
  letter-spacing: .08em;
  max-height: 124px;
}

[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-spine-text br {
  line-height: 1;
}

.bib-book-ico {
  font-size: 14px;
  color: rgba(0,0,0,.46);
  opacity: .9;
  display: inline-block;
  /* Rotate icons to align with the vertical spine title. */
  transform: rotate(-90deg);
  transform-origin: center;
}

/* Make FA icon match the spine text color (Biblioteca shelf only). */
[data-bib-shelf] .bib-book[class*="bib-v"] .bib-book-ico {
  color: rgba(0, 0, 0, 0.30);
  opacity: 1;
}

.bib-book-spine-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  color: rgba(0,0,0,.70);
  text-transform: uppercase;
  max-height: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Allow wrap by splitting on spaces; JS may also insert <br> when needed. */
  white-space: normal;
  word-break: break-word;
  line-height: 1.15;
  text-align: center;
}

[data-bib-shelf] .bib-book-spine-text {
  /* Slightly smaller on the shelf to fit 2-line titles. */
  font-size: 10px;
  text-align: center;
}

[data-bib-shelf] .bib-book-spine-text .bib-spine-line {
  display: block;
  text-align: center;
}

/* Second line a bit smaller when the title is split on whitespace. */
[data-bib-shelf] .bib-book-spine-text .bib-spine-line--2 {
  font-size: 0.88em;
  letter-spacing: .05em;
  opacity: .92;
}

/* Right-side preview (occupies the empty area to the right) */
.bib-preview {
  height: 100%;
  min-height: 170px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 6px 2px;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bib-preview.is-empty {
  opacity: .92;
}
.bib-preview.is-empty .bib-preview-count {
  display: none;
}
.bib-preview-title {
  font-weight: 950;
  font-size: 28px;
  line-height: 1.1;
  color: var(--bib-text);
  min-width: 0;
}
.bib-preview-desc {
  color: var(--bib-muted);
  font-size: 22px;
  line-height: 1.35;
  font-weight: 500;
}

.bib-preview-recent {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 54px;
}
[data-theme="dark"] .bib-preview-recent {
  border-top-color: rgba(255,255,255,.10);
}

.bib-preview-recent-title {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--bib-muted);
}

.bib-preview-recent-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--bib-ink);
}
.bib-preview-recent-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bib-preview-recent-item time {
  flex: 0 0 auto;
  color: var(--bib-muted);
  font-variant-numeric: tabular-nums;
}

.bib-preview-title,
.bib-preview-desc,
.bib-preview-count {
  transition: opacity .18s ease, transform .22s ease;
}

.bib-preview.is-out .bib-preview-title,
.bib-preview.is-out .bib-preview-desc,
.bib-preview.is-out .bib-preview-count {
  opacity: 0;
  transform: translateY(2px);
}

.bib-preview.is-anim .bib-preview-title,
.bib-preview.is-anim .bib-preview-desc,
.bib-preview.is-anim .bib-preview-count {
  animation: bibPreviewIn 260ms cubic-bezier(.2,.9,.2,1);
}

@keyframes bibPreviewIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.bib-preview-desc.is-typing::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 1.1em;
  margin-left: 2px;
  border-right: 2px solid rgba(0,0,0,.55);
  opacity: .6;
  animation: bibCaretBlink 900ms steps(2) infinite;
  vertical-align: text-bottom;
}
[data-theme="dark"] .bib-preview-desc.is-typing::after {
  border-right-color: rgba(255,255,255,.55);
}

@keyframes bibCaretBlink {
  0%, 49% { opacity: .2; }
  50%, 100% { opacity: .75; }
}

@media (prefers-reduced-motion: reduce) {
  .bib-preview-title,
  .bib-preview-desc,
  .bib-preview-count {
    transition: none;
  }
  .bib-preview.is-anim .bib-preview-title,
  .bib-preview.is-anim .bib-preview-desc,
  .bib-preview.is-anim .bib-preview-count {
    animation: none;
  }
  .bib-preview-desc.is-typing::after {
    animation: none;
  }
}
.bib-preview-count {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 999px;
  padding: 10px 14px;
  border: 1px solid var(--bib-border);
  background: rgba(255,255,255,.55);
  color: var(--bib-text);
  font-weight: 950;
  font-size: 14px;
}
[data-theme="dark"] .bib-preview-count {
  background: rgba(0,0,0,.18);
}

/* keep legacy flyout classes for other nodes used by overlay (no-op here) */
.bib-fly-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bib-plank {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  margin-top: 0;
  height: 14px;
  border-radius: 10px;
  background: rgba(0,0,0,.10);
  border: 1px solid var(--bib-border);
  box-shadow: none;
}
[data-theme="dark"] .bib-plank {
  background: rgba(255,255,255,.06);
  box-shadow: none;
}

/* Open overlay (book "opens") */
.bib-shelf-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  z-index: 10040;
}

.bib-shelf-overlay.is-open { display: flex; }

.bib-shelf-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.52);
}

.bib-opened {
  position: relative;
  width: min(980px, 96vw);
  background: var(--bib-surface-2);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 30px 120px rgba(0,0,0,.45);
  overflow: hidden;
}

.bib-opened-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px 16px;
  border-bottom: 1px solid var(--bib-border);
  background: var(--bib-surface);
}

.bib-opened-kicker {
  color: var(--bib-muted);
  font-size: 12px;
  font-weight: 800;
}
.bib-opened-title {
  color: var(--bib-text);
  font-size: 18px;
  font-weight: 950;
  line-height: 1.2;
}
.bib-opened-meta {
  margin-top: 4px;
  color: var(--bib-muted);
  font-size: 12px;
  font-weight: 700;
}

.bib-opened-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--bib-border);
  background: var(--bib-surface);
  color: var(--bib-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
.bib-opened-close:hover { background: var(--bib-surface-2); }
.bib-opened-close:active { transform: translateY(1px); }

.bib-opened-body {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 760px) {
  .bib-opened-body { grid-template-columns: 1fr; }
}

.bib-page {
  background: var(--bib-surface);
  border: 1px solid var(--bib-border);
  border-radius: 14px;
  padding: 14px 14px;
  min-height: 230px;
  position: relative;
  overflow: hidden;
}
.bib-page::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 64px;
  height: 100%;
  background: linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,.03));
  pointer-events: none;
}
[data-theme="dark"] .bib-page::after {
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.06));
}

.bib-page h6 {
  margin: 0 0 8px 0;
  font-size: 12px;
  font-weight: 950;
  color: var(--bib-ink-2);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.bib-page p {
  margin: 0;
  color: var(--bib-ink);
  font-size: 13px;
  line-height: 1.45;
}

.bib-opened-actions {
  padding: 0 16px 16px 16px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.bib-opened-actions a,
.bib-opened-actions button {
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 900;
  font-size: 12px;
  border: 1px solid var(--bib-border);
  background: var(--bib-surface);
  color: var(--bib-ink);
  cursor: pointer;
  text-decoration: none;
}
.bib-opened-actions a.bib-primary {
  background: var(--bib-text);
  color: var(--bib-surface);
  border-color: var(--bib-text);
}
.bib-opened-actions a:hover,
.bib-opened-actions button:hover { background: var(--bib-surface-2); }
.bib-opened-actions a.bib-primary:hover { background: rgba(0,0,0,.88); }
[data-theme="dark"] .bib-opened-actions a.bib-primary:hover { background: rgba(255,255,255,.92); color: #000; border-color: rgba(255,255,255,.92); }
