/* =============================================
   TANSINH BOOKSHELF — Full Stylesheet
   ============================================= */

:root {
  --ink: #1a1a2e;
  --ink-light: #2d2d4e;
  --warm: #f5f0e8;
  --cream: #faf8f4;
  --paper: #ffffff;
  --accent: #c0392b;
  --accent-light: #e74c3c;
  --gold: #d4a04a;
  --gold-light: #f0d68a;
  --gold-bg: rgba(212,160,74,0.1);
  --muted: #8a8578;
  --border: #e8e2d8;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(26,26,46,0.07);
  --shadow-lg: 0 12px 40px rgba(26,26,46,0.12);
  --transition: 0.25s ease;
  --sidebar-w: 260px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100svh;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--warm);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(212,160,74,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(192,57,43,0.05) 0%, transparent 50%),
    var(--warm);
}

.card {
  width: 100%;
  max-width: 420px;
  padding: 36px 28px 40px;
  background: var(--paper);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fadeSlideUp 0.5s ease both;
}

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

.logo {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.logo i { color: var(--gold); font-size: 1.4rem; }

.subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 26px;
}

/* -- Form fields -- */
.field { position: relative; margin-bottom: 14px; }

.field input {
  width: 100%;
  padding: 14px 44px 14px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--cream);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.field input:focus {
  border-color: var(--gold);
  background: var(--paper);
  box-shadow: 0 0 0 4px var(--gold-bg);
}
.field input::placeholder { color: #b5ad9e; }

.toggle-password {
  position: absolute;
  top: 50%; right: 12px;
  transform: translateY(-50%);
  border: none; background: none;
  cursor: pointer; font-size: 1rem;
  color: #b5ad9e; padding: 2px 6px; border-radius: 8px;
}
.toggle-password:hover { color: var(--gold); }

/* -- Login button -- */
.btn {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--gold);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition), transform 0.05s ease;
}
.btn:hover, .btn:focus-visible { background: var(--gold-light); }
.btn:active { transform: translateY(1px); }

#message {
  margin-top: 14px;
  font-size: 0.88rem;
  font-weight: 500;
  min-height: 1.2em;
}
.error { color: var(--accent); }
.success { color: #269f53; }


/* =============================================
   TOP BAR
   ============================================= */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 2px 16px rgba(0,0,0,0.18);
}
.topbar-left {
  display: flex; align-items: center; gap: 8px;
}
.sidebar-toggle {
  width: 36px; height: 36px;
  border: none; border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: #fff; font-size: 1rem;
  cursor: pointer; display: grid; place-items: center;
  transition: background 0.2s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.15); }
.topbar-logo {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.2rem; font-weight: 700;
  display: flex; align-items: center; gap: 9px;
  letter-spacing: -0.02em;
}
.topbar-logo i { color: var(--gold); font-size: 1rem; }
.topbar-actions { display: flex; gap: 6px; align-items: center; }

