/* ═══ Anchor HQ — Library Section (The Archives) ═══ */
/* Stardew Valley Bookshelf / Archives Theme */

/* ── Keyframes ── */
@keyframes pageFlutter {
  0%, 100% { transform: rotateY(0deg); }
  50% { transform: rotateY(2deg); }
}

@keyframes archiveGlow {
  0%, 100% { box-shadow: inset 0 0 12px rgba(218,165,32,0.05); }
  50% { box-shadow: inset 0 0 20px rgba(218,165,32,0.12); }
}

@keyframes searchPulse {
  0%, 100% { border-color: var(--border); }
  50% { border-color: rgba(218,165,32,0.35); }
}

/* ── Main Layout — Wooden bookshelf frame ── */
.library-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  height: calc(100vh - 140px);
  min-height: 400px;
  border: 3px solid var(--wood, #6b4423);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(107,68,35,0.3),
    0 4px 16px rgba(0,0,0,0.3),
    0 1px 0 rgba(107,68,35,0.5);
  image-rendering: pixelated;
}

/* ── Reader Mode — Full-screen reading experience ── */
.library-layout.reader-mode {
  grid-template-columns: 1fr;
}

.library-layout.reader-mode .library-sidebar {
  display: none;
}

/* ── Sidebar — Bookshelf panel ── */
.library-sidebar {
  min-height: 0;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0px,
      transparent 48px,
      rgba(107,68,35,0.12) 48px,
      rgba(107,68,35,0.12) 50px
    ),
    linear-gradient(180deg, var(--panel) 0%, rgba(42,28,12,0.95) 100%);
  border-right: 3px solid var(--wood, #6b4423);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Wood grain texture overlay on sidebar */
.library-sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 2px,
      rgba(107,68,35,0.03) 2px,
      rgba(107,68,35,0.03) 4px
    );
  pointer-events: none;
  z-index: 0;
}

.library-sidebar > * {
  position: relative;
  z-index: 1;
}

