:root {
  --bg: #faf7f1;
  --paper: #fffdf8;
  --text: #1f1a17;
  --muted: #756c64;
  --line: #e4d8c8;
  --accent: #5a3217;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
}

a {
  color: var(--accent);
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

.container {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0;
}

.hero,
.card,
.novel-title,
.chapter,
.admin-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.04);
}

.card {
  margin: 1rem 0;
}

.meta {
  color: var(--muted);
  font-size: .95rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.reading-page {
  max-width: 820px;
}

.chapter {
  font-size: 1.22rem;
}

.chapter h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.15;
}

.chapter h2 {
  margin-top: 2.5rem;
  font-size: 1.55rem;
}

.chapter-content p {
  margin: 1.25rem 0;
}

.chapter-content {
  max-width: 68ch;
}

.chapter-list li {
  margin: .75rem 0;
}

.admin-body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
}

.admin-panel {
  max-width: 1100px;
}

label {
  display: block;
  margin-top: 1rem;
  font-weight: 700;
}

input,
textarea,
select,
button {
  width: 100%;
  max-width: 100%;
  padding: .8rem;
  border: 1px solid #bbb;
  border-radius: 10px;
  font: inherit;
}

textarea {
  min-height: 320px;
  line-height: 1.55;
}

button,
.button {
  display: inline-block;
  width: auto;
  margin-top: 1rem;
  padding: .75rem 1rem;
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
}

.button.secondary {
  background: #555;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.table th,
.table td {
  border-bottom: 1px solid #ddd;
  padding: .75rem;
  text-align: left;
}

.notice {
  padding: .8rem 1rem;
  border-radius: 10px;
  background: #fff3cd;
  border: 1px solid #ffe69c;
}

@media print {
  .no-print,
  .site-header {
    display: none;
  }

  body {
    background: white;
  }

  .chapter {
    border: 0;
    box-shadow: none;
  }
}

.chapter-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: .75rem;
  align-items: center;
  margin: 0 0 1rem;
}

.chapter-nav:last-child {
  margin: 1rem 0 0;
}

.chapter-nav a:last-child {
  justify-self: end;
}

.chapter-content img,
.rich-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
  margin: 1rem auto;
}

.chapter-content figure,
.rich-editor figure {
  margin: 1.5rem 0;
  text-align: center;
}

.chapter-content figcaption,
.rich-editor figcaption {
  color: var(--muted);
  font-size: .9rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.chapter-content blockquote,
.rich-editor blockquote {
  border-left: 4px solid var(--line);
  margin: 1.5rem 0;
  padding: .25rem 0 .25rem 1rem;
  color: #3a312b;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .75rem;
  border: 1px solid #bbb;
  border-radius: 10px 10px 0 0;
  background: #fff;
}

.editor-toolbar button,
.editor-toolbar select,
.editor-toolbar input[type="color"],
.upload-button {
  width: auto;
  margin: 0;
  min-height: 2.5rem;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  padding: .55rem .8rem;
  border-radius: 10px;
  background: #555;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.upload-button input {
  display: none;
}

.rich-editor {
  min-height: 420px;
  padding: 1rem;
  border: 1px solid #bbb;
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: white;
  line-height: 1.7;
  outline: none;
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #888;
  white-space: pre-line;
}

@media (max-width: 720px) {
  .chapter-nav {
    grid-template-columns: 1fr;
  }
  .chapter-nav a:last-child {
    justify-self: stretch;
  }
}

.badge {
  display: inline-block;
  padding: .25rem .55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f3eadf;
  color: var(--accent);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .85rem;
  font-weight: 700;
}

.novel-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.cover-thumb img,
.cover-large img,
.cover-preview img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.cover-thumb img {
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.book-view {
  display: grid;
  grid-template-columns: minmax(160px, 240px) 1fr;
  gap: 2rem;
  align-items: start;
}

.cover-preview {
  max-width: 180px;
  margin: .75rem 0;
}

.compact-form,
.inline-form {
  max-width: 620px;
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #fff;
  margin: .75rem 0 1.25rem;
}

button.danger,
.button.danger {
  background: #8a1f1f;
}

details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 720px) {
  .novel-card,
  .book-view {
    grid-template-columns: 1fr;
  }

  .cover-thumb,
  .cover-large {
    max-width: 220px;
  }
}

/* Bookshelf front page redesign */
body {
  background:
    radial-gradient(circle at top left, rgba(142, 102, 62, .18), transparent 28rem),
    linear-gradient(180deg, #f8efe3 0%, #efe2d2 45%, #e7d5bf 100%);
}

.shelf-container {
  width: min(1180px, calc(100% - 2rem));
}

.shelf-hero {
  position: relative;
  overflow: hidden;
  border: 0;
  color: #fff8ef;
  background:
    linear-gradient(135deg, rgba(47, 25, 12, .92), rgba(103, 59, 30, .9)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.06) 0 1px, transparent 1px 26px);
  box-shadow: 0 24px 60px rgba(60, 34, 17, .18);
}

.shelf-hero::after {
  content: "";
  position: absolute;
  right: -4rem;
  bottom: -7rem;
  width: 20rem;
  height: 20rem;
  border-radius: 999px;
  background: rgba(255, 221, 164, .14);
}

.shelf-hero h1 {
  margin: .25rem 0;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 1;
}

.shelf-hero p {
  max-width: 60ch;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .8rem;
  color: #ffe2ad;
  font-weight: 800;
}

.bookshelf {
  margin-top: 2rem;
  padding: 1.5rem;
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(74, 38, 17, .12), transparent 8%, transparent 92%, rgba(74, 38, 17, .12)),
    linear-gradient(180deg, #7a4422 0 1.1rem, #5a2e16 1.1rem 1.45rem, transparent 1.45rem),
    #d9b98f;
  box-shadow: inset 0 0 0 1px rgba(81, 42, 20, .18), 0 24px 50px rgba(73, 38, 17, .18);
}

.shelf-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin: 0 0 1rem;
  color: #2d170b;
}

.shelf-heading h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 2rem 1.35rem;
  align-items: stretch;
}

.book-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 1rem 1rem 1.25rem;
  border-radius: 18px;
  background: rgba(255, 249, 238, .92);
  box-shadow: 0 16px 28px rgba(55, 28, 12, .22);
}

.book-card::after {
  content: "";
  position: absolute;
  left: -1rem;
  right: -1rem;
  bottom: -.8rem;
  height: .9rem;
  border-radius: 0 0 18px 18px;
  background: linear-gradient(180deg, #7b431e, #4c260f);
  box-shadow: 0 10px 18px rgba(48, 24, 10, .25);
}

.book-cover {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 12px 16px 16px 12px;
  background: linear-gradient(135deg, #5b3018, #b7773e);
  box-shadow: 10px 12px 18px rgba(37, 20, 10, .24), inset 10px 0 14px rgba(0,0,0,.18);
  transform: perspective(900px) rotateY(-4deg);
  transition: transform .18s ease, box-shadow .18s ease;
}

.book-cover:hover {
  transform: perspective(900px) rotateY(0deg) translateY(-4px);
  box-shadow: 12px 18px 28px rgba(37, 20, 10, .32), inset 10px 0 14px rgba(0,0,0,.14);
}

.book-cover::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 12%;
  background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(255,255,255,.08), transparent);
  z-index: 2;
}

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