.btn-topbar {
  padding: 7px 14px; border: none; border-radius: 8px;
  font-family: inherit; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  background: rgba(255,255,255,0.1); color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-topbar:hover { background: rgba(255,255,255,0.18); }
.btn-logout {
  width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(192,57,43,0.15); color: #e88; border-color: rgba(192,57,43,0.25);
}
.btn-logout:hover { background: rgba(192,57,43,0.3); color: #fff; }


/* =============================================
   ADMIN LAYOUT (SIDEBAR + MAIN)
   ============================================= */
.admin-layout {
  display: flex;
  min-height: calc(100svh - 56px);
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--paper);
  border-right: 1.5px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
  position: sticky;
  top: 56px;
  height: calc(100svh - 56px);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.sidebar-section {
  margin-bottom: 4px;
  padding-bottom: 4px;
}
.sidebar-section + .sidebar-section {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.sidebar-heading {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.sidebar-heading span {
  display: flex; align-items: center; gap: 6px;
}
.sidebar-heading i { font-size: 0.6rem; }

.sidebar-add-btn {
  width: 20px; height: 20px;
  border: 1.5px dashed var(--gold);
  border-radius: 6px;
  background: transparent;
  color: var(--gold);
  cursor: pointer; display: grid; place-items: center;
  font-size: 0.58rem;
  transition: all 0.2s;
}
.sidebar-add-btn:hover { background: var(--gold); color: #fff; border-style: solid; }

.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  margin: 2px 10px;
  font-size: 0.82rem; font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  border-radius: 10px;
  border-left: none;
}
.sidebar-item:hover {
  background: var(--cream);
}
.sidebar-item.active {
  background: var(--gold-bg);
  font-weight: 600;
  color: var(--ink);
}
.sidebar-item i {
  font-size: 0.76rem;
  width: 18px; text-align: center;
  color: var(--muted);
}
.sidebar-item.active i { color: var(--gold); }
.sidebar-item span.sidebar-cat-dot { flex: 0 0 auto; }
.sidebar-item span:not(.sidebar-cat-dot):not(.sidebar-count) { flex: 1; }

.sidebar-count {
  font-size: 0.66rem;
  font-weight: 700;
  background: var(--cream);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 24px;
  text-align: center;
  line-height: 1.3;
}
.sidebar-item.active .sidebar-count {
  background: var(--gold);
  color: #fff;
}

/* Category dot in sidebar */
.sidebar-cat-dot {
  width: 10px; height: 10px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.06);
}

/* Manage categories link */
.sidebar-manage {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  margin: 4px 10px 2px;
  font-size: 0.72rem; font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 8px;
}
.sidebar-manage:hover { color: var(--accent); background: #fef2f2; }
.sidebar-manage i { font-size: 0.64rem; }

/* --- MAIN CONTENT --- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 24px 60px;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 89;
  background: rgba(26,26,46,0.35);
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }


/* =============================================
   SECTION HEADER
   ============================================= */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 10px;
}
.section-title {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.5rem; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}
.section-title i { color: var(--gold); font-size: 1.1rem; }

/* Active filter chips */
.active-filters {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px 4px 10px;
  background: var(--gold-bg);
  border: 1px solid rgba(212,160,74,0.25);
  border-radius: 20px;
  font-size: 0.74rem; font-weight: 600;
  color: var(--ink);
}
.filter-chip .chip-dot {
  width: 7px; height: 7px; border-radius: 50%;
}
.filter-chip .chip-remove {
  width: 16px; height: 16px;
  border: none; border-radius: 50%;
  background: rgba(0,0,0,0.06);
  color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
  font-size: 0.6rem; margin-left: 2px;
  transition: all 0.15s;
}
.filter-chip .chip-remove:hover { background: var(--accent); color: #fff; }


/* =============================================
   BOOK GRID
   ============================================= */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 20px;
}

.book-card {
  background: var(--paper);
  border-radius: 16px;
  border: 1.5px solid var(--border);
  padding: 0;
  cursor: pointer;
  transition: all 0.32s cubic-bezier(.4,0,.2,1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 180px;
}
.book-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 16px 16px 0 0;
  z-index: 1;
}

/* Book cover image */
.book-cover {
  width: 100%;
  max-height: 240px;
  overflow: hidden;
  background: #f5f0e6;
}
.book-cover img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  display: block;
}
.book-card:has(.book-cover) h3 {
  padding-top: 14px;
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 36px rgba(26,26,46,0.12);
  border-color: var(--gold);
}
.book-card h3 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.18rem; font-weight: 700;
  margin-bottom: 8px; padding: 24px 22px 0 22px;
  line-height: 1.35;
  color: var(--ink);
}
.book-card .book-desc {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0 22px;
  margin-bottom: 8px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* Book tags (category + level) */
.book-tags {
  display: flex; gap: 6px; padding-left: 22px; padding-right: 22px; margin-bottom: 10px; flex-wrap: wrap;
}
.book-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.68rem; font-weight: 600;
  background: var(--cream);
  color: var(--muted);
}
.book-tag .tag-dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.book-tag-level {
  background: rgba(41,128,185,0.1);
  color: #2980b9;
}

.book-card .meta {
  font-size: 0.76rem; color: var(--muted); padding: 0 22px;
  display: flex; gap: 14px; align-items: center;
  flex: 1;
}
.book-card .meta i { font-size: 0.68rem; }

/* Actions - hidden by default, show on hover */
.book-card .actions {
  display: flex; gap: 6px; padding: 12px 22px;
  border-top: 1px solid var(--border);
  background: var(--cream);
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}
.book-card:hover .actions {
  opacity: 1;
  max-height: 60px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.book-card .actions button {
  padding: 6px 13px; border: none; border-radius: 8px;
  font-family: inherit; font-size: 0.74rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}

.btn-link { background: var(--cream); color: var(--ink); border: 1px solid var(--border) !important; }
.btn-link:hover { background: var(--warm); }
.btn-edit-book { background: var(--gold-bg); color: var(--gold); }
.btn-edit-book:hover { background: rgba(212,160,74,0.2); }
.btn-delete { background: #fef2f2; color: var(--accent); }
.btn-delete:hover { background: #fde8e8; }

/* -- Add book card -- */
.add-book-card {
  background: transparent;
  border: 2px dashed rgba(212,160,74,0.35);
  border-radius: 16px;
  padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.32s cubic-bezier(.4,0,.2,1);
  min-height: 180px;
}
.add-book-card:hover {
  border-color: var(--gold);
  background: var(--paper);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.add-book-card i { font-size: 2.4rem; color: var(--gold); transition: transform 0.3s; }
.add-book-card:hover i { transform: scale(1.15); }
.add-book-card span { font-size: 0.88rem; font-weight: 600; color: var(--muted); }


/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(26,26,46,0.45);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--paper);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px;
  padding: 28px;
  animation: modalSlide 0.3s ease;
}
.modal-wide { max-width: 520px; }

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.25rem; font-weight: 700; margin-bottom: 16px;
}
.modal label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--muted); margin-bottom: 5px; margin-top: 14px;
}
.modal label:first-of-type { margin-top: 0; }
.modal input, .modal textarea, .modal select {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 0.88rem;
  background: var(--cream); color: var(--ink);
  outline: none; transition: border 0.2s;
}
.modal input:focus, .modal textarea:focus, .modal select:focus {
  border-color: var(--gold); background: var(--paper);
}
.modal textarea { resize: vertical; min-height: 72px; line-height: 1.6; }
.modal select { cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a8578' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

/* Modal row for side-by-side fields */
.modal-row {
  display: flex; gap: 12px; margin-top: 14px;
}
.modal-col { flex: 1; }
.modal-col label { margin-top: 0; }

.modal-btns { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
.modal-btns button {
  padding: 9px 22px; border: none; border-radius: 10px;
  font-family: inherit; font-size: 0.84rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.btn-save { background: var(--gold); color: var(--ink); }
.btn-save:hover { background: var(--gold-light); }
.btn-cancel { background: var(--cream); color: var(--ink); border: 1.5px solid var(--border) !important; }
.btn-cancel:hover { background: var(--warm); }

/* Color picker */
.color-picker {
  display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap;
}
.color-dot {
  width: 30px; height: 30px;
  border: 2.5px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(26,26,46,0.12);
}

/* Manage categories list in modal */
.manage-cat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.manage-cat-item:hover { border-color: var(--gold); }
.manage-cat-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.manage-cat-name {
  flex: 1; font-size: 0.88rem; font-weight: 600;
}
.manage-cat-actions { display: flex; gap: 4px; }
.manage-cat-actions button {
  width: 28px; height: 28px; border: none; border-radius: 6px;
  background: var(--cream); color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
  font-size: 0.72rem; transition: all 0.2s;
}
.manage-cat-actions button:hover { background: var(--warm); color: var(--ink); }
.manage-cat-actions .del-cat:hover { background: #fef2f2; color: var(--accent); }


/* =============================================
   BREADCRUMB & BOOK HEADER
   ============================================= */
.breadcrumb {
  font-size: 0.82rem; color: var(--muted); margin-bottom: 14px;
  display: flex; align-items: center; gap: 7px;
}
.breadcrumb a {
  color: var(--accent); text-decoration: none; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.breadcrumb a:hover { text-decoration: underline; }

.book-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.book-header h2 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.4rem; font-weight: 700;
}
.btn-gold {
  padding: 9px 18px; border: none; border-radius: 10px;
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; background: var(--gold); color: var(--ink);
  transition: all 0.2s; display: flex; align-items: center; gap: 6px;
}
.btn-gold:hover { background: var(--gold-light); }


/* =============================================
   CHAPTER LIST
   ============================================= */
.chapter-item {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
  transition: all 0.22s;
  cursor: pointer;
}
.chapter-item:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow);
  transform: translateX(3px);
}
.ch-info { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.ch-num {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #fff; font-size: 0.8rem; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
}
.ch-title { font-weight: 600; font-size: 0.9rem; }
.ch-actions { display: flex; gap: 5px; }
.ch-actions button {
  width: 32px; height: 32px; border: none; border-radius: 8px;
  background: var(--cream); color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
  font-size: 0.75rem; transition: all 0.2s;
}
.ch-actions button:hover { background: var(--warm); color: var(--ink); }
.ch-actions .del-ch:hover { background: #fef2f2; color: var(--accent); }


/* =============================================
   CONTENT EDITOR
   ============================================= */
.content-editor {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 14px;
  animation: fadeSlideUp 0.3s ease;
}
.content-editor h3 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.1rem; font-weight: 700; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.content-editor h3 i { color: var(--gold); }
.content-editor textarea {
  width: 100%; min-height: 240px; padding: 16px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 0.9rem; line-height: 1.75;
  background: var(--cream); color: var(--ink);
  outline: none; resize: vertical; transition: border 0.2s;
}


#ceEditorWrapper:focus-within { border-color: var(--gold) !important; background: var(--paper); }
#ceEditorWrapper .ql-toolbar { border: none !important; border-bottom: 1px solid var(--border) !important; background: var(--warm); }
#ceEditorWrapper .ql-container { border: none !important; font-family: 'DM Sans', system-ui, sans-serif; font-size: 0.9rem; min-height: 240px; }
#ceEditorWrapper .ql-editor { min-height: 240px; line-height: 1.75; padding: 16px; color: var(--ink); }


.content-editor textarea:focus { border-color: var(--gold); background: var(--paper); }
.editor-btns { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.editor-btns button {
  padding: 9px 20px; border: none; border-radius: 10px;
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  text-align: center; padding: 52px 20px;
  color: var(--muted); font-size: 0.9rem;
}
.empty-state i {
  font-size: 2.8rem; color: var(--border);
  margin-bottom: 12px; display: block;
}


/* =============================================
   PUBLIC READER VIEW
   ============================================= */
.reader-wrap {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 20px 60px;
  overflow: visible;
}

.reader-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 12px 24px;
  background: var(--ink);
  color: #fff;
  margin-bottom: 0;
  box-shadow: 0 2px 16px rgba(0,0,0,0.18);
}
.reader-topbar-logo {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.1rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.reader-topbar-logo i { color: var(--gold); }

.reader-cover {
  text-align: center; padding: 48px 28px;
  background: linear-gradient(135deg, var(--ink) 0%, #2d2d4e 60%, #3b1f3d 100%);
  border-radius: 20px; color: #fff;
  margin-bottom: 28px;
  position: relative; overflow: hidden;
}
.reader-cover::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M20 20.5V18H0v-2h20V0h2v16h18v2H22v4.5a2.5 2.5 0 1 1-2 0z'/%3E%3C/g%3E%3C/svg%3E");
}
.reader-cover::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--accent));
}
.reader-cover h1 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 2.1rem; font-weight: 700;
  position: relative; margin-bottom: 10px; line-height: 1.3;
}
.reader-cover p {
  font-size: 0.92rem; opacity: 0.65; position: relative; max-width: 480px; margin: 0 auto;
}
.reader-cover .reader-tags {
  display: flex; gap: 8px; justify-content: center; margin-top: 14px; position: relative;
}
.reader-cover .reader-tag {
  padding: 4px 14px; border-radius: 20px;
  font-size: 0.76rem; font-weight: 600;
  background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8);
}

