/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #c9a84c;
  --accent-light: #e0c97a;
  --accent-dark: #8b3a1e;
  --bg: #1a1a1a;
  --surface: #2a2318;
  --border: #3d3020;
  --text: #f5ecd7;
  --text-muted: #a09070;
  --danger: #c0392b;
  --radius: 10px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Auth Page ===== */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('/static/images/login-bg-dragon.png') center center / cover no-repeat;
  position: relative;
}

body.auth-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 5, 0.72);
  z-index: 0;
}

body.auth-page > * { position: relative; z-index: 1; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.logo { text-align: center; margin-bottom: 2rem; }
.logo h1 { font-size: 2rem; color: var(--accent); font-weight: 700; }
.logo p { color: var(--text-muted); font-size: 0.95rem; }

.auth-card input[type="password"],
.auth-card input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  margin-bottom: 1rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

.auth-card input[type="password"]:focus,
.auth-card input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-card label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-card button[type="submit"] {
  width: 100%;
  padding: 0.8rem;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.auth-card button[type="submit"]:hover { background: var(--accent-light); }

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.success {
  color: #6dbf7e;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

/* ===== Header ===== */
.site-header {
  background: url('/static/images/header-banner.png') center 30% / cover no-repeat;
  color: var(--text);
  padding: 0 1.5rem;
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  position: relative;
}

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 5, 0.78);
}

.header-inner {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.brand h1 { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.brand span { font-size: 0.85rem; color: var(--text-muted); }

nav { display: flex; gap: 0.75rem; align-items: center; }

.btn-secondary {
  padding: 0.4rem 1rem;
  border: 1.5px solid rgba(255,255,255,0.5);
  border-radius: 6px;
  color: #fff;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-secondary:hover { background: rgba(255,255,255,0.15); text-decoration: none; }

/* ===== Library ===== */
.library {
  max-width: 1100px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}

.library-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

/* ===== Collection Tabs ===== */
.library-tabs {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.tab-btn {
  padding: 0.55rem 1.25rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 6px 6px 0 0;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.tab-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tab-btn.active {
  background: var(--bg);
  border-color: var(--accent);
  border-bottom-color: var(--bg);
  color: var(--accent);
}

/* ===== Search ===== */
.search-wrap { flex: 1; max-width: 380px; }

.search-input {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { outline: none; border-color: var(--accent); }

.empty-state, .no-results {
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 3rem 0;
  text-align: center;
}

/* ===== Alpha nav (top horizontal bar) ===== */
.alpha-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 1.75rem;
}

.alpha-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s;
}
.alpha-link:hover { background: rgba(201,168,76,0.15); text-decoration: none; }

.alpha-inactive {
  color: var(--border);
  pointer-events: none;
}

/* ===== Letter sections (grid layout) ===== */
.letter-block {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.letter-label {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

/* ===== Grid (kept for admin/other uses) ===== */
.ebook-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

/* ===== Card ===== */
.ebook-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
}

.ebook-card:hover {
  box-shadow: 0 6px 24px rgba(201,168,76,0.18);
  transform: translateY(-3px);
}

/* ===== Cover ===== */
.cover-wrap {
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--bg);
}

.ebook-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.placeholder-cover {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
}

/* ===== Card info ===== */
.ebook-info {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.ebook-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ebook-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ebook-series {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Series badge (used in modal) ===== */
.ebook-series-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(201,168,76,0.12);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 4px;
  padding: 0.2rem 0.55rem;
  letter-spacing: 0.02em;
}

/* ===== Download buttons (modal only) ===== */
.download-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.btn-download {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: #1a1a1a;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s;
  flex: 1;
}
.btn-download:hover { background: var(--accent-light); text-decoration: none; }

.btn-epub { background: var(--accent); }
.btn-mobi { background: #7a5c2e; color: var(--text); }
.btn-mobi:hover { background: #9a7840; }
.btn-info { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); flex: 0; }
.btn-info:hover { background: rgba(201,168,76,0.12); }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay.active { display: flex; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  box-shadow: 0 16px 48px rgba(0,0,0,0.7);
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-header {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.modal-cover {
  width: 100px;
  min-width: 100px;
  border-radius: 6px;
  object-fit: cover;
}

.modal-meta { flex: 1; min-width: 0; }

.modal-genre {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin: 0 0 0.25rem;
}

.modal-author {
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.modal-desc {
  font-size: 0.925rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
}

.modal-desc-loading {
  font-style: italic;
  opacity: 0.6;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== Admin ===== */
.admin-main {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.admin-section-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.admin-section h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0;
}

.admin-search {
  max-width: 280px;
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
}

.hint { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1rem; }

.admin-table-wrap { overflow-x: auto; margin-bottom: 1.25rem; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th, .admin-table td {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.admin-table th { background: var(--bg); font-weight: 600; }
.td-desc { max-width: 200px; }
.td-link a { color: var(--accent); }
.td-empty { color: var(--text-muted); font-style: italic; }

.add-form {
  margin-top: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.add-form summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label { font-size: 0.875rem; font-weight: 600; }

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea {
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group small { color: var(--text-muted); font-size: 0.8rem; }

.btn-secondary-outline {
  padding: 0.55rem 1.25rem;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-secondary-outline:hover { background: var(--accent); color: #1a1a1a; }

.btn-primary {
  padding: 0.65rem 1.5rem;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-light); }

.btn-danger-sm {
  padding: 0.3rem 0.75rem;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 5px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-danger-sm:hover { background: var(--danger); color: #fff; }

.btn-edit-sm {
  padding: 0.3rem 0.75rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 5px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-edit-sm:hover { background: var(--accent); color: #1a1a1a; }

.td-actions { display: flex; gap: 0.4rem; align-items: center; white-space: nowrap; }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--accent); }
th.sort-asc, th.sort-desc { color: var(--accent); }
.sort-icon { font-size: 0.7rem; opacity: 0.8; }

.edit-modal-card { max-width: 640px; }

.edit-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.password-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.password-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.password-list code {
  background: var(--bg);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9rem;
  border: 1px solid var(--border);
}

.inline-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input[type="text"] {
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  min-width: 220px;
  background: var(--bg);
  color: var(--text);
}

.inline-form input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.flash-messages { margin-bottom: 1.5rem; }

.flash {
  background: #2a2318;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* ===== Send to Kindle ===== */
.kindle-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.btn-kindle {
  background: #146eb4;
  color: #fff;
  border: none;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.btn-kindle:hover:not(:disabled) { background: #1a85d8; }
.btn-kindle:disabled { opacity: 0.55; cursor: default; }

.kindle-status {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.kindle-status.kindle-ok  { color: #5cb85c; }
.kindle-status.kindle-err { color: var(--danger); }

/* ===== Admin user display ===== */
.user-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 160px;
}

.kindle-email-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.kindle-email-form input[type="email"] {
  padding: 0.35rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  width: 200px;
}

.kindle-email-form input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.user-password-display {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .ebook-grid { grid-template-columns: repeat(2, 1fr); }
  .letter-block { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 640px) {
  .alpha-link { width: 24px; height: 24px; font-size: 0.72rem; }
}

@media (max-width: 640px) {
  /* Header */
  .header-inner { flex-direction: column; gap: 0.5rem; align-items: flex-start; padding: 0.75rem 0; }
  .brand h1 { font-size: 1.25rem; }
  nav { width: 100%; justify-content: flex-end; }

  /* Auth */
  .auth-card { padding: 2rem 1.25rem; margin: 1rem; width: calc(100% - 2rem); }

  /* Library */
  .library { margin: 1.5rem auto; }
  .library-top { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .search-wrap { max-width: 100%; width: 100%; }
  .ebook-grid { grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }

  /* Modal */
  .modal-card { padding: 1.25rem; }
  .modal-header { flex-direction: column; }
  .modal-cover { width: 80px; min-width: 80px; }

  /* Admin */
  .admin-section { padding: 1.25rem; }
  .form-grid { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input[type="text"] { min-width: unset; width: 100%; }
  .admin-table { font-size: 0.8rem; }
  .admin-table th, .admin-table td { padding: 0.4rem 0.5rem; }
}

@media (max-width: 400px) {
  .ebook-grid { grid-template-columns: 1fr; }
}

/* ===== Book Detail Page ===== */
.book-detail {
  max-width: 860px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}

.book-detail-inner {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
}

.book-detail-header {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.book-detail-cover {
  width: 160px;
  min-width: 160px;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.placeholder-cover-lg {
  width: 160px;
  min-width: 160px;
  height: 220px;
  font-size: 3rem;
}

.book-detail-meta { flex: 1; min-width: 0; }

.book-detail-title {
  font-size: 1.6rem;
  margin: 0 0 0.4rem;
  color: var(--text);
  line-height: 1.2;
}

.book-detail-author {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0 0 0.6rem;
}

.book-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
}

.tag {
  background: rgba(201,168,76,0.15);
  color: var(--accent);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 20px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
}

.book-detail-desc {
  margin-top: 2rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 1.5rem;
}

.book-detail-desc h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
}

.book-detail-desc p {
  color: var(--text);
  line-height: 1.7;
  margin: 0;
}

@media (max-width: 540px) {
  .book-detail-header { flex-direction: column; align-items: center; text-align: center; }
  .book-detail-tags { justify-content: center; }
  .download-links { justify-content: center; }
  .kindle-row { justify-content: center; }
}

/* ===== Sync spinner ===== */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 1em; height: 1em;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.5em;
}

/* ===== Gothic Library Bookshelf ===== */
body.library-page {
  background-color: #070504;
  background-image:
    repeating-linear-gradient(0deg, transparent 0px, transparent 59px, rgba(255,255,255,0.025) 59px, rgba(255,255,255,0.025) 60px),
    repeating-linear-gradient(90deg, transparent 0px, transparent 89px, rgba(255,255,255,0.018) 89px, rgba(255,255,255,0.018) 90px),
    radial-gradient(ellipse 100% 55% at 50% 0%, rgba(35,22,6,0.5) 0%, transparent 65%),
    radial-gradient(ellipse 80% 40% at 50% 100%, rgba(0,0,0,0.65) 0%, transparent 75%);
}

body.library-page::before,
body.library-page::after {
  content: '';
  position: fixed;
  bottom: 0;
  width: 240px;
  height: 340px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 240'%3E%3Cg opacity='0.7'%3E%3Crect x='5' y='205' width='150' height='35' rx='5' fill='%23252018'/%3E%3Crect x='0' y='193' width='160' height='16' rx='4' fill='%232e2820'/%3E%3Cellipse cx='48' cy='193' rx='18' ry='12' fill='%23181412'/%3E%3Cellipse cx='112' cy='193' rx='18' ry='12' fill='%23181412'/%3E%3Cpath d='M32,196 L20,190 L28,193 L17,183 L27,188 L22,178 L32,187 Z' fill='%23181412'/%3E%3Cpath d='M128,196 L140,190 L132,193 L143,183 L133,188 L138,178 L128,187 Z' fill='%23181412'/%3E%3Cellipse cx='80' cy='148' rx='46' ry='50' fill='%23181412'/%3E%3Cpath d='M116,172 Q148,188 155,208 Q148,216 142,205 Q135,188 108,175 Z' fill='%23181412'/%3E%3Cpath d='M36,136 Q0,82 2,28 Q12,15 24,34 Q28,88 52,126 Z' fill='%231e1a12'/%3E%3Cpath d='M124,136 Q160,82 158,28 Q148,15 136,34 Q132,88 108,126 Z' fill='%231e1a12'/%3E%3Cellipse cx='80' cy='104' rx='22' ry='22' fill='%23181412'/%3E%3Cellipse cx='80' cy='82' rx='30' ry='28' fill='%23181412'/%3E%3Cpolygon points='63,66 54,26 70,63' fill='%23221c14'/%3E%3Cpolygon points='97,66 106,26 90,63' fill='%23221c14'/%3E%3Cpolygon points='52,78 40,60 58,74' fill='%23181412'/%3E%3Cpolygon points='108,78 120,60 102,74' fill='%23181412'/%3E%3Cellipse cx='70' cy='80' rx='7' ry='6' fill='%23c9a84c' opacity='0.55'/%3E%3Cellipse cx='90' cy='80' rx='7' ry='6' fill='%23c9a84c' opacity='0.55'/%3E%3Crect x='72.5' y='78' width='3' height='5' rx='1.5' fill='%230a0806' opacity='0.9'/%3E%3Crect x='92.5' y='78' width='3' height='5' rx='1.5' fill='%230a0806' opacity='0.9'/%3E%3Cellipse cx='80' cy='96' rx='13' ry='9' fill='%23181412'/%3E%3Cellipse cx='75' cy='98' rx='2' ry='1.5' fill='%230a0806' opacity='0.7'/%3E%3Cellipse cx='85' cy='98' rx='2' ry='1.5' fill='%230a0806' opacity='0.7'/%3E%3Cpath d='M72,104 L70,114 L74,104' fill='%23d0ccc0' opacity='0.55'/%3E%3Cpath d='M88,104 L90,114 L86,104' fill='%23d0ccc0' opacity='0.55'/%3E%3Cpath d='M36,160 Q18,174 14,196' fill='none' stroke='%23181412' stroke-width='16' stroke-linecap='round'/%3E%3Cpath d='M124,160 Q142,174 146,196' fill='none' stroke='%23181412' stroke-width='16' stroke-linecap='round'/%3E%3Cpath d='M14,196 L2,190 L9,194 L0,184 L8,189 L4,180 L12,188 Z' fill='%23181412'/%3E%3Cpath d='M146,196 L158,190 L151,194 L160,184 L152,189 L156,180 L148,188 Z' fill='%23181412'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: contain;
  pointer-events: none;
  z-index: 0;
}

body.library-page::before { left: 0; }
body.library-page::after { right: 0; transform: scaleX(-1); }

@media (max-width: 1350px) {
  body.library-page::before,
  body.library-page::after { display: none; }
}

body.library-page .letter-block {
  position: relative;
  margin-bottom: 4.5rem;
  box-shadow:
    0 8px 0 rgba(210,195,165,0.05),
    0 10px 0 #2c2416,
    0 17px 0 #1c1610,
    0 23px 0 #100e08,
    0 27px 0 #080706,
    0 36px 24px rgba(0,0,0,0.9);
}

body.library-page .letter-block::before {
  content: '';
  position: absolute;
  top: 1.5rem;
  right: 2px;
  width: 68px;
  height: 68px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80'%3E%3Cline x1='80' y1='0' x2='0' y2='0' stroke='%23b0a890' stroke-width='0.6'/%3E%3Cline x1='80' y1='0' x2='0' y2='20' stroke='%23b0a890' stroke-width='0.6'/%3E%3Cline x1='80' y1='0' x2='5' y2='52' stroke='%23b0a890' stroke-width='0.6'/%3E%3Cline x1='80' y1='0' x2='26' y2='80' stroke='%23b0a890' stroke-width='0.6'/%3E%3Cline x1='80' y1='0' x2='56' y2='80' stroke='%23b0a890' stroke-width='0.6'/%3E%3Cline x1='80' y1='0' x2='80' y2='62' stroke='%23b0a890' stroke-width='0.6'/%3E%3Cpath d='M60,0 Q58,22 80,20' fill='none' stroke='%23b0a890' stroke-width='0.5'/%3E%3Cpath d='M36,0 Q32,42 80,42' fill='none' stroke='%23b0a890' stroke-width='0.5'/%3E%3Cpath d='M12,0 Q4,56 80,62' fill='none' stroke='%23b0a890' stroke-width='0.5'/%3E%3Ccircle cx='46' cy='28' r='2.5' fill='%23807868' opacity='0.7'/%3E%3Cline x1='43' y1='28' x2='39' y2='26' stroke='%23807868' stroke-width='0.7' opacity='0.6'/%3E%3Cline x1='49' y1='28' x2='53' y2='26' stroke='%23807868' stroke-width='0.7' opacity='0.6'/%3E%3Cline x1='43' y1='30' x2='39' y2='33' stroke='%23807868' stroke-width='0.7' opacity='0.6'/%3E%3Cline x1='49' y1='30' x2='53' y2='33' stroke='%23807868' stroke-width='0.7' opacity='0.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  opacity: 0.22;
}

body.library-page .ebook-card {
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  position: relative;
  z-index: 1;
}