/* ── Sidebar Header — Archive label ── */
.library-sidebar-header {
  padding: 14px 16px;
  border-bottom: 2px solid var(--wood, #6b4423);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(107,68,35,0.15) 0%, transparent 100%);
}

.library-sidebar-header h3 {
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: 8px;
  font-family: var(--font-pixel);
  letter-spacing: .03em;
  color: var(--gold-bright, #f0c040);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* Decorative book icon before header */
.library-sidebar-header h3::before {
  content: '\1F4DA';
  margin-right: 6px;
  font-size: .7rem;
  image-rendering: pixelated;
}

/* ── Search — Archive search with magnifying glass ── */
.library-search {
  width: 100%;
  padding: 8px 12px 8px 30px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Crect x='2' y='2' width='2' height='2' fill='%238a7a6a'/%3E%3Crect x='4' y='0' width='4' height='2' fill='%238a7a6a'/%3E%3Crect x='0' y='4' width='2' height='4' fill='%238a7a6a'/%3E%3Crect x='8' y='2' width='2' height='2' fill='%238a7a6a'/%3E%3Crect x='10' y='4' width='2' height='2' fill='%238a7a6a'/%3E%3Crect x='10' y='6' width='2' height='2' fill='%238a7a6a'/%3E%3Crect x='8' y='8' width='2' height='2' fill='%238a7a6a'/%3E%3Crect x='4' y='10' width='4' height='2' fill='%238a7a6a'/%3E%3Crect x='2' y='8' width='2' height='2' fill='%238a7a6a'/%3E%3Crect x='10' y='10' width='2' height='2' fill='%238a7a6a'/%3E%3Crect x='12' y='12' width='2' height='2' fill='%238a7a6a'/%3E%3C/svg%3E")
    8px center / 14px 14px no-repeat,
    var(--panel-soft);
  color: var(--text);
  font-size: .75rem;
  font-family: inherit;
  outline: none;
  margin-bottom: 8px;
  transition: all 250ms;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}

.library-search::placeholder {
  color: var(--muted);
  font-style: italic;
  opacity: 0.7;
}

.library-search:focus {
  border-color: var(--gold);
  background-color: rgba(218,165,32,0.04);
  box-shadow:
    inset 0 1px 3px rgba(0,0,0,0.15),
    0 0 0 2px rgba(218,165,32,0.12);
  animation: searchPulse 2s ease-in-out infinite;
  animation-play-state: paused;
}

/* ── Category Filters — Bookshelf genre tabs ── */
.library-category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.library-category-btn {
  padding: 4px 8px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 180ms;
  position: relative;
  image-rendering: pixelated;
}

.library-category-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 3px;
  background: var(--muted);
  opacity: 0.2;
  border-radius: 0 1px 1px 0;
  transition: opacity 180ms;
}

.library-category-btn:hover::before,
.library-category-btn.active::before {
  opacity: 0.8;
  background: var(--gold-bright, #f0c040);
}

.library-category-btn:hover,
.library-category-btn.active {
  background: var(--gold-soft, rgba(218,165,32,0.15));
  color: var(--gold-bright, #f0c040);
  border-color: var(--border-accent);
  box-shadow: 0 1px 4px rgba(218,165,32,0.1);
}

.library-category-btn.new {
  background: rgba(108,191,74,0.08);
  border-color: rgba(108,191,74,0.2);
  color: var(--green);
}

.library-category-btn.new::before {
  background: var(--green);
  opacity: 0.5;
}

.library-category-btn.new:hover {
  background: rgba(108,191,74,0.15);
}

/* ── Bulk Actions ── */
.library-bulk-actions {
  display: none;
  padding: 8px;
  background: var(--panel-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  gap: 6px;
  align-items: center;
  border: 1px dashed var(--border-accent);
}

.library-bulk-actions.show { display: flex; }

.library-bulk-select {
  font-size: .68rem;
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: .45rem;
}

.library-move-select {
  padding: 3px 8px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: .68rem;
  font-family: inherit;
  outline: none;
}

.library-move-btn {
  padding: 3px 10px;
  border-radius: 2px;
  border: 1px solid var(--border-accent);
  background: var(--gold-soft, rgba(218,165,32,0.15));
  color: var(--gold-bright, #f0c040);
  font-size: .68rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* ── Document List — Book shelf rows ── */
.library-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--wood, #6b4423) transparent;
}

.library-list::-webkit-scrollbar { width: 6px; }
.library-list::-webkit-scrollbar-track { background: transparent; }
.library-list::-webkit-scrollbar-thumb {
  background: var(--wood, #6b4423);
  border-radius: 0;
  image-rendering: pixelated;
}

/* ── Group Titles — Bookshelf section labels ── */
.library-group-title {
  font-family: var(--font-pixel);
  font-size: .5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gold-bright, #f0c040);
  padding: 12px 16px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Decorative shelf line under group title */
.library-group-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--wood, #6b4423) 0px,
      var(--wood, #6b4423) 4px,
      transparent 4px,
      transparent 8px
    );
  opacity: 0.5;
}

/* Pixel book icon before group title */
.library-group-title::before {
  content: '\1F4D6';
  font-size: .6rem;
  image-rendering: pixelated;
}

/* ── Document Items — Book spines ── */
.library-doc-item {
  padding: 10px 16px;
  cursor: pointer;
  transition: all 180ms;
  border-left: 4px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  position: relative;
  margin: 1px 6px;
  border-radius: 0 2px 2px 0;
}

/* Book spine color by category — uses nth-child for variety */
.library-doc-item:nth-child(5n+1) { border-left-color: rgba(180,80,80,0.6); }
.library-doc-item:nth-child(5n+2) { border-left-color: rgba(80,120,180,0.6); }
.library-doc-item:nth-child(5n+3) { border-left-color: rgba(108,160,74,0.6); }
.library-doc-item:nth-child(5n+4) { border-left-color: rgba(180,140,60,0.6); }
.library-doc-item:nth-child(5n+5) { border-left-color: rgba(140,90,160,0.6); }

.library-doc-item:hover {
  background: rgba(218,165,32,0.06);
  border-left-width: 5px;
  padding-left: 15px;
}

.library-doc-item:hover:nth-child(5n+1) { border-left-color: rgba(180,80,80,0.9); }
.library-doc-item:hover:nth-child(5n+2) { border-left-color: rgba(80,120,180,0.9); }
.library-doc-item:hover:nth-child(5n+3) { border-left-color: rgba(108,160,74,0.9); }
.library-doc-item:hover:nth-child(5n+4) { border-left-color: rgba(180,140,60,0.9); }
.library-doc-item:hover:nth-child(5n+5) { border-left-color: rgba(140,90,160,0.9); }

.library-doc-item.active {
  background: var(--gold-soft, rgba(218,165,32,0.15));
  border-left-color: var(--gold) !important;
  border-left-width: 5px;
  padding-left: 15px;
  box-shadow: inset 0 0 12px rgba(218,165,32,0.08);
}

/* Subtle page edge effect on active item */
.library-doc-item.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(218,165,32,0.2) 0px,
      rgba(218,165,32,0.2) 2px,
      transparent 2px,
      transparent 4px
    );
}

.library-doc-checkbox {
  width: 14px;
  height: 14px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.library-doc-content {
  flex: 1;
  min-width: 0;
}

.library-doc-title {
  font-size: .78rem;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-doc-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .65rem;
  color: var(--muted);
}

.library-doc-tag {
  font-size: .62rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 2px;
  image-rendering: pixelated;
}

/* ── Viewer — Open book / parchment reading area ── */
.library-viewer {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(218,165,32,0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(107,68,35,0.03) 0%, transparent 50%),
    linear-gradient(180deg, rgba(45,32,18,0.02) 0%, rgba(30,22,12,0.05) 100%),
    var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* Subtle parchment edge effect */
.library-viewer::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(90deg, rgba(107,68,35,0.08) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* ── Viewer Header — Book title page ── */
.library-viewer-header {
  padding: 18px 24px 18px 36px;
  border-bottom: 2px solid var(--wood, #6b4423);
  background:
    linear-gradient(180deg, rgba(107,68,35,0.06) 0%, transparent 100%),
    var(--panel);
  flex-shrink: 0;
  position: relative;
}

/* Decorative corner flourish */
.library-viewer-header::after {
  content: '\2736';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  opacity: 0.15;
  font-size: 1.5rem;
}

.library-viewer-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: .01em;
}

/* Reader mode: normal font for title, better typography */
.library-layout.reader-mode .library-viewer-header h2 {
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

/* Reader mode: centered header content */
.library-layout.reader-mode .library-viewer-header {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 48px;
}

/* Back button for reader mode */
.library-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 180ms;
  margin-bottom: 16px;
}

.library-back-btn:hover {
  background: var(--panel-soft);
  border-color: var(--border-accent);
  color: var(--text);
}

.library-viewer-header .meta {
  font-size: .72rem;
  color: var(--muted);
  margin-top: 4px;
  display: flex;
  gap: 12px;
  font-family: var(--font-pixel);
  font-size: .45rem;
}

/* ── Viewer Body — Parchment reading area ── */
.library-viewer-body {
  flex: 1 1 0;
  overflow-y: auto;
  min-height: 0;
  padding: 28px 36px 40px;
  font-size: .88rem;
  line-height: 1.75;
  color: var(--text);
  animation: archiveGlow 6s ease-in-out infinite;
  scrollbar-width: thin;
  scrollbar-color: var(--wood, #6b4423) transparent;
}

/* Reader mode: centered content with comfortable max-width */
.library-layout.reader-mode .library-viewer-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 48px 60px;
  font-size: .95rem;
  line-height: 1.8;
}

.library-viewer-body::-webkit-scrollbar { width: 6px; }
.library-viewer-body::-webkit-scrollbar-track { background: transparent; }
.library-viewer-body::-webkit-scrollbar-thumb {
  background: var(--wood, #6b4423);
  border-radius: 0;
}

/* ── Typography — Warm book-like reading ── */
.library-viewer-body h1 {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 24px 0 12px;
  color: var(--text);
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(107,68,35,0.15);
}

.library-viewer-body h2 {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 20px 0 10px;
  color: var(--text);
}

/* Decorative diamond before h2 */
.library-viewer-body h2::before {
  content: '\25C6';
  margin-right: 8px;
  color: var(--gold);
  font-size: .7rem;
  opacity: 0.5;
}

.library-viewer-body h3 {
  font-size: .95rem;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text);
}

.library-viewer-body p {
  margin-bottom: 12px;
  text-align: left;
}

.library-viewer-body ul,
.library-viewer-body ol {
  margin: 8px 0 12px 20px;
}

.library-viewer-body li {
  margin-bottom: 5px;
}

.library-viewer-body a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px dashed rgba(218,165,32,0.3);
  transition: all 180ms;
}

.library-viewer-body a:hover {
  text-decoration: none;
  border-bottom-style: solid;
  border-bottom-color: var(--gold);
  text-shadow: 0 0 8px rgba(218,165,32,0.15);
}

.library-viewer-body strong {
  color: var(--text);
  font-weight: 700;
}

.library-viewer-body em {
  color: var(--muted);
  font-style: italic;
}

/* ── Code Blocks — Retro terminal / pixel styled ── */
.library-viewer-body code {
  background: rgba(0,0,0,0.25);
  padding: 2px 7px;
  border-radius: 0;
  font-size: .8rem;
  color: var(--green, #6cbf4a);
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  border: 1px solid rgba(108,191,74,0.15);
  image-rendering: pixelated;
}

.library-viewer-body pre {
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 20px,
      rgba(108,191,74,0.02) 20px,
      rgba(108,191,74,0.02) 21px
    ),
    rgba(8,12,6,0.85);
  padding: 16px 18px;
  border-radius: 0;
  margin: 14px 0;
  overflow-x: auto;
  border: 2px solid rgba(108,191,74,0.2);
  box-shadow:
    inset 0 0 20px rgba(0,0,0,0.3),
    0 0 8px rgba(108,191,74,0.06);
  position: relative;
}

/* Terminal header bar */
.library-viewer-body pre::before {
  content: '> TERMINAL';
  display: block;
  font-family: var(--font-pixel);
  font-size: .4rem;
  color: rgba(108,191,74,0.4);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(108,191,74,0.1);
  letter-spacing: .1em;
}

.library-viewer-body pre code {
  background: none;
  padding: 0;
  border: none;
  color: var(--green, #6cbf4a);
  text-shadow: 0 0 4px rgba(108,191,74,0.15);
}

/* ── Blockquotes — Scroll / parchment callouts ── */
.library-viewer-body blockquote {
  border-left: none;
  padding: 14px 18px 14px 22px;
  margin: 14px 0;
  background:
    linear-gradient(135deg, rgba(218,165,32,0.08) 0%, rgba(107,68,35,0.06) 100%);
  border-radius: 0;
  font-style: italic;
  color: var(--muted);
  position: relative;
  border: 1px solid rgba(107,68,35,0.2);
  box-shadow:
    inset 0 0 12px rgba(107,68,35,0.06),
    2px 2px 0 rgba(0,0,0,0.08);
}

/* Scroll top edge */
.library-viewer-body blockquote::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 8px;
  right: 8px;
  height: 3px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(107,68,35,0.3) 0px,
      rgba(107,68,35,0.3) 3px,
      transparent 3px,
      transparent 6px
    );
  border-radius: 2px 2px 0 0;
}

/* Scroll bottom edge */
.library-viewer-body blockquote::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 8px;
  right: 8px;
  height: 3px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(107,68,35,0.3) 0px,
      rgba(107,68,35,0.3) 3px,
      transparent 3px,
      transparent 6px
    );
  border-radius: 0 0 2px 2px;
}

/* Parchment scroll left accent */
.library-viewer-body blockquote > :first-child::before {
  content: '\275D';
  color: var(--gold);
  opacity: 0.3;
  font-size: 1.2rem;
  margin-right: 4px;
  vertical-align: text-top;
  line-height: 1;
}

/* ── Table — Archive ledger ── */
.library-viewer-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  border: 2px solid rgba(107,68,35,0.2);
}

.library-viewer-body th,
.library-viewer-body td {
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--border);
}

.library-viewer-body th {
  background: rgba(107,68,35,0.1);
  font-weight: 600;
  font-size: .82rem;
  color: var(--gold-bright, #f0c040);
  font-family: var(--font-pixel);
  font-size: .5rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.library-viewer-body tr:nth-child(even) td {
  background: rgba(107,68,35,0.03);
}

/* ── Empty State ── */
.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: .85rem;
  gap: 8px;
}

.library-empty::before {
  content: '\1F4DA';
  font-size: 2rem;
  opacity: 0.3;
  image-rendering: pixelated;
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .library-layout {
    grid-template-columns: 240px 1fr;
  }

  .library-viewer-body {
    padding: 20px 24px 28px;
    font-size: 0.85rem;
  }

  .library-viewer-header {
    padding: 14px 20px 14px 28px;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile: stack sidebar and viewer
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {

  /* Stack vertically: sidebar on top, viewer below */
  .library-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: calc(100vh - 100px);
  }

  /* Sidebar becomes compact top panel */
  .library-sidebar {
    border-right: none;
    border-bottom: 3px solid var(--wood, #6b4423);
    max-height: 200px;
  }

  .library-sidebar::before {
    display: none;
  }

  .library-sidebar-header {
    padding: 10px 12px;
  }

  .library-sidebar-header h3 {
    font-size: 0.72rem;
    margin-bottom: 6px;
  }

  .library-search {
    padding: 8px 12px 8px 28px;
    font-size: 0.72rem;
    margin-bottom: 6px;
  }

  /* Category filters: horizontal scroll */
  .library-category-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding-bottom: 4px;
  }

  .library-category-filters::-webkit-scrollbar {
    display: none;
  }

  .library-category-btn {
    flex-shrink: 0;
    padding: 5px 10px;
    min-height: 32px;
    font-size: 0.65rem;
  }

  /* Compact document list */
  .library-doc-item {
    padding: 8px 12px;
    margin: 1px 4px;
    gap: 6px;
  }

  .library-doc-title {
    font-size: 0.72rem;
  }

  .library-doc-meta {
    font-size: 0.6rem;
    gap: 4px;
  }

  .library-group-title {
    font-size: 0.45rem;
    padding: 10px 12px 4px;
  }

  /* Viewer adjustments */
  .library-viewer::before {
    display: none;
  }

  .library-viewer-header {
    padding: 12px 14px;
  }

  .library-viewer-header h2 {
    font-size: 0.95rem;
  }

  .library-viewer-header .meta {
    font-size: 0.4rem;
    gap: 8px;
  }

  .library-viewer-body {
    padding: 16px 14px 24px;
    font-size: 0.82rem;
    line-height: 1.65;
  }

  .library-viewer-body h1 {
    font-size: 1.1rem;
    margin: 18px 0 10px;
  }

  .library-viewer-body h2 {
    font-size: 0.98rem;
    margin: 16px 0 8px;
  }

  .library-viewer-body pre {
    padding: 12px 10px;
    margin: 10px 0;
    font-size: 0.72rem;
  }

  .library-viewer-body code {
    font-size: 0.72rem;
    padding: 1px 5px;
  }

  .library-viewer-body blockquote {
    padding: 10px 12px 10px 16px;
    margin: 10px 0;
  }

  .library-viewer-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .library-viewer-body th,
  .library-viewer-body td {
    padding: 6px 8px;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  /* Bulk actions */
  .library-bulk-actions {
    flex-wrap: wrap;
    padding: 6px;
    gap: 4px;
  }

  .library-bulk-select {
    font-size: 0.4rem;
  }

  /* Reader mode on mobile: always use reader mode when doc is opened */
  .library-layout.reader-mode .library-viewer-header {
    padding: 16px 18px;
    max-width: none;
  }

  .library-layout.reader-mode .library-viewer-body {
    padding: 20px 18px 32px;
    max-width: none;
    font-size: 0.88rem;
    line-height: 1.7;
  }

  .library-back-btn {
    font-size: 0.7rem;
    padding: 6px 10px;
    margin-bottom: 12px;
  }
}