.reader-toc { margin-bottom: 28px; }
.reader-toc h3 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.05rem; font-weight: 700; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.reader-toc h3 i { color: var(--gold); }

.toc-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.22s;
  text-decoration: none; color: inherit;
}
.toc-item:hover {
  border-color: var(--gold); box-shadow: var(--shadow);
  transform: translateX(5px);
}
.toc-num {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--warm); color: var(--accent);
  font-size: 0.76rem; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
}
.toc-label { font-weight: 600; font-size: 0.88rem; }

.reader-chapter {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  margin-bottom: 16px;
  scroll-margin-top: 72px;
  animation: fadeSlideUp 0.4s ease both;
}
.reader-chapter h2 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.25rem; font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--warm);
  display: flex; align-items: center; gap: 10px;
}
.rc-num {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #fff; font-size: 0.72rem; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
}
.rc-body {
  font-size: 0.93rem; line-height: 1.85;
  color: #3a3a3a;
}
.rc-body h1, .rc-body h2, .rc-body h3 {
  margin-top: 1em; margin-bottom: 0.5em;
  font-family: 'Crimson Pro', Georgia, serif;
}
.rc-body h1 { font-size: 1.5rem; }
.rc-body h2 { font-size: 1.25rem; }
.rc-body h3 { font-size: 1.1rem; }
.rc-body p { margin-bottom: 0.8em; }
.rc-body ul, .rc-body ol { margin-left: 1.5em; margin-bottom: 0.8em; }
.rc-body blockquote {
  border-left: 3px solid var(--gold);
  padding-left: 14px;
  color: var(--muted);
  margin: 0.8em 0;
}
.rc-body img { max-width: 100%; border-radius: 8px; margin: 0.5em 0; }
.rc-body a { color: var(--accent); text-decoration: underline; }
.rc-body pre {
  background: var(--cream); padding: 12px;
  border-radius: 8px; overflow-x: auto;
  font-size: 0.85rem; margin: 0.8em 0;
}

.rc-body code { background: var(--cream); padding: 2px 6px; border-radius: 4px; font-size: 0.85rem; }

/* Strip pasted white backgrounds from content */
.rc-body span,
.rc-body p,
.rc-body div,
.rc-body li,
.rc-body td,
.rc-body th,
.rc-body b,
.rc-body strong,
.rc-body a,
.rc-body em,
.rc-body i,
.rc-body u,
.rc-body h1,
.rc-body h2,
.rc-body h3,
.rc-body h4,
.rc-body h5,
.rc-body h6 {
  background-color: transparent !important;
}

/* =============================================
   URL BOX
   ============================================= */
.url-box {
  background: var(--cream); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 11px 14px;
  font-size: 0.8rem; color: var(--ink);
  word-break: break-all;
  display: flex; align-items: center; gap: 10px;
}
.url-box code { flex: 1; font-family: 'DM Sans', monospace; font-size: 0.78rem; }
.url-box button {
  padding: 6px 14px; border: none; border-radius: 8px;
  background: var(--gold); color: var(--ink);
  font-family: inherit; font-size: 0.74rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.url-box button:hover { background: var(--gold-light); }


/* =============================================
   TOAST
   ============================================= */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 11px 26px; border-radius: 12px;
  font-size: 0.84rem; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity 0.3s;
  pointer-events: none; z-index: 300;
}
.toast.show { opacity: 1; }


/* =============================================
   LOADING SPINNER
   ============================================= */
.loading-overlay {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(245,240,232,0.7);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 56px;
    z-index: 90;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    height: calc(100svh - 56px);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    padding: 20px 14px 40px;
  }
}

@media (min-width: 769px) {
  .sidebar-overlay { display: none !important; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 14px; }
  .topbar-logo { font-size: 1rem; }
  .book-grid { grid-template-columns: 1fr; }
  .reader-cover h1 { font-size: 1.55rem; }
  .reader-wrap { padding: 0 14px 40px; }
  .reader-chapter { padding: 22px 18px; }
  .modal { padding: 22px; }
  .modal-row { flex-direction: column; gap: 0; }
}


/* ===== SELECT WITH ACTION BUTTONS ===== */
.select-with-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.select-with-actions select {
  flex: 1;
  min-width: 0;
}
.select-action-btn {
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--cream);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  flex-shrink: 0;
  transition: all 0.2s;
}
.select-action-btn.sa-add:hover {
  background: var(--gold-bg);
  color: var(--gold);
  border-color: var(--gold);
}
.select-action-btn.sa-del:hover {
  background: #fef2f2;
  color: var(--accent);
  border-color: var(--accent);
}


/* Sidebar add book button */
.sidebar-add-book {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 8px 10px 2px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold);
  cursor: pointer;
  border: 1.5px dashed var(--gold);
  border-radius: 10px;
  transition: all 0.2s ease;
}
.sidebar-add-book:hover {
  background: var(--gold-bg);
  border-style: solid;
}
.sidebar-add-book i {
  font-size: 0.76rem;
  width: 18px;
  text-align: center;
}



/* =============================================
   ADD BOOK PAGE
   ============================================= */
.ab-form-card {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  margin-bottom: 20px;
}
.ab-page-title {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.3rem; font-weight: 700;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
.ab-page-title i { color: var(--gold); }

.ab-field { margin-bottom: 14px; }
.ab-field label,
.ab-form-card .modal-col label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--muted); margin-bottom: 5px;
}
.ab-field input, .ab-field textarea {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 0.88rem;
  background: var(--cream); color: var(--ink);
  outline: none; transition: border 0.2s;
}
.ab-field input:focus, .ab-field textarea:focus {
  border-color: var(--gold); background: var(--paper);
}
.ab-field textarea { resize: vertical; min-height: 60px; line-height: 1.6; }

.ab-save-row {
  display: flex; align-items: center; gap: 14px; margin-top: 18px;
}
.ab-saved-badge {
  font-size: 0.82rem; font-weight: 600; color: #269f53;
  display: flex; align-items: center; gap: 5px;
}

.ab-chapters-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.ab-chapters-header h3 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.15rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.ab-chapters-header h3 i { color: var(--gold); }

.ab-add-lesson {
  display: flex; gap: 10px; align-items: center;
  margin-top: 14px; margin-bottom: 20px;
}
.ab-add-lesson input {
  flex: 1; padding: 11px 14px;
  border: 1.5px dashed var(--border); border-radius: 10px;
  font-family: inherit; font-size: 0.88rem;
  background: var(--cream); color: var(--ink);
  outline: none; transition: border 0.2s;
}
.ab-add-lesson input:focus { border-color: var(--gold); border-style: solid; background: var(--paper); }