.cover-placeholder {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: .5rem;
  padding: 1rem;
  color: #fff4e3;
  text-align: center;
}

.cover-placeholder strong {
  font-size: clamp(2.6rem, 8vw, 4.4rem);
  line-height: 1;
}

.cover-placeholder small {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
  opacity: .8;
}

.book-card-body h3 {
  margin: 1rem 0 .2rem;
  line-height: 1.2;
  font-size: 1.25rem;
}

.book-card-body h3 a {
  color: #2d170b;
  text-decoration: none;
}

.book-card-body h3 a:hover {
  text-decoration: underline;
}


.book-synopsis {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
  max-height: 6.8em;
}

.book-card-body p:last-child {
  margin-bottom: 0;
}

.empty-shelf {
  padding: 2rem;
  border-radius: 16px;
  background: rgba(255, 249, 238, .9);
}

@media (max-width: 620px) {
  .bookshelf {
    padding: 1rem;
  }

  .shelf-heading {
    display: block;
  }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* Redesigned admin backend */
.admin-shell-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.25rem;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid #e1e5ea;
  backdrop-filter: blur(12px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.admin-brand { display:flex; align-items:center; gap:.6rem; color:#1f2937; text-decoration:none; }
.admin-brand span { display:grid; place-items:center; width:2.2rem; height:2.2rem; border-radius:12px; background:#2f241d; color:#fff4df; }
.admin-top-nav { display:flex; align-items:center; gap:.35rem; flex-wrap:wrap; }
.admin-top-nav a { padding:.55rem .75rem; border-radius:999px; text-decoration:none; color:#374151; font-weight:700; }
.admin-top-nav a.active, .admin-top-nav a:hover { background:#f0e6d8; color:#5a3217; }
.site-header .admin-top-nav { margin-left:auto; }
.site-header .admin-top-nav a { margin-top:0; }
.site-top-nav a { color:#374151; }

.admin-shell { width:min(1360px, calc(100% - 1.5rem)); margin:0 auto; padding:1.25rem 0 3rem; display:grid; grid-template-columns:260px 1fr; gap:1.25rem; font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
.admin-sidebar { position:sticky; top:5rem; align-self:start; padding:1rem; border:1px solid #e1e5ea; border-radius:22px; background:rgba(255,255,255,.86); box-shadow:0 14px 40px rgba(31,41,55,.08); }
.admin-user-card { display:flex; align-items:center; gap:.75rem; padding:.75rem; border-radius:16px; background:#f9fafb; margin-bottom:.9rem; }
.admin-user-card small { display:block; color:#6b7280; text-transform:capitalize; }
.avatar { display:inline-grid; place-items:center; width:2.35rem; height:2.35rem; flex:0 0 auto; border-radius:999px; background:#5a3217; color:white; font-weight:900; }
.avatar.big { width:3rem; height:3rem; }
.side-link { display:flex; gap:.5rem; align-items:center; padding:.8rem .85rem; border-radius:14px; text-decoration:none; color:#374151; font-weight:800; margin:.2rem 0; }
.side-link.active, .side-link:hover { background:#2f241d; color:#fff4df; }
.admin-content { min-width:0; }
.admin-page-head { display:flex; justify-content:space-between; align-items:flex-start; gap:1rem; margin:.25rem 0 1.25rem; }
.admin-page-head h1 { margin:.05rem 0; font-size:clamp(2rem, 4vw, 3.2rem); line-height:1; }
.kicker { margin:0; color:#8a5a2f; text-transform:uppercase; letter-spacing:.14em; font-size:.78rem; font-weight:900; }
.admin-subtitle { margin:.35rem 0 0; color:#6b7280; max-width:65ch; }
.head-actions { display:flex; flex-wrap:wrap; gap:.5rem; justify-content:flex-end; }
.admin-card { background:rgba(255,255,255,.92); border:1px solid #e1e5ea; border-radius:22px; padding:1.25rem; box-shadow:0 14px 40px rgba(31,41,55,.08); }
.section-head { display:flex; justify-content:space-between; align-items:baseline; gap:1rem; margin-bottom:1rem; }
.section-head h2 { margin:0; }
.stat-grid { display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:.9rem; margin-bottom:1.25rem; }
.stat-card { padding:1rem; border-radius:18px; background:#fff; border:1px solid #e1e5ea; box-shadow:0 8px 24px rgba(31,41,55,.06); }
.stat-card strong { display:block; font-size:2rem; line-height:1; color:#2f241d; }
.stat-card span { color:#6b7280; font-weight:700; }
.admin-library-list { display:grid; gap:.85rem; }
.admin-book-row { display:grid; grid-template-columns:72px 1fr auto; gap:1rem; align-items:center; padding:.85rem; border:1px solid #edf0f4; border-radius:18px; background:#fbfcfd; }
.admin-cover-mini { width:72px; aspect-ratio:2/3; border-radius:10px; overflow:hidden; background:linear-gradient(135deg,#5b3018,#b7773e); display:grid; place-items:center; color:white; font-weight:900; box-shadow:inset 8px 0 10px rgba(0,0,0,.18); }
.admin-cover-mini img { width:100%; height:100%; object-fit:cover; display:block; }
.admin-book-main h3, .user-info h3 { margin:0 0 .2rem; }
.pill-row { display:flex; flex-wrap:wrap; gap:.35rem; margin-top:.45rem; }
.pill { display:inline-flex; padding:.25rem .55rem; border-radius:999px; background:#eef2f7; color:#374151; font-weight:800; font-size:.78rem; }
.pill.good { background:#dcfce7; color:#166534; }
.pill.warn { background:#fef3c7; color:#92400e; }
.pill.muted { background:#f3f4f6; color:#6b7280; }
.row-actions { display:flex; gap:.4rem; align-items:center; }
.button.primary { background:#2f241d; }
.button.small { padding:.55rem .75rem; border-radius:9px; font-size:.92rem; margin-top:0; }
.button.ghost { background:transparent; color:#374151; border:1px solid #d1d5db; }
.button.full { width:100%; text-align:center; }
.empty-state { padding:2rem; border:1px dashed #cbd5e1; border-radius:18px; background:#f8fafc; }
.flash { padding:.85rem 1rem; border-radius:14px; border:1px solid; margin:0 0 1rem; font-weight:800; }
.flash-success { background:#ecfdf5; color:#166534; border-color:#bbf7d0; }
.flash-error { background:#fef2f2; color:#991b1b; border-color:#fecaca; }
.editor-layout { display:grid; grid-template-columns:280px minmax(0,1fr); gap:1.25rem; align-items:start; }
.chapter-sidebar { position:sticky; top:5rem; }
.chapter-sidebar h2 { margin-top:0; }
.chapter-picker { display:grid; gap:.55rem; margin:1rem 0; }
.chapter-chip { display:grid; grid-template-columns:2rem 1fr; gap:.55rem; padding:.7rem; border-radius:14px; border:1px solid #e5e7eb; text-decoration:none; color:#1f2937; background:#fff; }
.chapter-chip span { grid-row:1/3; display:grid; place-items:center; width:2rem; height:2rem; border-radius:999px; background:#f0e6d8; color:#5a3217; font-weight:900; }
.chapter-chip strong { line-height:1.2; }
.chapter-chip small { color:#6b7280; }
.chapter-chip.active, .chapter-chip:hover { border-color:#5a3217; box-shadow:0 8px 24px rgba(90,50,23,.12); }
.editor-main { display:grid; gap:1.25rem; }
.form-section label { margin-top:.75rem; }
.form-grid { display:grid; gap:1rem; }
.form-grid.two { grid-template-columns:repeat(2, minmax(0,1fr)); }
label small { display:block; margin-top:.3rem; color:#6b7280; font-weight:500; }
.short-textarea { min-height:120px; }
.cover-admin-grid { display:grid; grid-template-columns:1fr 220px; gap:1.25rem; align-items:start; }
.cover-preview-panel { border:1px dashed #cbd5e1; border-radius:18px; padding:.75rem; background:#f8fafc; }
.cover-preview-panel img { width:100%; aspect-ratio:2/3; object-fit:cover; border-radius:14px; display:block; }
.admin-placeholder { aspect-ratio:2/3; border-radius:14px; background:linear-gradient(135deg,#5b3018,#b7773e); }
.checkbox-card { display:flex; gap:.75rem; align-items:flex-start; padding:.8rem; border:1px solid #e5e7eb; border-radius:14px; background:#fbfcfd; }
.checkbox-card input { width:auto; margin-top:.25rem; }
.checkbox-card span { display:grid; }
.checkbox-card small { color:#6b7280; font-weight:500; }
.checkbox-card.compact { margin:.8rem 0; }
.sticky-save { position:sticky; bottom:.75rem; z-index:10; display:flex; gap:.5rem; flex-wrap:wrap; align-items:center; padding:.75rem; border:1px solid #e1e5ea; border-radius:18px; background:rgba(255,255,255,.94); box-shadow:0 14px 40px rgba(31,41,55,.13); }
.users-layout { display:grid; grid-template-columns:minmax(280px, 380px) 1fr; gap:1.25rem; align-items:start; }
.clean-form { display:grid; gap:.75rem; }
.clean-form label { margin-top:0; }
.user-list { display:grid; gap:.75rem; }
.user-row { display:flex; gap:1rem; align-items:flex-start; padding:1rem; border:1px solid #edf0f4; border-radius:18px; background:#fbfcfd; }
.user-info { flex:1; min-width:0; }
.edit-user-details { margin-top:.75rem; }
.nested-form { margin-top:.75rem; padding:1rem; border-radius:14px; background:#fff; border:1px solid #e5e7eb; }
@media (max-width: 1000px) {
  .admin-shell, .editor-layout, .users-layout { grid-template-columns:1fr; }
  .admin-sidebar, .chapter-sidebar { position:static; }
  .stat-grid { grid-template-columns:repeat(2, minmax(0,1fr)); }
}
@media (max-width: 720px) {
  .admin-shell-header, .admin-page-head, .section-head { align-items:flex-start; flex-direction:column; }
  .admin-book-row, .cover-admin-grid, .form-grid.two { grid-template-columns:1fr; }
  .row-actions { justify-content:flex-start; }
  .stat-grid { grid-template-columns:1fr; }
}

/* Editor chapter list scrolling fix */
.editor-layout {
  align-items: start;
}

.chapter-sidebar {
  align-self: start;
  max-height: calc(100vh - 6.5rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chapter-picker {
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(100vh - 18rem);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: .35rem;
  margin-right: -.35rem;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.chapter-picker::-webkit-scrollbar {
  width: 8px;
}

.chapter-picker::-webkit-scrollbar-thumb {
  background: #d1b596;
  border-radius: 999px;
}

.chapter-picker::-webkit-scrollbar-track {
  background: #f7efe4;
  border-radius: 999px;
}

.chapter-chip {
  min-width: 0;
}

.chapter-chip strong,
.chapter-chip small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-chip strong {
  white-space: nowrap;
}

@media (max-width: 1000px) {
  .chapter-sidebar {
    max-height: none;
    overflow: visible;
  }

  .chapter-picker {
    max-height: 50vh;
    overflow-y: auto;
  }
}

/* FinctionTale logo integration */
.site-header {
  align-items: center;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--text);
}

.brand-logo img {
  width: auto;
  height: 3.15rem;
  max-width: min(300px, 54vw);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(64, 38, 116, .18);
}

.brand-logo span {
  letter-spacing: .01em;
}


.shelf-hero {
  background:
    radial-gradient(circle at 14% 8%, rgba(133, 75, 255, .30), transparent 22rem),
    radial-gradient(circle at 86% 18%, rgba(0, 188, 255, .24), transparent 20rem),
    linear-gradient(135deg, rgba(12, 9, 22, .96), rgba(42, 21, 73, .92) 52%, rgba(13, 46, 70, .90)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.06) 0 1px, transparent 1px 26px);
}

.shelf-hero::after {
  background: rgba(111, 202, 255, .16);
}


@media (max-width: 620px) {
  .brand-logo span { font-size: .95rem; }
}


.site-footer {
  margin-top: 2rem;
  padding: 1.25rem;
  border-top: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  text-align: center;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .92rem;
}

.site-footer nav {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .35rem;
}

.legal-text h2 {
  margin-top: 1.8rem;
}

/* GDPR-friendly cookie/privacy notice */
.cookie-notice {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  width: min(980px, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 18px;
  background: rgba(16, 13, 28, .96);
  color: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  transform: translate(-50%, 1.25rem);
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
}

.cookie-notice.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.cookie-notice[hidden] {
  display: none;
}

.cookie-notice__content strong {
  display: block;
  margin-bottom: .25rem;
  font-size: 1.05rem;
}

.cookie-notice__content p {
  margin: 0;
  color: rgba(255, 255, 255, .82);
  line-height: 1.45;
}

.cookie-notice__actions {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cookie-notice .button {
  margin-top: 0;
  white-space: nowrap;
}

.cookie-notice .button-light {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .18);
}

@media (max-width: 760px) {
  .cookie-notice {
    grid-template-columns: 1fr;
  }

  .cookie-notice__actions {
    justify-content: stretch;
  }

  .cookie-notice .button {
    flex: 1 1 12rem;
    text-align: center;
  }
}


/* Chapter author annotations */
.annotation-editor {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid #eadfce;
  border-radius: 18px;
  background: #fffaf2;
}
.section-head.compact h3 { margin: 0; }
.chapter-annotation {
  margin: 1.4rem 0;
  padding: 1rem 1.15rem;
  border-left: 4px solid #8b5e34;
  border-radius: 14px;
  background: #fff8ed;
  color: #3b2a1d;
}
.chapter-annotation strong {
  display: block;
  margin-bottom: .45rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  font-size: .82rem;
}
.chapter-annotation p {
  margin: .45rem 0 0;
}

.annotation-list {
  display: grid;
  gap: 1rem;
}
.annotation-row {
  padding: 1rem;
  border: 1px dashed #d8c5ad;
  border-radius: 16px;
  background: rgba(255, 255, 255, .55);
}
.annotation-row .annotation-remove {
  margin-top: .35rem;
}

/* Community features */
.community-card,
.comments {
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(109, 74, 255, .14);
  border-radius: 22px;
  padding: 1.4rem;
  box-shadow: 0 18px 50px rgba(41, 28, 74, .08);
  margin: 2rem 0;
}
.comment-list { display: grid; gap: 1rem; margin: 1rem 0 1.5rem; }
.comment-item { background: #fff; border: 1px solid rgba(41,28,74,.1); border-radius: 16px; padding: 1rem; }
.comment-item header { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; margin-bottom: .35rem; }
.comment-item p { margin: 0; white-space: normal; }
.comment-form { display: grid; gap: 1rem; margin-top: 1.25rem; }
.comment-form textarea { min-height: 120px; resize: vertical; }
.honeypot { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }
.author-profile h1 { margin-top: .2rem; }
.compact-books { margin-top: 1rem; }
.compact-books .book-card { min-height: auto; }
.comments .checkbox-card small { display: block; line-height: 1.35; }
.comment-captcha { display: grid; gap: .45rem; align-items: start; }
.comment-submit[disabled] { cursor: wait; opacity: .72; filter: grayscale(.15); }
.comment-captcha.is-unlocked .comment-submit { cursor: pointer; opacity: 1; filter: none; }
.comment-captcha-status { display: block; }

@media (max-width: 720px) { .comment-item header { display: block; } }

.comment-moderation-list { display: grid; gap: 1rem; }
.moderation-item { background: rgba(255,255,255,.92); }
.moderation-actions { margin-top: .85rem; justify-content: flex-start; }

.author-bio {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.06);
  line-height: 1.7;
  white-space: normal;
}
.clean-form label.wide {
  grid-column: 1 / -1;
}
.clean-form textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
}

.chapter-annotation-link {
  border-style: solid;
}
.chapter-annotation-link small, .privacy-note {
  display: block;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}
.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 820px) {
  .form-grid.three { grid-template-columns: 1fr; }
}

.annotation-link-field[hidden] { display: none !important; }

.totp-qr-panel { display:flex; gap:1rem; align-items:flex-start; padding:1rem; border:1px solid rgba(255,255,255,.12); border-radius:16px; background:rgba(255,255,255,.04); margin:1rem 0; }
.totp-qr-code { min-width:185px; min-height:185px; display:flex; align-items:center; justify-content:center; background:#fff; border-radius:12px; padding:.75rem; box-shadow:0 10px 30px rgba(0,0,0,.25); }
.totp-qr-code canvas { width:180px; height:180px; image-rendering:pixelated; }
.totp-qr-panel details code { display:block; white-space:normal; word-break:break-all; margin-top:.5rem; }
@media (max-width: 700px) { .totp-qr-panel { flex-direction:column; } }

.sort-form { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.sort-form label { display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 700; }
.sort-form select { min-width: 12rem; }
.book-stats, .stats-line { font-weight: 700; }

.comment-replies { margin: 1rem 0 0 1.25rem; padding-left: 1rem; border-left: 2px solid rgba(47,36,29,.16); display: grid; gap: 1rem; }
.comment-reply { background: rgba(255,255,255,.55); }
.reply-box { margin-top: .75rem; }
.reply-box summary { cursor: pointer; font-weight: 700; color: #2f241d; display: inline-flex; align-items: center; gap: .35rem; }
.reply-box summary::before { content: '↳'; opacity: .7; }
.reply-form { margin-top: .75rem; padding: 1rem; border-radius: 18px; background: rgba(47,36,29,.05); }
@media (max-width: 720px) { .comment-replies { margin-left: .35rem; padding-left: .75rem; } }

.checkbox-group { margin-top: 1rem; display: grid; gap: .65rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .55rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }

/* Editor compact expandable cards and natural chapter scrolling */
.editor-layout {
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  align-items: start;
}

.chapter-sidebar {
  position: static;
  max-height: none;
  overflow: visible;
  display: block;
}

.chapter-picker {
  max-height: none;
  overflow: visible;
  padding-right: 0;
  margin-right: 0;
}

.editor-card {
  padding: 0;
  overflow: hidden;
}

.editor-card-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(240,230,216,.88), rgba(255,255,255,.95));
}

.editor-card-summary::-webkit-details-marker { display: none; }
.editor-card-summary::after {
  content: '+';
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: #2f241d;
  color: #fff4df;
  font-size: 1.15rem;
  line-height: 1;
  flex: 0 0 auto;
}

.editor-card[open] > .editor-card-summary::after { content: '–'; }
.editor-card-summary span { display: grid; gap: .15rem; }
.editor-card-summary strong { font-size: 1.05rem; color: #1f2937; }
.editor-card-summary small { color: #6b7280; font-weight: 600; }
.editor-card > :not(summary) { margin-left: 1.25rem; margin-right: 1.25rem; }
.editor-card > :last-child { margin-bottom: 1.25rem; }
.editor-card .form-grid:first-of-type,
.editor-card .cover-admin-grid:first-of-type,
.editor-card > label:first-of-type { margin-top: 1rem; }

.chapter-sidebar .button.full { margin-top: .85rem; }
.chapter-chip strong { white-space: normal; }

@media (max-width: 1000px) {
  .chapter-sidebar,
  .chapter-picker {
    max-height: none;
    overflow: visible;
  }
}

.badge.tag { opacity: .9; }
.library-filter-form { align-items: flex-end; }

/* Main shelf search/filter refresh */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.site-header { gap:1rem; }
.quick-search-form { margin-left:auto; display:flex; align-items:center; min-width:min(360px, 36vw); }
.quick-search-box { position:relative; width:100%; display:flex; align-items:center; }
.quick-search-form input[type="search"] { width:100%; border:1px solid #e5dccf; border-radius:999px; padding:.58rem 2.75rem .58rem .95rem; background:#fffaf4; color:#2f2418; }
.quick-search-form button { position:absolute; right:.22rem; top:50%; transform:translateY(-50%); width:2.15rem; height:2.15rem; display:inline-flex; align-items:center; justify-content:center; border:0; border-radius:999px; background:#5a3217; color:#fffaf4; font-weight:800; cursor:pointer; line-height:1; }
.quick-search-form button span { font-size:1rem; }
.site-header .site-top-nav { margin-left:0; }
.compact-shelf-heading { align-items:flex-start; gap:1rem; }
.library-actions { margin-left:auto; position:relative; }
.filter-menu { position:relative; }
.filter-menu summary { list-style:none; cursor:pointer; display:inline-flex; align-items:center; gap:.55rem; border:1px solid #eadfce; background:#fffaf4; border-radius:999px; padding:.65rem .95rem; font-weight:800; color:#5a3217; box-shadow:0 8px 20px rgba(90,50,23,.08); }
.filter-menu summary::-webkit-details-marker { display:none; }
.hamburger-icon, .hamburger-icon::before, .hamburger-icon::after { display:block; width:1.1rem; height:2px; background:#5a3217; border-radius:99px; content:""; }
.hamburger-icon { position:relative; }
.hamburger-icon::before { position:absolute; top:-6px; left:0; }
.hamburger-icon::after { position:absolute; top:6px; left:0; }
.filter-menu[open] summary { background:#f0e6d8; }
.filter-menu .library-filter-form { position:absolute; right:0; top:calc(100% + .6rem); z-index:20; width:min(92vw, 360px); display:grid; gap:.8rem; padding:1rem; border:1px solid #eadfce; border-radius:1.25rem; background:#fffaf4; box-shadow:0 20px 50px rgba(47,36,24,.18); }
.filter-menu .library-filter-form label { display:grid; gap:.35rem; font-weight:800; color:#5a3217; }
.filter-menu .library-filter-form select { width:100%; }
.filter-actions { display:flex; gap:.5rem; flex-wrap:wrap; }
.button.ghost { background:#fffaf4; color:#5a3217; border:1px solid #eadfce; }
.advanced-search-card { margin:1.2rem 0 2rem; }
.advanced-search-form { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:1rem; }
.advanced-search-form label { display:grid; gap:.4rem; font-weight:800; color:#5a3217; }
.advanced-search-form .wide { grid-column:1 / -1; }
.advanced-search-form input, .advanced-search-form select { width:100%; }
.advanced-search-actions { grid-column:1 / -1; display:flex; gap:.65rem; flex-wrap:wrap; align-items:center; }
.compact-hero { padding-bottom:1.5rem; }

@media (max-width: 900px) {
  .site-header { align-items:stretch; }
  .quick-search-form { order:3; width:100%; min-width:100%; margin-left:0; }
  .site-header .site-top-nav { order:2; margin-left:auto; }
  .advanced-search-form { grid-template-columns:1fr; }
  .library-actions { margin-left:0; }
  .compact-shelf-heading { flex-direction:column; }
  .filter-menu .library-filter-form { left:0; right:auto; }
}

.checkbox-filter-group { border:1px solid #eadfce; border-radius:18px; padding:1rem; background:#fffaf7; }
.checkbox-filter-group legend { padding:0 .35rem; font-weight:900; color:#3c2818; }
.compact-checkbox-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:.5rem; margin-top:.5rem; max-height:none; overflow:visible; }
.advanced-search-form .checkbox-filter-group.wide { grid-column:1 / -1; }
.checkbox-card.compact { font-size:.9rem; padding:.5rem .65rem; }

/* Refined quick search and advanced search layout */
.site-header .quick-search-form { flex: 1 1 260px; max-width: 420px; min-width: 240px; margin-left: auto; }
.site-header .quick-search-box { position: relative; width: 100%; display: block; }
.site-header .quick-search-form input[type="search"] {
  display: block;
  width: 100%;
  height: 2.65rem;
  box-sizing: border-box;
  padding: .62rem 3rem .62rem 1rem;
  border: 1px solid #e5dccf;
  border-radius: 999px;
  background: #fffaf4;
  color: #2f2418;
  box-shadow: inset 0 1px 2px rgba(47,36,24,.05);
}
.site-header .quick-search-form input[type="search"]::-webkit-search-cancel-button { margin-right: 2.05rem; }
.site-header .quick-search-form button {
  position: absolute;
  z-index: 2;
  right: .28rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.1rem;
  height: 2.1rem;
  min-width: 2.1rem;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: #5a3217;
  color: #fffaf4;
  cursor: pointer;
  line-height: 1;
}
.site-header .quick-search-form button span { display:block; line-height:1; font-size:1rem; }

.refined-search-card { padding: 1.15rem; }
.advanced-search-refined { display: grid; gap: 1rem; }
.advanced-search-topline { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 240px); gap: .85rem; align-items: end; }
.advanced-search-topline label,
.advanced-search-sort,
.advanced-search-text { display: grid; gap: .4rem; font-weight: 900; color: #5a3217; }
.advanced-search-topline input,
.advanced-search-topline select { width: 100%; }
.advanced-search-quick-row { display: grid; grid-template-columns: 1.15fr .85fr; gap: .85rem; align-items: start; }
.soft-filter-card { margin: 0; background: #fffaf7; }
.pill-checkbox-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .55rem; }
.checkbox-pill { display: inline-flex; align-items: center; gap: .42rem; padding: .46rem .65rem; border: 1px solid #eadfce; border-radius: 999px; background: #fff; font-weight: 800; color: #3c2818; cursor: pointer; }
.checkbox-pill input { width: auto; accent-color: #5a3217; }
.advanced-filter-accordion { display: grid; gap: .75rem; }
.advanced-filter-section { border: 1px solid #eadfce; border-radius: 18px; background: #fffaf7; overflow: hidden; }
.advanced-filter-section > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; font-weight: 950; color: #3c2818; background: linear-gradient(180deg, #fffdf9, #fff5e8); }
.advanced-filter-section > summary::-webkit-details-marker { display: none; }
.advanced-filter-section > summary::after { content: '+'; width: 1.65rem; height: 1.65rem; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: #5a3217; color: #fffaf4; font-weight: 900; flex: 0 0 auto; }
.advanced-filter-section[open] > summary::after { content: '–'; }
.advanced-filter-section summary span { font-size: 1.02rem; }
.advanced-filter-section summary small { margin-left: auto; color: #7b6551; font-weight: 800; }
.refined-checkbox-grid { padding: 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .55rem; }
.search-note { margin: .85rem 1rem 0; padding: .7rem .85rem; border-radius: 14px; background: #fff; color: #6b5846; font-size: .92rem; }
.sticky-search-actions { position: sticky; bottom: .75rem; z-index: 5; padding: .75rem; border: 1px solid #eadfce; border-radius: 999px; background: rgba(255,250,244,.94); backdrop-filter: blur(8px); box-shadow: 0 12px 30px rgba(47,36,24,.12); justify-content: flex-end; }

@media (max-width: 900px) {
  .site-header .quick-search-form { order: 3; max-width: none; width: 100%; min-width: 100%; margin-left: 0; }
  .advanced-search-topline,
  .advanced-search-quick-row { grid-template-columns: 1fr; }
  .sticky-search-actions { border-radius: 1.25rem; justify-content: stretch; }
  .sticky-search-actions .button { flex: 1 1 auto; text-align: center; }
}


/* Advanced search redesign - clean two-panel layout */
.site-header .quick-search-inline,
.site-header .quick-search-form {
  display: block !important;
  position: relative !important;
  flex: 1 1 280px;
  max-width: 430px;
  min-width: 250px;
  margin-left: auto;
}
.site-header .quick-search-box {
  position: relative !important;
  display: block !important;
  width: 100%;
}
.site-header .quick-search-box input[type="search"] {
  display: block !important;
  width: 100% !important;
  padding-right: 3.05rem !important;
}
.site-header .quick-search-box button {
  position: absolute !important;
  top: 50% !important;
  right: .28rem !important;
  left: auto !important;
  transform: translateY(-50%) !important;
  margin: 0 !important;
  z-index: 3 !important;
}
.advanced-page .advanced-hero-clean { margin-bottom: 1rem; }
.advanced-search-shell { margin: 1rem 0 2rem; }
.advanced-search-clean {
  display: grid;
  grid-template-columns: minmax(280px, .78fr) minmax(0, 1.22fr);
  gap: 1rem;
  align-items: start;
}
.search-panel,
.filter-panel {
  border: 1px solid #eadfce;
  border-radius: 24px;
  background: #fffaf4;
  box-shadow: 0 14px 35px rgba(47,36,24,.08);
  padding: 1rem;
}
.primary-search-panel { position: sticky; top: .75rem; display: grid; gap: .9rem; }
.search-panel h2,
.filter-panel h2 { margin: .1rem 0 0; font-size: 1.28rem; }
.field-label { display: grid; gap: .4rem; font-weight: 900; color: #5a3217; }
.field-label input,
.field-label select { width: 100%; }
.two-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.status-strip { border: 0; padding: 0; margin: 0; }
.status-strip legend { margin-bottom: .45rem; font-weight: 900; color: #5a3217; }
.status-choice-row { display: flex; gap: .45rem; flex-wrap: wrap; }
.choice-chip { display: inline-flex; align-items: center; gap: .36rem; padding: .42rem .58rem; border: 1px solid #eadfce; border-radius: 999px; background: #fff; font-weight: 800; font-size: .9rem; cursor: pointer; }
.choice-chip input { width: auto; accent-color: #5a3217; }
.filter-panel-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; margin-bottom: .75rem; }
.selected-count { white-space: nowrap; border-radius: 999px; background: #f1e4d4; color: #5a3217; padding: .35rem .65rem; font-weight: 900; font-size: .86rem; }
.clean-filter-group { border: 1px solid #eadfce; border-radius: 18px; background: #fff; margin-top: .7rem; overflow: hidden; }
.clean-filter-group > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .82rem .95rem; font-weight: 950; color: #3c2818; }
.clean-filter-group > summary::-webkit-details-marker { display: none; }
.clean-filter-group > summary::after { content: '+'; display: inline-flex; align-items: center; justify-content: center; width: 1.45rem; height: 1.45rem; border-radius: 999px; background: #5a3217; color: #fffaf4; font-weight: 900; }
.clean-filter-group[open] > summary::after { content: '–'; }
.clean-filter-group summary small { margin-left: auto; color: #7b6551; font-weight: 800; }
.filter-help { margin: 0 .95rem .65rem; color: #6b5846; font-size: .92rem; }
.clean-checkbox-grid {
  padding: 0 .95rem .95rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: .42rem;
}
.clean-check { display: flex; align-items: center; gap: .45rem; min-height: 2.2rem; padding: .38rem .5rem; border-radius: 12px; font-weight: 750; color: #3c2818; }
.clean-check:hover { background: #fff5e8; }
.clean-check input { width: auto; accent-color: #5a3217; }
.clean-search-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: .65rem;
  flex-wrap: wrap;
  padding: .85rem 1rem;
  border: 1px solid #eadfce;
  border-radius: 20px;
  background: #fffaf4;
}
@media (max-width: 900px) {
  .site-header .quick-search-inline,
  .site-header .quick-search-form { order: 3; width: 100%; max-width: none; min-width: 100%; margin-left: 0; }
  .advanced-search-clean { grid-template-columns: 1fr; }
  .primary-search-panel { position: static; }
  .two-field-row { grid-template-columns: 1fr; }
  .clean-search-actions { justify-content: stretch; }
  .clean-search-actions .button { flex: 1 1 auto; text-align: center; }
}

/* Advanced search usability: select all, counters, chips */
.site-header .quick-search-box {
  position: relative !important;
  display: block !important;
  width: 100% !important;
}
.site-header .quick-search-box input[type="search"] {
  height: 2.7rem !important;
  padding-right: 3.2rem !important;
  box-sizing: border-box !important;
}
.site-header .quick-search-box button[type="submit"] {
  position: absolute !important;
  right: .32rem !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 2.1rem !important;
  height: 2.1rem !important;
  min-width: 2.1rem !important;
  border-radius: 999px !important;
}
.advanced-search-enhanced .primary-search-panel { gap: 1rem; }
.advanced-search-enhanced .two-field-row { grid-template-columns: 1fr; }
.enhanced-choice-group { border-top: 1px solid #eadfce; padding-top: .85rem; }
.filter-mini-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .45rem; }
.filter-mini-head legend { margin: 0; padding: 0; }
.filter-mini-head small { color: #7b6551; font-weight: 850; }
.compact-choice-row { gap: .4rem; }
.selected-filter-summary { border: 1px dashed #d8c4ac; border-radius: 16px; padding: .8rem; background: #fffdf9; margin-bottom: .75rem; }
.selected-filter-summary strong { display: block; color: #3c2818; margin-bottom: .55rem; }
.selected-chip-wrap { display: flex; flex-wrap: wrap; gap: .45rem; }
.selected-chip { display: inline-flex; align-items: center; border: 1px solid #eadfce; border-radius: 999px; padding: .36rem .58rem; background: #fff5e8; color: #5a3217; font-weight: 850; font-size: .86rem; }
button.selected-chip { cursor: pointer; }
button.selected-chip:hover { background: #f0e0cc; }
.filter-tools-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .65rem; align-items: center; padding: 0 .95rem .75rem; }
.filter-search-label { display: block; }
.filter-search-input { width: 100%; border: 1px solid #eadfce; border-radius: 999px; padding: .55rem .8rem; background: #fffaf4; }
.filter-bulk-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.mini-button { border: 1px solid #5a3217; background: #5a3217; color: #fffaf4; border-radius: 999px; padding: .48rem .7rem; font-weight: 900; cursor: pointer; font-size: .84rem; }
.mini-button.ghost { background: #fffaf4; color: #5a3217; border-color: #eadfce; }
.enhanced-checkbox-grid { max-height: min(42vh, 430px); overflow: auto; padding-top: .1rem; scrollbar-width: thin; }
.clean-check[hidden] { display: none !important; }
.sticky-advanced-actions { position: sticky; bottom: .8rem; z-index: 8; box-shadow: 0 14px 35px rgba(47,36,24,.14); backdrop-filter: blur(8px); background: rgba(255,250,244,.95); }
@media (max-width: 700px) {
  .filter-tools-row { grid-template-columns: 1fr; }
  .filter-bulk-actions { justify-content: stretch; }
  .filter-bulk-actions .mini-button { flex: 1 1 auto; }
  .enhanced-checkbox-grid { max-height: none; overflow: visible; }
}

/* Natural Reader / text-to-speech compatibility */
.natural-reader-document,
.natural-reader-body,
.chapter-content {
  user-select: text;
  -webkit-user-select: text;
}
.reader-mode-body {
  background: #fffaf4;
}
.reader-mode-page {
  max-width: 78ch;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 3rem);
}
.reader-mode-page .natural-reader-document {
  background: #fff;
  border: 1px solid #eadfce;
  border-radius: 1.5rem;
  padding: clamp(1.25rem, 4vw, 3rem);
  box-shadow: 0 18px 45px rgba(47,36,24,.08);
}
.natural-reader-body p {
  margin: 1.15rem 0;
}


/* Final search/header cleanup */
.site-header .quick-search-form { flex: 1 1 260px; max-width: 420px; min-width: 220px; margin-left: auto; }
.site-header .quick-search-box { position: relative; display: block; width: 100%; }
.site-header .quick-search-box input[type="search"] { width: 100%; box-sizing: border-box; padding-right: 3rem !important; }
.site-header .quick-search-box button[type="submit"] { position: absolute !important; right: .35rem !important; top: 50% !important; transform: translateY(-50%) !important; margin: 0 !important; }
.language-switcher { display:inline-flex; align-items:center; margin:0 .25rem; }
.language-switcher select { border:1px solid rgba(90,50,23,.22); border-radius:999px; background:#fffaf4; padding:.45rem .65rem; font-weight:800; color:#5a3217; }
.language-badge { white-space: nowrap; margin-left:.35rem; }
.inline-bulk { margin:.2rem 0 .4rem; }
.sticky-advanced-actions { position: static !important; bottom: auto !important; z-index: auto !important; margin-top: 1rem; }
.advanced-search-clean { padding-bottom: 0 !important; }
.status-strip .inline-bulk { justify-content:flex-start; }
@media (max-width: 760px) {
  .site-header .quick-search-form { order: 3; width: 100%; max-width: none; min-width: 100%; margin-left: 0; }
  .language-switcher { order: 2; }
}

.translation-table-wrap { overflow:auto; max-width:100%; }
.translation-table { width:100%; border-collapse:separate; border-spacing:0 .35rem; }
.translation-table th { text-align:left; vertical-align:top; color:#5a3217; }
.translation-table td, .translation-table th { padding:.35rem; }
.translation-table textarea { width:100%; min-width:220px; }


/* Final advanced search action-bar and SVG language flag fixes */
.advanced-page .advanced-search-shell,
.advanced-page .advanced-search-clean,
.advanced-page .primary-search-panel,
.advanced-page .secondary-filter-panel { overflow: visible !important; }
.advanced-page .advanced-search-clean { padding-bottom: 1.5rem !important; }
.advanced-page .sticky-advanced-actions,
.advanced-page .clean-search-actions.sticky-advanced-actions {
  position: static !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  z-index: auto !important;
  grid-column: 1 / -1 !important;
  width: 100% !important;
  margin: 1.25rem 0 0 !important;
  transform: none !important;
  box-shadow: 0 10px 24px rgba(47,36,24,.08) !important;
}
.lang-flag {
  width: 1.35em;
  height: .95em;
  border-radius: .14em;
  object-fit: cover;
  vertical-align: -0.15em;
  display: inline-block;
  margin-right: .35em;
  box-shadow: 0 0 0 1px rgba(60,40,20,.16);
  background: #fff;
}
.language-badge { display: inline-flex; align-items: center; gap: .1rem; }
.language-badge .lang-flag { margin-right: .25em; }
.admin-lang-flag { width: 2rem; height: 1.35rem; margin-right: 0; }
@media (max-width: 700px) {
  .advanced-page .clean-search-actions.sticky-advanced-actions {
    position: sticky !important;
    bottom: .5rem !important;
    z-index: 20 !important;
  }
  .advanced-page .advanced-search-clean { padding-bottom: 6.5rem !important; }
}


/* Final fixes: no advanced-search action overlap, flag shown beside language dropdown, clamped advanced result synopses */
.advanced-page .clean-search-actions.advanced-action-row {
  position: relative !important;
  inset: auto !important;
  z-index: 1 !important;
  grid-column: 1 / -1 !important;
  width: auto !important;
  margin: 1.5rem 0 0 !important;
  transform: none !important;
  clear: both !important;
  box-shadow: 0 10px 24px rgba(47,36,24,.08) !important;
}
.advanced-page .advanced-search-clean { padding-bottom: 0 !important; }
.advanced-page .primary-search-panel { position: static !important; }
@media (max-width: 700px) {
  .advanced-page .clean-search-actions.advanced-action-row {
    position: relative !important;
    bottom: auto !important;
    z-index: 1 !important;
  }
  .advanced-page .advanced-search-clean { padding-bottom: 0 !important; }
}
.synopsis-preview.book-synopsis,
.book-card-body .synopsis-preview {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
  max-height: 6.8em;
}
.language-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.language-select-wrap select {
  width: 100%;
  padding-left: 2.8rem !important;
}
.language-select-flag {
  position: absolute;
  left: .8rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
}
.language-select-flag .lang-flag { margin-right: 0; }

/* Header language switcher selected SVG flag */
.language-switcher-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.language-switcher-select-wrap select {
  padding-left: 2.45rem !important;
  min-width: 8.5rem;
}
.language-switcher-flag {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  z-index: 2;
  pointer-events: none;
}
.language-switcher-flag .lang-flag { margin-right: 0; }

/* Extra Natural Reader compatibility: keep story text selectable and keep tools out of reader flow. */
.chapter-content,
.natural-reader-document,
.natural-reader-body,
.natural-reader-body p {
  user-select: text !important;
  -webkit-user-select: text !important;
}
.reader-tools { margin-top: 1rem; }
.reader-tools .button { margin-right: .5rem; margin-bottom: .5rem; }
.chapter-annotation-link a[target="_blank"] { speak: none; }

/* Compact reader tool buttons */
.reader-tools {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-top: .65rem;
}
.icon-button.reader-icon-button {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #eadfce;
  background: #fffaf4;
  color: #5a3217;
  font-weight: 900;
  font-size: .95rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(90, 50, 23, .08);
}
.icon-button.reader-icon-button:hover,
.icon-button.reader-icon-button:focus-visible,
.icon-button.reader-icon-button[aria-pressed="true"] {
  background: #5a3217;
  color: #fffaf4;
}
.inline-reader-plain[hidden],
.chapter-content[hidden] {
  display: none !important;
}

/* Chapter reader controls: compact top-right toolbar and local text resizing. */
.chapter > header {
  position: relative;
  padding-right: 8.5rem;
}
.reader-tools.reader-tools-corner {
  position: absolute;
  top: .15rem;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
  z-index: 3;
}
.reader-tools-corner .reader-icon-button {
  width: 2.05rem;
  height: 2.05rem;
  font-size: .78rem;
}
.chapter-content {
  font-size: calc(1rem * var(--reader-font-scale, 1));
}
.chapter-content p,
.chapter-content li,
.chapter-content blockquote {
  font-size: inherit;
}
@media (max-width: 720px) {
  .chapter > header { padding-right: 0; padding-top: 2.85rem; }
  .reader-tools.reader-tools-corner { top: 0; left: 0; right: auto; }
}

/* Chapter reader controls: icon row above the meta line plus local text resizing. */
.chapter-reading-header {
  position: relative;
}
.chapter-reader-topline {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 2.25rem;
  margin-bottom: .25rem;
}
.reader-tools.reader-tools-corner {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: .4rem;
  margin: 0;
  z-index: 3;
}
.reader-tools-corner .reader-icon-button {
  width: 2.05rem;
  height: 2.05rem;
  font-size: .78rem;
  flex: 0 0 auto;
}
.chapter-meta-line {
  font-size: .92rem;
  line-height: 1.45;
  margin: 0 0 1.1rem;
  max-width: 100%;
}
.chapter-byline {
  font-size: .95rem;
  line-height: 1.45;
}
.chapter-content {
  font-size: calc(1rem * var(--reader-font-scale, 1));
}
.chapter-content p,
.chapter-content li,
.chapter-content blockquote {
  font-size: inherit;
}
@media (min-width: 880px) {
  .chapter-meta-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
@media (max-width: 720px) {
  .chapter-reader-topline {
    justify-content: flex-start;
  }
  .chapter-meta-line {
    font-size: .85rem;
  }
}

/* Final chapter reader toolbar fix: tools are a tidy top-right row above metadata. */
.chapter-reading-header {
  position: relative !important;
  padding-top: 3.25rem !important;
  padding-right: 0 !important;
}
.chapter-reading-header .chapter-reader-topline {
  position: absolute !important;
  top: .65rem !important;
  right: .9rem !important;
  left: auto !important;
  width: auto !important;
  min-height: 2.25rem !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
  z-index: 5 !important;
}
.chapter-reader-spacer { display: none !important; }
.chapter-reading-header .reader-tools.reader-tools-corner {
  position: static !important;
  display: inline-flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: .42rem !important;
  margin: 0 !important;
}
.chapter-reading-header .reader-icon-button {
  width: 2.15rem !important;
  height: 2.15rem !important;
  min-width: 2.15rem !important;
  min-height: 2.15rem !important;
  line-height: 1 !important;
}
.chapter-reading-header .reader-tools a.reader-icon-button:first-child {
  background: #111 !important;
  color: #fff !important;
  border-color: #111 !important;
}
.chapter-reading-header .reader-tools a.reader-icon-button:first-child:hover,
.chapter-reading-header .reader-tools a.reader-icon-button:first-child:focus-visible {
  background: #333 !important;
  color: #fff !important;
}
.chapter-reading-header .chapter-meta-line {
  display: block !important;
  font-size: .86rem !important;
  line-height: 1.35 !important;
  margin: 0 0 .95rem !important;
  white-space: normal !important;
  color: #6b5846 !important;
}
@media (max-width: 720px) {
  .chapter-reading-header { padding-top: 3.1rem !important; }
  .chapter-reading-header .chapter-reader-topline { top: .55rem !important; right: .65rem !important; }
}


/* 2026-05 Natural Reader/header toolbar final override */
.chapter-reading-header {
  position: relative !important;
  padding-top: 0 !important;
  padding-right: 0 !important;
}
.chapter-card-topbar {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 1rem !important;
  margin: 0 0 1rem !important;
}
.chapter-card-topbar .chapter-meta-line {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding-top: .45rem !important;
  font-size: .84rem !important;
  line-height: 1.35 !important;
  white-space: normal !important;
  color: #6b5846 !important;
}
.chapter-card-topbar .reader-tools.reader-tools-corner {
  position: static !important;
  flex: 0 0 auto !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: .5rem !important;
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  min-height: 0 !important;
}
.chapter-card-topbar .reader-icon-button {
  width: 2.25rem !important;
  height: 2.25rem !important;
  min-width: 2.25rem !important;
  min-height: 2.25rem !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  vertical-align: middle !important;
  transform: none !important;
  font-size: .9rem !important;
}
.chapter-card-topbar .reader-raw-button {
  background: #111 !important;
  color: #fff !important;
  border-color: #111 !important;
}
.chapter-card-topbar .reader-raw-button:hover,
.chapter-card-topbar .reader-raw-button:focus-visible {
  background: #333 !important;
  color: #fff !important;
}
.chapter-reader-topline,
.chapter-reader-spacer { display: none !important; }
@media (min-width: 880px) {
  .chapter-card-topbar .chapter-meta-line {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}
@media (max-width: 720px) {
  .chapter-card-topbar {
    align-items: stretch !important;
    flex-direction: column-reverse !important;
  }
  .chapter-card-topbar .reader-tools.reader-tools-corner {
    justify-content: flex-end !important;
  }
}


/* Reader icon alignment and tooltips fix */
.chapter-card-topbar .reader-tools.reader-tools-corner,
.reader-tools.reader-tools-corner {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: .55rem !important;
}
.chapter-card-topbar .reader-tools.reader-tools-corner > .reader-icon-button,
.chapter-card-topbar .reader-tools.reader-tools-corner > a.reader-icon-button,
.chapter-card-topbar .reader-tools.reader-tools-corner > button.reader-icon-button {
  box-sizing: border-box !important;
  width: 2.45rem !important;
  height: 2.45rem !important;
  min-width: 2.45rem !important;
  min-height: 2.45rem !important;
  max-width: 2.45rem !important;
  max-height: 2.45rem !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  align-self: center !important;
  line-height: 1 !important;
  font-size: 1rem !important;
  text-decoration: none !important;
  vertical-align: middle !important;
  transform: none !important;
  position: relative !important;
  top: 0 !important;
}
.chapter-card-topbar .reader-tools.reader-tools-corner > .reader-raw-button {
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  line-height: 1 !important;
}

.button.danger{background:#8b1e1e;color:#fff;border-color:#8b1e1e}.button.danger:hover{filter:brightness(.95)}
.danger-zone{border-color:#e3b4a8;background:#fff8f6;margin-bottom:1.25rem}.danger-zone summary{cursor:pointer;display:flex;justify-content:space-between;gap:1rem;align-items:center}.danger-zone summary small{display:block;color:#8b5f51;font-weight:400}.danger-zone form{margin-top:1rem;display:grid;gap:1rem}

.autosave-status,
.autosave-restore {
  margin: 1rem 0;
  padding: .85rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(124, 92, 55, .18);
  background: rgba(255,255,255,.82);
  box-shadow: 0 8px 24px rgba(30, 20, 10, .06);
}
.autosave-status.ok { color: #23622f; }
.autosave-status.warn { color: #8a5a00; }
.autosave-restore { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.autosave-restore strong { display: block; }
.autosave-restore span { color: var(--muted, #776b60); font-size: .9rem; }
.autosave-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.chapter-import-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  padding: .9rem 1rem;
  border: 1px solid rgba(105, 83, 62, .18);
  border-radius: 16px;
  background: rgba(255, 250, 242, .78);
}
.chapter-import-panel strong { display: block; margin-bottom: .2rem; }
.chapter-import-actions { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.chapter-import-actions input[type="file"] { max-width: 260px; }
.chapter-import-actions .import-replace { margin: 0; padding: .45rem .65rem; min-height: auto; }
.import-status { width: 100%; font-size: .9rem; color: #5f503f; }
.import-status.ok { color: #226235; }
.import-status.warn { color: #8a4b13; }
@media (max-width: 760px) {
  .chapter-import-panel { align-items: stretch; }
  .chapter-import-actions { width: 100%; align-items: stretch; }
  .chapter-import-actions input[type="file"], .chapter-import-actions button { width: 100%; max-width: none; }
}

.import-status {
  width: 100%;
  margin-top: .65rem;
  padding: .65rem .8rem;
  border-radius: 12px;
  font-size: .92rem;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(76,45,24,.12);
  color: var(--muted);
}
.import-status.info { color: #5f4a36; }
.import-status.ok { color: #23613b; background: rgba(224, 245, 229, .9); border-color: rgba(35, 97, 59, .2); }
.import-status.warn { color: #8a3b1e; background: rgba(255, 235, 222, .92); border-color: rgba(138, 59, 30, .22); }
#chapterImportButton[aria-busy="true"] { opacity: .75; cursor: wait; }