/* Individual lesson card on add-book page */
.ab-lesson-card {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.ab-lesson-card:hover, .ab-lesson-card.editing { border-color: var(--gold); }

.ab-lesson-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
}
.ab-lesson-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.ab-lesson-num {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #fff; font-size: 0.78rem; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
}
.ab-lesson-name { font-weight: 600; font-size: 0.88rem; }
.ab-lesson-actions { display: flex; gap: 5px; }
.ab-lesson-actions button {
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: var(--cream); color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
  font-size: 0.72rem; transition: all 0.2s;
}
.ab-lesson-actions button:hover { background: var(--warm); color: var(--ink); }
.ab-lesson-actions .ab-del:hover { background: #fef2f2; color: var(--accent); }

.ab-lesson-body {
  padding: 0 18px 16px;
  border-top: 1px solid var(--border);
}
.ab-lesson-body textarea {
  width: 100%; min-height: 160px; padding: 14px;
  margin-top: 12px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 0.88rem; line-height: 1.75;
  background: var(--cream); color: var(--ink);
  outline: none; resize: vertical; transition: border 0.2s;
}
.ab-lesson-body textarea:focus { border-color: var(--gold); background: var(--paper); }
.ab-lesson-save-row {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px;
}
.ab-lesson-save-row button {
  padding: 7px 16px; border: none; border-radius: 8px;
  font-family: inherit; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.ab-content-saved {
  font-size: 0.76rem; color: #269f53; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  opacity: 0; transition: opacity 0.3s;
}
.ab-content-saved.show { opacity: 1; }

/* ===== QUILL CUSTOM FONTS ===== */
.ql-font-roboto { font-family: 'Roboto', sans-serif !important; }
.ql-font-open-sans { font-family: 'Open Sans', sans-serif !important; }
.ql-font-lato { font-family: 'Lato', sans-serif !important; }
.ql-font-montserrat { font-family: 'Montserrat', sans-serif !important; }
.ql-font-poppins { font-family: 'Poppins', sans-serif !important; }
.ql-font-nunito { font-family: 'Nunito', sans-serif !important; }
.ql-font-raleway { font-family: 'Raleway', sans-serif !important; }
.ql-font-inter { font-family: 'Inter', sans-serif !important; }
.ql-font-playfair-display { font-family: 'Playfair Display', serif !important; }
.ql-font-merriweather { font-family: 'Merriweather', serif !important; }
.ql-font-source-sans-3 { font-family: 'Source Sans 3', sans-serif !important; }
.ql-font-noto-sans { font-family: 'Noto Sans', sans-serif !important; }
.ql-font-pt-sans { font-family: 'PT Sans', sans-serif !important; }
.ql-font-quicksand { font-family: 'Quicksand', sans-serif !important; }
.ql-font-oswald { font-family: 'Oswald', sans-serif !important; }

/* Font picker dropdown labels */
.ql-snow .ql-picker.ql-font .ql-picker-label::before,
.ql-snow .ql-picker.ql-font .ql-picker-item::before { content: 'Sans Serif'; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="roboto"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="roboto"]::before { content: 'Roboto'; font-family: 'Roboto', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="open-sans"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="open-sans"]::before { content: 'Open Sans'; font-family: 'Open Sans', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="lato"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="lato"]::before { content: 'Lato'; font-family: 'Lato', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="montserrat"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="montserrat"]::before { content: 'Montserrat'; font-family: 'Montserrat', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="poppins"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="poppins"]::before { content: 'Poppins'; font-family: 'Poppins', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="nunito"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="nunito"]::before { content: 'Nunito'; font-family: 'Nunito', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="raleway"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="raleway"]::before { content: 'Raleway'; font-family: 'Raleway', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="inter"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="inter"]::before { content: 'Inter'; font-family: 'Inter', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="playfair-display"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="playfair-display"]::before { content: 'Playfair Display'; font-family: 'Playfair Display', serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="merriweather"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="merriweather"]::before { content: 'Merriweather'; font-family: 'Merriweather', serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="source-sans-3"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="source-sans-3"]::before { content: 'Source Sans 3'; font-family: 'Source Sans 3', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="noto-sans"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="noto-sans"]::before { content: 'Noto Sans'; font-family: 'Noto Sans', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="pt-sans"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="pt-sans"]::before { content: 'PT Sans'; font-family: 'PT Sans', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="quicksand"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="quicksand"]::before { content: 'Quicksand'; font-family: 'Quicksand', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="oswald"]::before,
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="oswald"]::before { content: 'Oswald'; font-family: 'Oswald', sans-serif; }

/* Size picker labels */
.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before { content: 'Normal'; }
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="small"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="small"]::before { content: 'Small'; }
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="large"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="large"]::before { content: 'Large'; }
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="huge"]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before { content: 'Huge'; }
.ql-snow .ql-size-small { font-size: 0.75em; }
.ql-snow .ql-size-large { font-size: 1.5em; }
.ql-snow .ql-size-huge { font-size: 2em; }

/* ===== QUILL TOOLBAR STYLING ===== */
.ql-toolbar.ql-snow {
  border-color: var(--border) !important;
  background: var(--warm) !important;
  flex-wrap: wrap;
  padding: 6px 8px !important;
}
.ql-toolbar.ql-snow .ql-formats {
  margin-right: 8px !important;
  margin-bottom: 2px;
}
.ql-snow .ql-picker.ql-font {
  width: 150px !important;
}
.ql-snow .ql-picker.ql-font .ql-picker-options {
  max-height: 300px;
  overflow-y: auto;
}
.ql-snow .ql-picker.ql-size {
  width: 80px !important;
}
.ql-snow .ql-picker.ql-header {
  width: 105px !important;
}

/* ===== TABLE STYLES IN EDITOR ===== */
.ql-editor table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}
.ql-editor table td,
.ql-editor table th {
  border: 1.5px solid var(--border);
  padding: 8px 12px;
  min-width: 60px;
  vertical-align: top;
}
.ql-editor table th {
  background: var(--warm);
  font-weight: 600;
}
.ql-editor table td:focus,
.ql-editor table th:focus {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

/* ===== TABLE STYLES IN READER ===== */
.rc-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 0.9rem;
}
.rc-body table td,
.rc-body table th {
  border: 1.5px solid var(--border);
  padding: 10px 14px;
  vertical-align: top;
}
.rc-body table th {
  background: var(--warm);
  font-weight: 600;
  text-align: left;
}
.rc-body table tr:nth-child(even) td {
  background: rgba(245,240,232,0.4);
}

/* ==============================================
   SPLIT-PANEL READER (Kindle-style)
   ============================================== */

/* --- Main 2-column layout --- */
.rdr-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Left sidebar --- */
.rdr-sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--cream);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rdr-sidebar-cover {
  padding: 12px 14px 10px;
  border-bottom: none;
  background: linear-gradient(160deg, #1a1a2e 0%, #2a2848 40%, #3b2740 80%, #4a2040 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.rdr-sidebar-cover::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(212,160,74,0.08);
}
.rdr-sidebar-cover::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--accent), var(--gold));
}

/* Row 1: book name + tags in one line */
.rdr-sidebar-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
}
.rdr-sidebar-title-icon {
  color: var(--gold);
  font-size: 0.85rem;
  opacity: 0.6;
  flex-shrink: 0;
}
.rdr-sidebar-cover h2 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.rdr-sidebar-cover .reader-tag {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.62rem;
  font-weight: 600;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  backdrop-filter: blur(4px);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Row 2: WordWise controls inside sidebar header */
.rdr-sidebar-ww {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 10px;
  position: relative;
}
.rdr-sidebar-ww .ww-bar-label {
  font-size: 0.68rem;
  color: #e8c97a;
  gap: 4px;
}
.rdr-sidebar-ww .ww-bar-label i {
  font-size: 0.62rem;
}
.rdr-sidebar-ww .ww-toggle {
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}
.rdr-sidebar-ww .ww-toggle-slider::before {
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
}
.rdr-sidebar-ww .ww-toggle input:checked + .ww-toggle-slider::before {
  transform: translateX(14px);
}
.rdr-sidebar-ww .ww-level-group {
  gap: 5px;
  font-size: 0.68rem;
}
.rdr-sidebar-ww .ww-level-slider {
  width: 50px;
  height: 3px;
}
.rdr-sidebar-ww .ww-level-slider::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
}
.rdr-sidebar-ww .ww-level-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
}
.rdr-sidebar-ww .ww-level-label {
  font-size: 0.68rem;
  min-width: 10px;
  color: #e8c97a;
}
.rdr-sidebar-ww .ww-generating {
  font-size: 0.65rem;
}

/* Reading controls — collapsible panel */
.rdr-rc-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 10px;
}
.rdr-rc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--paper);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.rdr-rc-toggle:hover {
  border-color: var(--gold);
  color: var(--ink);
}
.rdr-rc-toggle.rdr-rc-toggle-open {
  border-color: var(--gold);
  color: var(--ink);
  background: var(--gold-bg);
}
.rdr-rc-toggle i:first-child {
  font-size: 0.6rem;
  color: var(--gold);
}
.rdr-rc-arrow {
  font-size: 0.5rem !important;
  transition: transform 0.25s;
  color: var(--muted) !important;
}
.rdr-rc-panel {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.3s ease;
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  clip-path: inset(0 0 -200px 0);
}
.rdr-rc-group {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--paper);
  height: 33px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.rdr-rc-btn {
  width: 33px;
  height: 100%;
  border: none;
  border-radius: 0;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.65rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
  padding: 0;
}
.rdr-rc-btn + .rdr-rc-btn,
.rdr-rc-btn + .rdr-rc-size,
.rdr-rc-size + .rdr-rc-btn {
  border-left: 1.5px solid var(--border);
}
.rdr-rc-btn:hover {
  background: var(--warm);
  color: var(--ink);
}
.rdr-rc-btn.rdr-rc-active {
  background: var(--ink);
  color: #fff;
}
.rdr-rc-size {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  width: 33px;
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--paper);
  user-select: none;
}

/* Background picker */
.rdr-rc-bg-wrap {
  position: relative;
}
.rdr-rc-bg-trigger {
  width: 33px;
  height: 33px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.7rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.rdr-rc-bg-trigger:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.rdr-rc-bg-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.2s ease;
}
.rdr-rc-bg-dropdown.rdr-rc-bg-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.rdr-rc-bg {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  flex-shrink: 0;
}
.rdr-rc-bg:hover {
  transform: scale(1.15);
  border-color: var(--gold);
}
.rdr-rc-bg.rdr-rc-bg-active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2.5px var(--gold);
}

/* WordWise compact (mobile) */
.rdr-rc-ww-compact {
  display: none;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--paper);
}
.rdr-rc-ww-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0 10px;
  height: 30px;
  display: grid;
  place-items: center;
}
.rdr-rc-ww-compact .ww-toggle-sm-cell {
  border-left: 1.5px solid var(--border);
  width: 40px;
  height: 30px;
  display: grid;
  place-items: center;
}
/* WordWise full (desktop) */
.rdr-rc-ww-full {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--paper);
}
.rdr-rc-ww-full-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  padding: 0 10px;
  height: 30px;
}
.rdr-rc-ww-full-label i { font-size: 0.5rem; color: var(--gold); }
.rdr-rc-ww-full .ww-toggle-sm-cell {
  border-left: 1.5px solid var(--border);
  width: 40px;
  height: 30px;
  display: grid;
  place-items: center;
}
.rdr-rc-ww-slider {
  display: flex;
  align-items: center;
  gap: 0;
  border-left: 1.5px solid var(--border);
  height: 30px;
}
.rdr-rc-ww-slider input[type="range"] {
  width: 45px;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  margin: 0 8px;
}
.rdr-rc-ww-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.rdr-rc-ww-slider input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: none;
}

.rdr-rc-ww-eng {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--paper);
  height: 33px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.rdr-rc-ww-eng .ww-toggle-sm-cell {
  border-left: 1.5px solid var(--border);
  width: 40px;
  height: 30px;
  display: grid;
  place-items: center;
}

.rdr-rc-ww-lvl {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--gold);
  min-width: 16px;
  padding-right: 8px;
  text-align: center;
}
/* Small toggle — fits inside segmented cells */
label.ww-toggle.ww-toggle-sm {
  width: 28px !important;
  height: 16px !important;
  position: relative;
  flex-shrink: 0;
}
label.ww-toggle.ww-toggle-sm .ww-toggle-slider {
  background: var(--border);
  border-radius: 16px;
}
label.ww-toggle.ww-toggle-sm .ww-toggle-slider::before {
  height: 10px !important;
  width: 10px !important;
  left: 3px !important;
  bottom: 3px !important;
}
label.ww-toggle.ww-toggle-sm input:checked + .ww-toggle-slider {
  background: var(--gold);
}
label.ww-toggle.ww-toggle-sm input:checked + .ww-toggle-slider::before {
  transform: translateX(12px) !important;
}



/* Mobile: show compact, hide full, keep ENG Dict visible */
@media (max-width: 768px) {
  .rdr-rc-ww-compact { display: flex; }
  .rdr-rc-ww-full { display: none; }
  .rdr-rc-ww-eng {
    height: 30px;
  }
}

.rdr-sidebar-heading {
  padding: 14px 20px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.rdr-sidebar-heading i {
  color: var(--gold);
  font-size: 0.72rem;
}
.rdr-sidebar-count {
  background: var(--warm);
  color: var(--accent);
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}

.rdr-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 20px;
}

.rdr-sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 2px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink);
  position: relative;
}
.rdr-sidebar-item:hover {
  background: var(--warm);
}
.rdr-sidebar-item.active {
  background: linear-gradient(90deg, rgba(212,160,74,0.15), rgba(212,160,74,0.04));
  color: var(--ink);
  font-weight: 700;
}
.rdr-sidebar-item.active .rdr-sidebar-num {
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #fff;
  box-shadow: 0 2px 8px rgba(192,57,43,0.3);
}
.rdr-sidebar-item.active .rdr-sidebar-label {
  color: var(--accent);
}
.rdr-sidebar-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--warm);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.rdr-sidebar-label {
  line-height: 1.35;
  transition: color 0.2s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* --- Right content area --- */
.rdr-content {
  flex: 1;
  overflow-y: auto;
  padding: 36px 48px 60px;
  background: var(--paper);
}

.rdr-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 60vh;
  color: var(--muted);
}
.rdr-welcome i {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.3;
}
.rdr-welcome h2 {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
}
.rdr-welcome p {
  font-size: 0.88rem;
  margin: 0;
}

/* Lesson top bar inside content */
.rdr-lesson-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1.5px solid var(--border);
}
.rdr-lesson-progress {
  flex: 1;
  height: 5px;
  background: var(--warm);
  border-radius: 5px;
  overflow: hidden;
}
.rdr-lesson-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 5px;
  transition: width 0.4s ease;
}
.rdr-lesson-counter {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--paper);
  background: var(--ink);
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.rdr-lesson-title {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  margin: 0 0 28px;
  padding-left: 18px;
  border-left: 4px solid var(--gold);
}

.rdr-lesson-body {
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 20px;
  margin-bottom: 28px;
  min-height: 240px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.03);
  line-height: 1.9;
  overflow-x: clip;
}

.rdr-lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 4px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  gap: 12px;
}
.rdr-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--cream);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.22s;
}
.rdr-nav-btn:hover {
  border-color: var(--gold);
  background: var(--warm);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
.rdr-nav-next {
  background: linear-gradient(135deg, var(--ink), #2d2d4e);
  color: #fff;
  border-color: var(--ink);
}
.rdr-nav-next:hover {
  background: linear-gradient(135deg, #2d2d4e, #3b1f3d);
  border-color: #2d2d4e;
  color: #fff;
  box-shadow: 0 4px 14px rgba(26,26,46,0.2);
  transform: translateY(-1px);
}

/* Mobile toggle button */
.rdr-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 60;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* ---- Mobile: stack layout ---- */
@media (max-width: 768px) {
  .rdr-layout {
    position: relative;
  }
  .rdr-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 55;
    width: 85vw;
    max-width: 340px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: none;
  }
  .rdr-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  .rdr-content {
    padding: 20px 16px 60px;
  }
  .rdr-mobile-toggle {
    display: grid;
    place-items: center;
  }
  .rdr-lesson-title {
    font-size: 1.4rem;
  }
  .rdr-lesson-body {
    padding: 20px 16px;
  }
  .rdr-rc-panel {
    flex-wrap: wrap;
  }
  .rdr-nav-btn {
    padding: 10px 14px;
    font-size: 0.82rem;
  }
}


/* ==============================================
   WORDWISE FEATURE (Kindle-style)
   ============================================== */

/* Toggle bar in reader */
.ww-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  flex-wrap: wrap;
}
.ww-bar-label {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 0.78rem;
}
.ww-bar-label i { font-size: 0.72rem; }

/* Toggle switch */
.ww-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.ww-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.ww-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  transition: 0.25s;
}
.ww-toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.ww-toggle input:checked + .ww-toggle-slider {
  background: var(--accent);
}
.ww-toggle input:checked + .ww-toggle-slider::before {
  transform: translateX(18px);
}

/* Level slider */
.ww-level-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--muted);
}
.ww-level-group span { white-space: nowrap; }
.ww-level-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  outline: none;
}
.ww-level-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.ww-level-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
.ww-level-label {
  font-weight: 700;
  color: var(--accent);
  min-width: 14px;
  text-align: center;
}

.ww-generating {
  font-size: 0.74rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ww-generating i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* WordWise annotation — Kindle-style with unified bracket */
.ww-word {
  position: relative;
  display: inline;
  cursor: default;
}
.ww-hint {
  position: absolute;
  bottom: calc(100% - 3px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  user-select: none;
}
.ww-def {
  font-size: 0.62em;
  color: #999;
  font-weight: 400;
  white-space: nowrap;
  line-height: 1;
  padding-bottom: 1px;
}
.ww-bracket {
  width: 100%;
  height: 7px;
  display: block;
}
.ww-bracket path {
  stroke: #bbb;
}
.ww-word:hover .ww-def {
  color: var(--accent);
}
.ww-word:hover .ww-bracket path {
  stroke: var(--accent);
}
.ww-word-hidden .ww-hint {
  visibility: hidden;
}

/* Speak icon on WordWise words */
.ww-speak {
  position: absolute;
  left: 50%;
  top: calc(100% + 1px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.7em;
  transition: opacity 0.2s ease;
  z-index: 5;
}
/* Invisible bridge so mouse can travel from word to speaker without gap */
.ww-speak::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 12px;
  cursor: pointer;
}
.ww-word:hover .ww-speak {
  opacity: 0.7;
  pointer-events: auto;
  transition: opacity 0.2s ease;
}
/* When hint is below the word, flip speaker to appear ABOVE */
.ww-word:has(.ww-hint-below) .ww-speak {
  top: auto;
  bottom: calc(100% + 1px);
}
.ww-speak:hover {
  opacity: 1 !important;
  transform: translateX(-50%) scale(1.2);
}
.ww-speak-loading {
  animation: ww-pulse 0.6s ease-in-out;
}
.ww-speak.ww-src-mw {
  color: #16a34a;
}
.ww-speak.ww-src-tts {
  color: #f59e0b;
}
.ww-word:hover .ww-speak.ww-src-mw,
.ww-word:hover .ww-speak.ww-src-tts {
  opacity: 1;
}
@keyframes ww-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.3; }
}

/* When WordWise is active, increase line spacing to fit annotations */
.rdr-lesson-body.ww-active {
  line-height: calc(var(--reader-line-spacing, 1.85) + 0.65) !important;
}

/* Hint moved below word when overlapping */
.ww-hint-below {
  bottom: auto !important;
  top: calc(100% + 1px);
  flex-direction: column-reverse;
}
.ww-hint-below .ww-bracket {
  transform: scaleY(-1);
}
.ww-hint-below .ww-def {
  padding-bottom: 0;
  padding-top: 1px;
}

/* Edge-aligned hints */
.ww-hint-align-left {
  left: 0 !important;
  transform: none !important;
}
.ww-hint-align-right {
  left: auto !important;
  right: 0 !important;
  transform: none !important;
}

/* Fallback: JS adds this class when hint is below */
.ww-word.ww-speak-above .ww-speak {
  top: auto;
  bottom: calc(100% + 1px);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .ww-bar {
    gap: 6px;
  }
  .ww-level-slider {
    width: 50px;
  }
}


.ww-inline {
  font-size: 0.72em;
  color: #888;
  font-style: italic;
  letter-spacing: -0.01em;
  pointer-events: none;
}


.ab-audio-url-row {
      margin-bottom: 10px;
    }
    .ab-audio-url-row label {
      display: block;
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--muted);
      margin-bottom: 4px;
    }
    .ab-audio-url-input {
      width: 100%;
      padding: 8px 12px;
      border: 1.5px solid var(--border);
      border-radius: 8px;
      font-family: inherit;
      font-size: 0.82rem;
      background: var(--cream);
      color: var(--ink);
      outline: none;
      transition: border 0.2s;
    }
    .ab-audio-url-input:focus {
      border-color: var(--gold);
      background: var(--paper);
    }

    .ab-audio-url-flex {
      display: flex;
      gap: 6px;
      align-items: center;
    }
    .ab-audio-url-flex .ab-audio-url-input {
      flex: 1;
      min-width: 0;
    }
    .ab-audio-upload-btn {
      width: 36px;
      height: 36px;
      flex-shrink: 0;
      border: 1.5px solid var(--border);
      border-radius: 8px;
      background: var(--cream);
      color: var(--gold);
      cursor: pointer;
      display: grid;
      place-items: center;
      font-size: 0.82rem;
      transition: all 0.2s;
    }
    .ab-audio-upload-btn:hover {
      background: var(--gold-bg);
      border-color: var(--gold);
      color: var(--ink);
    }
    .ab-audio-upload-btn:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

.ab-urls-row {
      display: flex;
      gap: 10px;
      margin-bottom: 10px;
    }
    .ab-url-col {
      flex: 1;
      min-width: 0;
    }
    .ab-url-col label {
      display: block;
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--muted);
      margin-bottom: 4px;
    }
    .ab-url-col-test {
      flex: 0 0 200px;
    }
    @media (max-width: 640px) {
      .ab-urls-row {
        flex-direction: column;
        gap: 6px;
      }
      .ab-url-col-test {
        flex: 1;
      }
    }
    /* =============================================================
   TSMiniPlayer — Audio/Video player styles
   ============================================================= */

.tsmp-container {
  position: relative;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  margin: 0 0 12px;
}
.tsmp-container { --tsmp-leftcol: 37px; }
.tsmp-container.tsmp-audio [data-tsmp="wave"] { margin-left: var(--tsmp-leftcol); }

.tsmp-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.tsmp-overlay * { pointer-events: auto; }

.tsmp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border, #e5e7eb);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  cursor: pointer;
}
.tsmp-btn:active { transform: translateY(1px); }

.tsmp-time {
  font: 700 .72rem/1 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: 2px 6px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  opacity: .9;
}

/* Video box */
.tsmp-video { display: block; width: 100%; border-radius: 10px; background: #000; }
.tsmp-container.tsmp-audio .tsmp-video { display: none; }
.tsmp-container.tsmp-video [data-tsmp="wave"] { display: none; }
.tsmp-container [data-tsmp="wave"] { height: 40px; }

/* Touch scrubbing */
.tsmp-container [data-tsmp="wave"],
.tsmp-container [data-tsmp="wave"] canvas { touch-action: none; }

/* Video mode: hide play/time overlay */
.tsmp-container.tsmp-video { --tsmp-leftcol: 0px; }
.tsmp-container.tsmp-video [data-tsmp="play"],
.tsmp-container.tsmp-video [data-tsmp="time"] { display: none; }

/* Floating play/pause FAB */
.tsmp-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9997;
  border-radius: 999px;
  width: 50px;
  height: 50px;
  background: #111827;
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(0,0,0,.18);
  cursor: pointer;
}
.tsmp-fab[hidden] { display: none; }
.tsmp-fab:active { transform: translateY(1px); }

/* Pin button */
.tsmp-pin {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(102,126,234,0.4);
  transition: all 0.2s ease;
}
.tsmp-pin:hover {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46a1 100%);
  box-shadow: 0 4px 12px rgba(102,126,234,0.5);
  transform: translateY(-1px);
}
.tsmp-pin.pinned {
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  box-shadow: 0 2px 8px rgba(245,158,11,0.4);
}
.tsmp-pin.pinned:hover {
  background: linear-gradient(135deg, #d97706 0%, #dc2626 100%);
}

/* Pinned audio state */
.tsmp-container.is-pinned {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 800px;
  z-index: 9998;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
  padding: 8px 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}
.tsmp-container.is-pinned .tsmp-overlay {
  position: static;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tsmp-container.is-pinned .tsmp-btn { width: 32px; height: 32px; }
.tsmp-container.is-pinned .tsmp-time { font-size: 0.7rem; padding: 3px 6px; }
.tsmp-container.is-pinned [data-tsmp="wave"] {
  flex: 1;
  height: 40px !important;
  margin-left: 0 !important;
}
.tsmp-container.is-pinned .tsmp-pin {
  position: static;
  flex-shrink: 0;
  transform: none;
}

/* Pinned video state — floating bottom-left */
.video-overlay-pinned {
  position: fixed !important;
  bottom: 20px;
  left: 20px;
  top: auto !important;
  transform: none !important;
  width: 320px;
  max-width: 90vw;
  z-index: 9999;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.1);
  background: #1a1a2e;
  overflow: hidden;
  animation: slideInVideo 0.3s ease-out;
}
@keyframes slideInVideo {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.video-overlay-pinned .tsmp-video { width: 100%; max-height: 180px; display: block; background: #000; }
.video-overlay-pinned .tsmp-overlay,
.video-overlay-pinned .tsmp-pin,
.video-overlay-pinned [data-tsmp="wave"] { display: none !important; }

.video-overlay-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  gap: 12px;
}
.video-overlay-controls .vol-play-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 14px;
  box-shadow: 0 4px 15px rgba(102,126,234,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.video-overlay-controls .vol-play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102,126,234,0.6);
}
.video-overlay-controls .vol-time {
  color: #e2e8f0; font-size: 0.8rem; font-weight: 600;
  font-family: 'SF Mono', Monaco, monospace;
  background: rgba(255,255,255,0.1);
  padding: 4px 10px; border-radius: 20px;
}
.video-overlay-controls .vol-unpin-btn {
  padding: 8px 14px; border-radius: 20px; border: none;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  color: #fff; cursor: pointer; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  box-shadow: 0 4px 15px rgba(245,158,11,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.video-overlay-controls .vol-unpin-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(245,158,11,0.5);
}

@media (max-width: 480px) {
  .video-overlay-pinned { width: calc(100vw - 24px); left: 12px; bottom: 12px; }
}

/* Placeholder when player is pinned */
.tsmp-pin-placeholder {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  background: #f9fafb;
  padding: 10px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

/* === Media row: audio player + quiz badge side by side === */
.rdr-media-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.rdr-player-flex {
  flex: 1;
  min-width: 0;
  margin: 0 !important;
}
.rdr-quiz-badge {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  white-space: nowrap;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  box-shadow: 0 4px 16px rgba(37,99,235,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.rdr-quiz-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37,99,235,0.4);
}
.rdr-quiz-badge:active {
  transform: translateY(0);
}
.rdr-quiz-badge i:first-child {
  font-size: 1.1rem;
}
.rdr-quiz-badge-arrow {
  font-size: 0.55rem;
  opacity: 0.7;
}
@media (max-width: 768px) {
  .rdr-media-row {
    flex-direction: column;
    align-items: stretch;
  }
  .rdr-player-flex {
    width: 100%;
  }
  .rdr-quiz-badge {
    flex-direction: row;
    padding: 10px 16px;
    gap: 8px;
  }
  .rdr-quiz-badge span br { display: none; }
}

/* ========== WORDWISE HINT POPUP ========== */
.wwhp {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  align-items: stretch;
  width: 240px;
  background: #fffef9;
  border: 1px solid #ecdcb6;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(120,100,60,0.10), 0 1px 3px rgba(0,0,0,0.04);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}
.wwhp.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.wwhp-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  background: linear-gradient(135deg, #f5e6c4, #e8d3a0);
  color: #b8892e;
  font-size: 0.72rem;
}
.wwhp-body {
  flex: 1;
  padding: 7px 9px 6px;
  min-width: 0;
}
.wwhp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.wwhp-text {
  font-size: 0.7rem;
  font-weight: 600;
  color: #5a4e36;
  letter-spacing: -0.01em;
}
.wwhp-x {
  background: none;
  border: none;
  color: #c0b090;
  cursor: pointer;
  font-size: 0.6rem;
  padding: 0 1px;
  line-height: 1;
  transition: color 0.15s;
}
.wwhp-x:hover { color: #6b5c3e; }
.wwhp-slider {
  display: flex;
  align-items: center;
  gap: 5px;
}
.wwhp-label {
  font-size: 0.58rem;
  color: #a89870;
  font-weight: 500;
  flex-shrink: 0;
}
.wwhp-slider input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, #e2d4b4, #d4a04a);
  outline: none;
  cursor: pointer;
  margin: 0;
}
.wwhp-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #d4a04a;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(160,120,40,0.35);
  cursor: pointer;
}
.wwhp-slider input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #d4a04a;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(160,120,40,0.35);
  cursor: pointer;
}
.wwhp-val {
  font-size: 0.68rem;
  font-weight: 700;
  color: #d4a04a;
  min-width: 10px;
  text-align: center;
  flex-shrink: 0;
}
@media (max-width: 500px) {
  .wwhp {
    right: 10px;
    bottom: 14px;
    width: 220px;
  }
}



/* ========== SIDEBAR READING CONTROLS PANEL ========== */
.rdr-sidebar-rc-btn {
  width: 100%;
  padding: 8px 12px;
  background: linear-gradient(135deg, #faf5e8, #f3ebd4);
  border: 1px solid #e6d5a8;
  border-radius: 8px;
  color: #7a6840;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: background 0.2s, border-color 0.2s;
}
.rdr-sidebar-rc-btn:hover {
  background: linear-gradient(135deg, #f3ebd4, #ecdcb6);
  border-color: #d4a04a;
}
.rdr-sidebar-rc-btn i:first-child { color: #d4a04a; font-size: 0.72rem; }
.rdr-sidebar-rc-arrow {
  margin-left: auto;
  font-size: 0.6rem;
  color: #b8a070;
  transition: transform 0.25s ease;
}
.rdr-sidebar-rc-btn.src-open {
  background: linear-gradient(135deg, #f3ebd4, #ecdcb6);
  border-color: #d4a04a;
  border-radius: 8px 8px 0 0;
}
.rdr-sidebar-rc-panel {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  background: #fdfaf2;
  border: 1px solid #e6d5a8;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 0 10px;
}
.rdr-sidebar-rc-panel.src-open {
  padding: 8px 10px;
}
.src-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
}
.src-label {
  font-size: 0.72rem;
  color: #6b5c3e;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.src-label i {
  color: #c0a060;
  font-size: 0.65rem;
  width: 14px;
  text-align: center;
}
.src-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.src-btn {
  width: 26px;
  height: 26px;
  border: 1px solid #e0d4b8;
  border-radius: 6px;
  background: #fff;
  color: #7a6840;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.src-btn:hover { background: #f5ecd6; border-color: #d4a04a; }
.src-btn-active {
  background: #d4a04a !important;
  color: #fff !important;
  border-color: #d4a04a !important;
}
.src-val {
  font-size: 0.72rem;
  font-weight: 700;
  color: #5a4e36;
  min-width: 22px;
  text-align: center;
}
.src-bg-row { gap: 5px; }
.src-bg {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #e0d4b8;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.src-bg:hover { transform: scale(1.1); }
.src-bg-active { border-color: #d4a04a; box-shadow: 0 0 0 2px rgba(212,160,74,0.25); }
.src-divider {
  height: 1px;
  background: #ecdcb6;
  margin: 4px 0;
}
.src-ww-level {
  padding: 2px 0 5px;
  gap: 8px;
}
.src-ww-level .ww-level-slider { flex: 1; }

/* ========== WORD LOOKUP POPUP ========== */
.wl-popup {
  position: absolute;
  z-index: 9998;
  width: 300px;
  background: #fffef9;
  border: 1px solid #ecdcb6;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(120,100,60,0.18), 0 2px 8px rgba(0,0,0,0.06);
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  overflow: hidden;
}
.wl-popup.wl-show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.wl-popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 36px 0 14px;
}
.wl-popup-word {
  font-size: 1.2rem;
  font-weight: 700;
  color: #3a2e1a;
  font-family: 'Georgia', serif;
}
.wl-popup-speak {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #f5ecd6, #ecdcb6);
  color: #a08040;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.wl-popup-speak:hover {
  background: linear-gradient(135deg, #ecdcb6, #d4a04a);
  color: #fff;
  transform: scale(1.1);
}
.wl-popup-speak:active { transform: scale(0.95); }
.wl-popup-ipa {
  padding: 2px 14px 0;
  font-size: 0.78rem;
  color: #a08040;
  font-family: 'Segoe UI', sans-serif;
  letter-spacing: 0.02em;
}
.wl-popup-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #ecdcb6, transparent);
  margin: 8px 14px;
}
.wl-popup-en {
  padding: 0 14px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #5a4e36;
}
.wl-popup-vi {
  padding: 5px 14px 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #b8860b;
  font-style: italic;
}
.wl-popup-example {
  padding: 6px 14px 12px;
  font-size: 0.76rem;
  color: #8a7d65;
  font-style: italic;
  line-height: 1.5;
  border-top: 1px dashed #ecdcb6;
  margin-top: 8px;
}
.wl-popup-example span {
  font-weight: 700;
  color: #6b5c3e;
  text-decoration: underline;
  text-decoration-color: #d4a04a;
  text-underline-offset: 2px;
}
.wl-popup-loading {
  padding: 22px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #a08040;
}
.wl-popup-loading .wl-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #ecdcb6;
  border-top-color: #d4a04a;
  border-radius: 50%;
  animation: wlSpin 0.6s linear infinite;
}
@keyframes wlSpin {
  to { transform: rotate(360deg); }
}
.wl-popup-error {
  padding: 14px;
  font-size: 0.78rem;
  color: #c0392b;
  text-align: center;
}
.wl-popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #c0a060;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 2;
}
.wl-popup-close:hover {
  background: #f5ecd6;
  color: #6b5c3e;
}
@media (max-width: 600px) {
  .wl-popup {
    width: 270px;
  }
}


/* ========== READER LOGIN CARD ========== */
.rdr-login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid #ecdcb6;
  border-radius: 16px;
  padding: 36px 28px 32px;
  box-shadow: 0 8px 40px rgba(120,100,60,0.12), 0 2px 8px rgba(0,0,0,0.04);
  text-align: center;
}
.rdr-login-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #faf5e8, #ecdcb6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #b8860b;
}
.rdr-login-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #3a2e1a;
  margin: 0 0 6px;
  font-family: 'Georgia', serif;
}
.rdr-login-desc {
  font-size: 0.82rem;
  color: #8a7d65;
  margin: 0 0 24px;
  line-height: 1.5;
}
.rdr-login-field {
  text-align: left;
  margin-bottom: 14px;
}
.rdr-login-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b5c3e;
  margin-bottom: 5px;
}
.rdr-login-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e0d4b8;
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: inherit;
  background: #faf8f4;
  color: #3a2e1a;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.rdr-login-field input:focus {
  outline: none;
  border-color: #d4a04a;
  background: #fff;
}
.rdr-login-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  color: #b8a070;
  cursor: pointer;
  font-size: 0.82rem;
  padding: 4px;
}
.rdr-login-eye:hover { color: #6b5c3e; }
.rdr-login-msg {
  font-size: 0.78rem;
  min-height: 20px;
  margin-bottom: 4px;
}
.rdr-login-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #3a2e1a, #5a4e36);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}
.rdr-login-btn:hover {
  background: linear-gradient(135deg, #5a4e36, #3a2e1a);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(58,46,26,0.25);
}
.rdr-login-btn:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
}
@media (max-width: 480px) {
  .rdr-login-card {
    margin: 0 16px;
    padding: 28px 20px 24px;
  }
}


/* ========== READER HOME ========== */
.rh-topbar {
  background: linear-gradient(160deg, #1a1a2e 0%, #2a2848 40%, #3b2740 80%, #4a2040 100%);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rh-topbar-logo {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rh-logout-btn {
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.rh-logout-btn:hover { background: rgba(255,255,255,0.25); }
.rh-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 20px;
}
.rh-greeting {
  margin-bottom: 28px;
}
.rh-hello {
  font-size: 1.4rem;
  font-weight: 700;
  color: #3a2e1a;
  font-family: 'Georgia', serif;
}
.rh-sub {
  font-size: 0.85rem;
  color: #8a7d65;
  margin-top: 4px;
}
.rh-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #6b5c3e;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rh-section-title i { color: #d4a04a; }
.rh-book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 20px;
}
.rh-book-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all 0.25s;
}
.rh-book-card:hover {
  transform: translateY(-4px);
}
.rh-book-card:hover .rh-book-cover,
.rh-book-card:hover .rh-book-icon {
  box-shadow: 0 8px 24px rgba(80,60,20,0.18);
}
.rh-book-icon {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: linear-gradient(145deg, #faf5e8, #ecdcb6);
  border-radius: 6px 12px 12px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #b8860b;
  box-shadow: 2px 3px 12px rgba(80,60,20,0.10), inset -2px 0 6px rgba(0,0,0,0.04);
  transition: box-shadow 0.25s;
}
.rh-book-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 6px 12px 12px 6px;
  overflow: hidden;
  box-shadow: 2px 3px 12px rgba(80,60,20,0.10), inset -2px 0 6px rgba(0,0,0,0.04);
  transition: box-shadow 0.25s;
}
.rh-book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rh-book-info { min-width: 0; padding-top: 10px; }
.rh-book-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #3a2e1a;
  margin-bottom: 4px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.rh-book-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  color: #8a7d65;
  background: #faf5e8;
  padding: 2px 8px;
  border-radius: 6px;
  margin-right: 4px;
}
.rh-empty {
  text-align: center;
  padding: 48px 20px;
  color: #b8a070;
}
.rh-empty i {
  font-size: 2.5rem;
  margin-bottom: 16px;
  display: block;
  opacity: 0.5;
}
.rh-empty p {
  font-size: 0.88rem;
  color: #8a7d65;
  line-height: 1.6;
}

/* Copy lesson link button - only visible on hover */
.rdr-sidebar-copy {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  margin-left: auto;
  font-size: 0.8rem;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.rdr-sidebar-copy:hover {
  color: var(--gold);
  background: rgba(0,0,0,0.06);
}
body.is-super-admin .rdr-sidebar-item:hover .rdr-sidebar-copy {
  display: inline-flex;
}


/* Content protection — prevent text selection appearance */
.rdr-lesson-body {
  -webkit-touch-callout: none; /* iOS Safari long press */
}

/* But allow short selections for word lookup — handled by JS */
/* WordWise hints and speak buttons remain fully clickable */

.wwhp-lookup-hint {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(139,115,72,0.15);
  font-size: 12px;
  color: #8b7348;
  text-align: center;
  font-style: italic;
}