:root {
  --bg: #141517;
  --surface: #1b1c1f;
  --surface2: #222428;
  --elevated: #292b30;
  --rim: rgba(255, 248, 236, 0.045);
  --card: #1d1e22;
  --line: rgba(226, 222, 212, 0.085);
  --line2: rgba(226, 222, 212, 0.15);
  --fg: #dedad0;
  --muted: #9b968d;
  --accent: #268663;
  --accent-hi: #58b892;
  --on-accent: #ffffff;
  --accent-bg: rgba(88, 184, 146, 0.13);
  --accent-border: rgba(88, 184, 146, 0.28);
  --gold: #f59e0b;
  --gold-hi: #fbbf24;
  --logo-frame-bg: #fafaf7;
  --logo-ring: rgba(251, 191, 36, 0.38);
  --like: #f43f5e;
  --like-bg: rgba(244, 63, 94, 0.16);
  --amber: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
  --card-hover-shadow: 0 16px 32px rgba(0, 0, 0, 0.44);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-snap: cubic-bezier(0.34, 1.38, 0.64, 1);
  --radius: 15px;
}

[data-theme="light"] {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface2: #ebf0ee;
  --elevated: #ffffff;
  --rim: rgba(255, 255, 255, 0.85);
  --card: #ffffff;
  --line: rgba(15, 23, 42, 0.09);
  --line2: rgba(15, 23, 42, 0.18);
  --fg: #0f172a;
  --muted: #526075;
  --accent: #047857;
  --accent-hi: #065f46;
  --on-accent: #ffffff;
  --accent-bg: rgba(4, 120, 87, 0.10);
  --accent-border: rgba(4, 120, 87, 0.28);
  --gold: #d97706;
  --gold-hi: #b45309;
  --logo-frame-bg: #ffffff;
  --logo-ring: var(--accent-border);
  --like: #e11d48;
  --like-bg: rgba(225, 29, 72, 0.10);
  --shadow: 0 8px 22px rgba(15, 23, 42, 0.07);
  --card-hover-shadow: 0 14px 28px rgba(15, 23, 42, 0.11);
}

[data-theme="sepia"] {
  --bg: #f4ebd8;
  --surface: #fcf7eb;
  --surface2: #ebe0c8;
  --elevated: #fdf9ef;
  --rim: rgba(255, 255, 255, 0.72);
  --card: #fffcf4;
  --line: rgba(92, 68, 36, 0.13);
  --line2: rgba(92, 68, 36, 0.24);
  --fg: #3b2d1c;
  --muted: #6e5a40;
  --accent: #065f46;
  --accent-hi: #047857;
  --on-accent: #ffffff;
  --accent-bg: rgba(6, 95, 70, 0.11);
  --accent-border: rgba(6, 95, 70, 0.30);
  --gold: #b45309;
  --gold-hi: #92400e;
  --logo-frame-bg: #fffcf5;
  --logo-ring: var(--accent-border);
  --like: #be123c;
  --like-bg: rgba(190, 18, 60, 0.11);
  --shadow: 0 8px 22px rgba(80, 56, 20, 0.09);
  --card-hover-shadow: 0 14px 28px rgba(80, 56, 20, 0.14);
}

/* Custom Editorial Accent Themes */
[data-accent="amber"] {
  --accent: #b45309;
  --accent-hi: #fbbf24;
  --on-accent: #ffffff;
  --accent-bg: rgba(245, 158, 11, 0.15);
  --accent-border: rgba(251, 191, 36, 0.34);
}
[data-theme="light"][data-accent="amber"],
[data-theme="sepia"][data-accent="amber"] {
  --accent: #b45309;
  --accent-hi: #92400e;
  --on-accent: #ffffff;
  --accent-bg: rgba(180, 83, 9, 0.12);
  --accent-border: rgba(180, 83, 9, 0.28);
}

[data-accent="sapphire"] {
  --accent: #2563eb;
  --accent-hi: #60a5fa;
  --on-accent: #ffffff;
  --accent-bg: rgba(59, 130, 246, 0.15);
  --accent-border: rgba(96, 165, 250, 0.34);
}
[data-theme="light"][data-accent="sapphire"],
[data-theme="sepia"][data-accent="sapphire"] {
  --accent: #1d4ed8;
  --accent-hi: #1e40af;
  --on-accent: #ffffff;
  --accent-bg: rgba(29, 78, 216, 0.11);
  --accent-border: rgba(29, 78, 216, 0.28);
}

[data-accent="violet"] {
  --accent: #7c3aed;
  --accent-hi: #a78bfa;
  --on-accent: #ffffff;
  --accent-bg: rgba(139, 92, 246, 0.16);
  --accent-border: rgba(167, 139, 250, 0.34);
}
[data-theme="light"][data-accent="violet"],
[data-theme="sepia"][data-accent="violet"] {
  --accent: #6d28d9;
  --accent-hi: #5b21b6;
  --on-accent: #ffffff;
  --accent-bg: rgba(109, 40, 217, 0.11);
  --accent-border: rgba(109, 40, 217, 0.28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: "Cairo", "Noto Naskh Arabic", "Noto Sans Arabic", "Geeza Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font-family: inherit; color: inherit; }
button, a, [role="button"], .bcard, .cat-tile, .lib-card, .lib-folder-card {
  touch-action: manipulation;
}
:focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 2px;
}
.hidden { display: none !important; }

.badge, .lib-stat-chip, .dl-row-progress-meta, .lib-prog-pill, .read-prio-pill, .lib-multi-badge, .bfoot {
  font-variant-numeric: tabular-nums;
}

main#mainScroll,
.modal-body,
.sreader-body,
.cs-book-grid,
.ab-chapters-list { scrollbar-width: none; -ms-overflow-style: none; }
main#mainScroll::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.sreader-body::-webkit-scrollbar,
.cs-book-grid::-webkit-scrollbar,
.ab-chapters-list::-webkit-scrollbar { width: 0; height: 0; display: none; }

.ic { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ic.sm { width: 16px; height: 16px; }
.ic.lg { width: 32px; height: 32px; }
.ic.filled { fill: currentColor; }

/* ---------- Smooth Launch Splash Screen (Zero Theme Flash) ---------- */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.16s ease-out, transform 0.16s ease-out;
  will-change: opacity, transform;
}
.app-splash.done {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}
.splash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.splash-crest-wrap {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 22px;
  background: var(--logo-frame-bg);
  border: 2px solid var(--logo-ring);
  padding: 5px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
}
.splash-crest-wrap img { width: 100%; height: 100%; border-radius: 16px; object-fit: contain; }
.splash-ring {
  position: absolute;
  inset: -6px;
  border-radius: 26px;
  border: 2px solid var(--accent-border);
  opacity: 0.7;
  animation: splashPulse 1.1s ease-in-out infinite;
}
.splash-name {
  font-size: 28px;
  font-weight: 800;
  color: var(--fg);
}
.splash-status {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  margin-top: -4px;
}
.splash-bar {
  width: 148px;
  height: 4px;
  border-radius: 99px;
  background: var(--surface2);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-top: 2px;
}
.splash-bar-fill {
  display: block;
  width: 28%;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi), var(--gold));
  transition: width 0.24s var(--ease-spring);
}
.midad-calligraphy {
  font-family: "Amiri", "Scheherazade New", "Traditional Arabic", "Noto Naskh Arabic", "Geeza Pro", Georgia, serif;
  line-height: 1.35;
  letter-spacing: 0;
}
@keyframes splashPulse {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.06); opacity: 0.95; }
}

/* ---------- Layout & Floating Glass Navigation Dock ---------- */
.app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}

.nav-dock {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  width: fit-content;
  max-width: calc(100vw - 24px);
  padding: 5px 7px;
  border-radius: 99px;
  background: rgba(27, 28, 31, 0.88);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(22px) saturate(1.45);
  -webkit-backdrop-filter: blur(22px) saturate(1.45);
  border: 1px solid var(--line2);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28), inset 0 1px 0 var(--rim);
  transition: transform 0.22s var(--ease-spring), box-shadow 0.2s ease;
}

.nav-items {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 99px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  position: relative;
  transition: background 0.18s ease, color 0.18s ease, transform 0.14s var(--ease-spring), box-shadow 0.18s ease;
}
.nav-btn .ic { transition: transform 0.2s var(--ease-snap); }
.nav-btn:hover { background: var(--surface2); color: var(--fg); }
.nav-btn:active { transform: scale(0.95); }
.nav-btn.on {
  background: linear-gradient(135deg, var(--accent), var(--accent-hi));
  color: var(--on-accent);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.28);
}
.nav-btn.on .ic { transform: scale(1.06); }

.badge {
  margin-inline-start: 2px;
  font-style: normal;
  background: var(--gold);
  color: #111827;
  border-radius: 99px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 800;
}

.workspace {
  position: relative;
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
}

/* ---------- Top Search Bar (60fps GPU Auto-Hide on Scroll Down, Zero Layout Shift) ---------- */
.top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 20px 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  z-index: 15;
  will-change: transform, opacity;
  transition: transform 0.22s var(--ease-spring), opacity 0.18s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.top-bar.top-bar-hidden {
  transform: translate3d(0, -108%, 0);
  opacity: 0;
  pointer-events: none;
}
.top-bar.scrolled {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.20);
  border-bottom-color: var(--line2);
}
.top-brand {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; flex-shrink: 0;
  padding: 4px 8px; border-radius: 10px;
  color: var(--fg);
  transition: background 0.16s ease, transform 0.15s var(--ease-spring);
}
.top-brand:hover { background: var(--surface2); }
.top-brand:active { transform: scale(0.97); }
.midad-logo-wordmark {
  display: block;
  height: 23px;
  width: auto;
  color: var(--fg);
}
.top-brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.midad-wordmark {
  font-size: 22px;
  font-weight: 800;
  padding: 0 2px;
  background: linear-gradient(135deg, var(--fg) 15%, var(--accent-hi) 68%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--fg);
}
.top-util-btn { border-radius: 11px; }
.top-util-btn.fs-active {
  color: var(--accent-hi);
  background: var(--accent-bg);
  border-color: var(--accent-border);
}
.top-util-btn.theme-spin svg { animation: themeIconSpin 0.44s var(--ease-snap); }
@keyframes themeIconSpin {
  0% { transform: scale(0.76) rotate(-35deg); }
  55% { transform: scale(1.22) rotate(14deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.theme-wave {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 95;
  opacity: 0;
  will-change: opacity;
}
.theme-wave.go {
  animation: themeCrossFade 0.21s ease-out forwards;
}
@keyframes themeCrossFade {
  0% { opacity: 0.72; }
  100% { opacity: 0; }
}

.omni-search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border: 1px solid var(--line);
  border-radius: 99px; padding: 5px 14px;
  min-width: 0;
  transition: border-color 0.2s ease, box-shadow 0.22s ease, background 0.2s ease;
}
.omni-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
  background: var(--surface);
}
.omni-search input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 14px; padding: 5px 0; min-width: 0;
}
.omni-search input::placeholder { color: var(--muted); }
.omni-go { background: transparent; border: none; cursor: pointer; padding: 2px; color: var(--accent-hi); display: flex; transition: transform 0.14s var(--ease-spring); }
.omni-go:active { transform: scale(0.9); }

.top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.top-streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 10px;
  border-radius: 99px;
  background: var(--surface2);
  border: 1px solid var(--line2);
  color: var(--fg);
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s var(--ease-spring), border-color 0.16s ease, background 0.16s ease;
}
.top-streak-pill:hover { border-color: var(--accent-hi); background: var(--elevated); }
.top-streak-pill:active { transform: scale(0.95); }
.top-streak-pill svg { width: 15px; height: 15px; color: #f59e0b; fill: rgba(245, 158, 11, 0.24); }
.top-streak-pill.mood-completed svg { color: var(--accent-hi); fill: var(--accent-bg); }
.top-streak-pill.mood-frozen svg { color: #38bdf8; fill: rgba(56, 189, 248, 0.22); }
.top-streak-pill.mood-angry svg { color: #f43f5e; fill: rgba(244, 63, 94, 0.22); }
.top-streak-pill span { line-height: 1; }
.pill-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--line);
  border-radius: 99px; padding: 7px 13px; font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s var(--ease-spring), border-color 0.18s ease, background 0.18s ease;
}
.pill-btn:hover { border-color: var(--line2); }
.pill-btn:active { transform: scale(0.96); }
.pill-btn.primary-soft {
  background: var(--accent-bg); border-color: var(--accent); color: var(--accent-hi);
}
.dot-live {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-hi);
  animation: livePulse 2.4s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.72; }
}

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: transform 0.15s var(--ease-spring), border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.icon-btn:hover { border-color: var(--line2); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn.sm { width: 28px; height: 28px; border: none; background: transparent; }
.icon-btn.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-hi); }
.icon-btn.like-on { background: var(--like-bg); border-color: var(--like); color: var(--like); position: relative; }
.icon-btn.like-on svg, .bcard-like.on svg, .lib-fav-btn.on svg { animation: heartPop 0.36s var(--ease-snap); }
@keyframes heartPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.32); }
  75% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
@keyframes heartRing {
  0% { opacity: 0.72; transform: scale(0.85); }
  100% { opacity: 0; transform: scale(1.65); }
}
.bcard-like.on::after {
  content: ""; position: absolute; inset: -3px; border-radius: inherit;
  border: 1.5px solid var(--like); pointer-events: none;
  animation: heartRing 0.42s var(--ease-spring) forwards;
}

.recent-bar {
  position: absolute;
  top: var(--topbar-h, 62px);
  left: 0; right: 0;
  z-index: 14;
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 9px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  animation: tabEnter 0.18s var(--ease-spring);
}
.recent-bar.hidden { display: none !important; }
.search-suggest-box {
  position: absolute;
  top: var(--topbar-h, 62px);
  left: 14px; right: 14px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 16;
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  padding: 6px;
  animation: tabEnter 0.14s var(--ease-spring);
}
.search-suggest-box.hidden { display: none !important; }
.suggest-didyoumean {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 11px; margin-bottom: 5px; border-radius: 10px;
  background: var(--accent-bg); border: 1px solid rgba(52, 211, 153, 0.35);
  color: var(--fg); font-size: 13px; cursor: pointer; width: 100%; text-align: right; font-family: inherit;
}
.suggest-didyoumean strong { color: var(--accent-hi); }
.suggest-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 10px; border: 0; background: transparent;
  color: var(--fg); font-family: inherit; text-align: right; cursor: pointer;
}
.suggest-item:hover, .suggest-item.active {
  background: var(--card);
}
.suggest-item-main {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; font-weight: 700;
}
.suggest-item-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-item-sub {
  font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0;
}

/* ---------- Main Scroll (60fps Hardware Composited) ---------- */
main#mainScroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: calc(var(--topbar-h, 62px) + 14px) 22px 98px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.tab { display: none; contain: layout style; }
@keyframes tabEnter {
  from { opacity: 0; transform: translate3d(0, 6px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
.tab.active {
  display: block;
  animation: tabEnter 0.16s var(--ease-spring);
}

/* ---------- Hero Banner ---------- */
.hero-card {
  position: relative; overflow: hidden;
  border-radius: 14px; padding: 11px 13px; margin-bottom: 8px;
  background: var(--card);
  border: 1px solid var(--line2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), inset 0 1px 0 var(--rim);
  display: flex; align-items: center; gap: 12px;
  transition: border-color 0.22s ease, box-shadow 0.24s ease, transform 0.22s var(--ease-spring);
}
.hero-card:hover { border-color: var(--accent-hi); }
.hero-cover {
  width: 98px; height: 132px; border-radius: 12px; object-fit: contain; flex-shrink: 0;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42); background: var(--surface2);
  border: 1px solid var(--rim);
  transition: transform 0.28s var(--ease-spring);
}
.hero-card:hover .hero-cover { transform: translateY(-2px) scale(1.02); }
.hero-cover img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; padding: 0; z-index: 1;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}
.hero-meta { flex: 1; min-width: 0; }
.hero-kicker {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800; color: var(--accent-hi);
  background: var(--accent-bg); border: 1px solid var(--accent-border);
  border-radius: 99px; padding: 3px 11px; margin-bottom: 8px;
}
.hero-title { font-size: 21px; font-weight: 800; margin: 0 0 5px; line-height: 1.32; letter-spacing: -0.015em; }
.hero-sub { font-size: 13px; color: var(--muted); margin: 0 0 13px; line-height: 1.55; max-width: 65ch; }
.hero-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons & Chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: 11px; border: 1px solid transparent;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: transform 0.16s var(--ease-spring), filter 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.2s ease;
}
.btn:active { transform: scale(0.96); }
.btn.emerald {
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 5px 15px var(--accent-bg), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn.emerald:hover { filter: brightness(1.07); }
.btn.glass { background: var(--surface2); border-color: var(--line2); color: var(--fg); box-shadow: inset 0 1px 0 var(--rim); }
.btn.glass:hover { border-color: var(--accent-hi); background: var(--elevated); }
.btn.amber { background: rgba(245, 158, 11, 0.16); border-color: rgba(245, 158, 11, 0.36); color: #fbbf24; }
.btn.like { background: var(--like-bg); border-color: rgba(244, 63, 94, 0.42); color: var(--like); }
.btn.sm { padding: 7px 12px; font-size: 12px; border-radius: 9px; min-height: 33px; }

.chips-row { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chips-row.center { justify-content: center; flex-wrap: wrap; }
.chips-row.sm .chip { padding: 5px 12px; font-size: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; flex-shrink: 0;
  padding: 7px 13px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform 0.14s var(--ease-spring), background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.2s ease;
}
.chip:hover { border-color: var(--line2); background: var(--surface2); }
.chip:active { transform: scale(0.95); }
.chip.on {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
  box-shadow: 0 4px 12px var(--accent-bg), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.seg-row {
  display: flex; gap: 6px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 5px; margin-bottom: 12px;
  box-shadow: inset 0 1px 0 var(--rim);
}
.seg-row button {
  border: none; background: transparent; cursor: pointer;
  padding: 7px 13px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--muted);
  transition: background 0.2s ease, color 0.18s ease, transform 0.14s var(--ease-spring), box-shadow 0.2s ease;
}
.seg-row button:hover { color: var(--fg); }
.seg-row button:active { transform: scale(0.96); }
.seg-row button.on {
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 3px 10px var(--accent-bg), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ---------- Sections & Horizontal Shelves ---------- */
.shelf-wrap { margin-bottom: 20px; contain: layout style; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sec-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; }
.sec-icon { color: var(--accent-hi); display: inline-flex; align-items: center; }
.sec-sub { font-size: 12px; color: var(--muted); }
.link-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: none; cursor: pointer; color: var(--accent-hi); font-size: 13px; font-weight: 700;
}

.shelf {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.shelf::-webkit-scrollbar { display: none; }
.shelf .bcard { width: 152px; flex-shrink: 0; }

/* ---------- Book Grid & Optimized Cards ---------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(154px, 1fr));
  gap: 13px;
}
html[data-density="dense"] .book-grid {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}
html[data-density="dense"] .lib-grid:not(.compact) {
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 10px;
}

.bcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  cursor: pointer;
  contain: layout style paint;
  box-shadow: inset 0 1px 0 var(--rim);
  transition: transform 0.16s var(--ease-spring), border-color 0.15s ease;
}
.bcard:hover {
  border-color: var(--accent-hi);
  transform: translate3d(0, -3px, 0);
  box-shadow: inset 0 1px 0 var(--rim), var(--card-hover-shadow);
}
.bcard:active { transform: scale(0.972); }

@keyframes cardIn {
  from { opacity: 0; transform: translate3d(0, 10px, 0) scale(0.988); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
.card-stagger {
  animation: cardIn 0.2s var(--ease-spring) calc(var(--idx, 0) * 15ms) both;
}

.bcover {
  position: relative; aspect-ratio: 3 / 4;
  background: var(--surface2); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.bcover img {
  width: 100%; height: 100%; object-fit: contain;
  padding: 0; display: block; z-index: 1;
  transition: transform 0.2s var(--ease-spring), opacity 0.15s ease;
}
.bcard:hover .bcover img { transform: scale(1.025); }

/* Editorial Loading Skeleton Shimmer */
.bcard-skel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.skel-cov {
  aspect-ratio: 3 / 4;
  background: var(--surface2);
  position: relative;
  overflow: hidden;
}
.skel-line {
  height: 11px; border-radius: 6px; background: var(--surface2);
  position: relative; overflow: hidden;
}
.skel-line.w75 { width: 76%; }
.skel-line.w50 { width: 52%; }
.skel-cov::after, .skel-line::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  animation: skelShimmer 1.35s ease-in-out infinite;
}
@keyframes skelShimmer {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}
.has-cover-img {
  background: radial-gradient(circle at 50% 32%, #182338 0%, #090e1a 100%) !important;
}
[data-theme="light"] .has-cover-img {
  background: radial-gradient(circle at 50% 32%, #e2e8f0 0%, #cbd5e1 100%) !important;
}
.has-cover-img > .bcover-fallback,
.has-cover-img > .lib-thumb-mono,
.hero-cover.has-cover-img > :not(img),
.detail-cover.has-cover-img > :not(img) {
  opacity: 0 !important;
  pointer-events: none;
}
.bcover img.cov-full,
.detail-cover img.cov-full,
.hero-cover img.cov-full,
.hero-main-cov img.cov-full,
.hero-next-cov img.cov-full {
  object-fit: cover !important;
}
.bcover.has-cover-img::after,
.detail-cover.has-cover-img::after,
.hero-cover.has-cover-img::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0%, rgba(0, 0, 0, 0.22) 3px, rgba(255, 255, 255, 0.08) 7px, transparent 15px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.bcover-fallback {
  width: 100%; height: 100%; padding: 18px 12px 14px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(150deg, var(--c1, #0f766e), var(--c2, #1e293b));
  color: #f8fafc;
}
.bcover-fallback strong { font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.bcover-fallback span { font-size: 11px; opacity: 0.84; }

/* Opaque-tinted tags (zero backdrop-filter blur -> silky Android scroll) */
.tag-fmt, .tag-src {
  position: absolute; top: 7px; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 6px; z-index: 2;
  background: rgba(9, 13, 22, 0.88); color: #f8fafc;
}
.tag-fmt { left: 7px; text-transform: uppercase; border: 1px solid rgba(52, 211, 153, 0.4); color: #6ee7b7; }
.tag-src { right: 7px; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bcard-like {
  position: absolute; bottom: 7px; left: 7px;
  width: 31px; height: 31px; border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  background: rgba(9, 13, 22, 0.86);
  color: #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 2;
  transition: transform 0.18s var(--ease-snap), background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.bcard-like:hover { transform: scale(1.08); border-color: rgba(255, 255, 255, 0.42); }
.bcard-like:active { transform: scale(0.9); }
.bcard-like.on { background: #e11d48; border-color: #fda4af; color: #fff; }

.bmeta { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.btitle {
  font-size: 13px; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bauthor-btn {
  align-self: flex-start;
  background: transparent; border: none; padding: 0; cursor: pointer;
  font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  text-align: right;
}
.bauthor-btn:hover { color: var(--accent-hi); text-decoration: underline; }
.bfoot { margin-top: auto; padding-top: 4px; display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--accent-hi); }
.bcard-dl-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: inherit; font-size: 10.5px; font-weight: 800; line-height: 1.2;
  padding: 5px 9px; border-radius: 99px; cursor: pointer;
  background: var(--accent); color: var(--on-accent); border: none;
  box-shadow: 0 3px 9px var(--accent-bg);
  transition: transform 0.14s var(--ease-spring), opacity 0.15s ease, filter 0.15s ease;
}
.bcard-dl-btn:hover { filter: brightness(1.08); }
.bcard-dl-btn:active { transform: scale(.95); }
.bcard-dl-btn:disabled { opacity: .65; cursor: wait; }
.bcard-dl-btn .ic { width: 12px; height: 12px; }
.bcard-dl-btn.downloading { opacity: 0.92; pointer-events: none; }

/* ---------- Categories Grid & Taste ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.cat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  contain: layout style paint;
  box-shadow: inset 0 1px 0 var(--rim);
  transition: transform 0.15s var(--ease-spring), border-color 0.15s ease, background 0.15s ease;
}
.cat-tile:hover { border-color: var(--accent-border); transform: translateY(-1.5px); }
.cat-tile:active { transform: scale(0.975); }
.cat-tile.on {
  border-color: var(--accent-hi);
  background: linear-gradient(135deg, var(--accent-bg), var(--surface));
  box-shadow: inset 0 1px 0 var(--rim), 0 4px 12px rgba(0, 0, 0, 0.18);
}
.cat-tile-ic {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--surface2); color: var(--accent-hi);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.cat-tile.on .cat-tile-ic {
  background: var(--accent); color: var(--on-accent); border-color: transparent;
}
.cat-tile-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cat-tile-top { display: flex; align-items: center; justify-content: flex-start; gap: 6px; }
.cat-tile strong {
  display: block; font-size: 13px; font-weight: 800; line-height: 1.3;
  white-space: normal; word-break: normal; overflow: visible;
}
.cat-tile-sub {
  display: block; font-size: 11px; color: var(--muted); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.cat-jump-chip {
  background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent-hi); font-weight: 800;
}
@media (max-width: 600px) {
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .cat-tile { padding: 9px 10px; gap: 8px; }
  .cat-tile-ic { width: 29px; height: 29px; border-radius: 8px; }
  .cat-tile strong { font-size: 12px; }
  .cat-tile-sub { font-size: 10px; }
}

.taste-icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 10px; font-size: 12px; font-weight: 700;
}

.taste-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; margin-bottom: 16px;
}

/* ---------- Search Controls & Banners ---------- */
.filter-bars { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.status-strip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; margin-bottom: 10px; font-size: 12px; color: var(--muted);
}
.cf-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--accent-bg); border: 1px solid var(--accent-border);
  border-radius: 12px; padding: 11px 14px; margin-bottom: 12px;
}
.cf-banner strong { display: block; font-size: 13px; }
.cf-banner small { font-size: 12px; color: var(--muted); }

/* ---------- Sleek Reading & Device Library Hub ---------- */
.lib-hero {
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, var(--accent) 8%), var(--surface));
  border: 1px solid var(--line2);
  box-shadow: inset 0 1px 0 var(--rim);
  border-radius: 15px;
  padding: 10px 14px;
  margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.lib-hero-main { display: flex; align-items: center; gap: 10px; flex: 1 1 220px; min-width: 0; }
.lib-hero-icon {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: var(--accent-bg); border: 1px solid var(--accent-border);
  color: var(--accent-hi); display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 0 var(--rim);
}
.lib-hero-copy { min-width: 0; flex: 1; }
.lib-hero-titleline {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.lib-hero h3 { margin: 0; font-size: 14.5px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.25; }
.lib-hero small { display: inline-block; color: var(--muted); font-size: 11px; line-height: 1.3; }
.lib-stats-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.lib-stat-chip {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--line);
  color: var(--fg); white-space: nowrap;
}
.lib-stat-chip.hi {
  background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent-hi);
}
.lib-hero-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.lib-more-wrap .icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; background: var(--surface2); border: 1px solid var(--line2); }
.lib-more-wrap { position: relative; }
.lib-pop-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  min-width: 235px; padding: 6px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--line2);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.52);
  display: flex; flex-direction: column; gap: 3px;
  transform-origin: top left;
}
.lib-pop-menu:not(.hidden) { animation: mMenuPop 0.18s var(--ease-spring) both; }
@keyframes mMenuPop {
  from { opacity: 0; transform: translateY(-6px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.lib-pop-item {
  width: 100%; display: flex; align-items: center; gap: 9px; text-align: right;
  padding: 9px 11px; border-radius: 9px; border: none; background: transparent;
  color: var(--fg); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.lib-pop-item:hover { background: var(--surface2); }
.lib-pop-item.danger { color: #fca5a5; }
.lib-pop-item.danger:hover { background: rgba(239, 68, 68, 0.14); }
.lib-pop-item:disabled { opacity: 0.42; cursor: not-allowed; }

.lib-access-banner {
  background: rgba(245, 158, 11, 0.10); border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 13px; padding: 12px 14px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.lib-access-banner strong { display: block; font-size: 13px; margin-bottom: 2px; color: #fde68a; }
.lib-access-banner small { font-size: 12px; color: var(--muted); }

.lib-toolbar {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px;
}
.lib-toolbar-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.lib-search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line2);
  border-radius: 11px; padding: 0 11px; flex: 1 1 200px; min-width: 180px;
}
.lib-search-box input {
  flex: 1; height: 36px; border: none; background: transparent; color: var(--fg);
  font-size: 12.5px; outline: none; min-width: 0;
}
.lib-toolbar-ctrls {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; flex-shrink: 0;
}
.lib-filter-pills {
  display: flex; align-items: center; gap: 6px; padding: 0 !important;
  flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none;
}
.lib-filter-pills::-webkit-scrollbar { display: none; }
.lib-filter-pills .chip { flex-shrink: 0; }

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 12px;
}
.lib-view-seg { margin-bottom: 0; padding: 3px; flex-shrink: 0; }
.lib-view-seg button { padding: 6px 11px; font-size: 12px; }
.lib-folder-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--accent-border);
  box-shadow: inset 0 1px 0 var(--rim);
  border-radius: 14px; padding: 10px 13px; margin-bottom: 12px;
}
.lib-folder-crumb { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lib-folder-crumb-name { font-size: 14px; font-weight: 800; color: var(--fg); }
.lib-folder-bar-acts { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.lib-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px 10px;
}
@media (min-width: 720px) {
  .lib-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
    gap: 14px 12px;
  }
}
.lib-card.compact,
.lib-folder-card.compact {
  padding: 6px;
  border-radius: 13px;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition: border-color .18s ease, background .18s ease, transform .18s var(--ease-spring), box-shadow .2s ease;
}
.lib-card.compact:hover,
.lib-folder-card.compact:hover {
  background: var(--surface);
  border-color: var(--accent-border);
  transform: translateY(-3px);
  box-shadow: var(--card-hover-shadow);
}
.lib-card.compact:active,
.lib-folder-card.compact:active {
  transform: scale(0.96);
}
.lib-compact-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.30);
}
.lib-compact-fav {
  position: absolute; top: 6px; left: 6px; z-index: 3;
  width: 24px; height: 24px; border-radius: 99px;
  background: rgba(225, 29, 72, 0.92); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(225, 29, 72, 0.42);
  pointer-events: none;
  animation: heartPop 0.32s var(--ease-snap);
}
.lib-compact-fav svg { width: 12px; height: 12px; }
.lib-compact-cover img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; z-index: 1; pointer-events: none;
}
.lib-compact-title {
  font-size: 12px; font-weight: 700; line-height: 1.35; color: var(--fg);
  text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  padding: 0 2px;
}
.lib-folder-card {
  background: linear-gradient(155deg, var(--accent-bg), transparent 70%), var(--surface);
  border: 1px solid var(--accent-border);
  box-shadow: inset 0 1px 0 var(--rim);
  border-radius: 16px; padding: 13px;
  display: flex; gap: 13px; align-items: stretch; cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  transition: border-color .18s ease, transform .18s var(--ease-spring), box-shadow .22s ease;
}
.lib-folder-card:hover { border-color: var(--accent-hi); transform: translateY(-2px); box-shadow: var(--card-hover-shadow); }
.lib-folder-card:active { transform: scale(0.985); }
.lib-folder-mosaic {
  width: 100%; height: 100%; padding: 6px;
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 4px;
  background: linear-gradient(155deg, rgba(14, 79, 68, 0.28), rgba(9, 30, 38, 0.25));
}
.lib-folder-mini {
  border-radius: 5px; overflow: hidden; position: relative;
  background: var(--surface2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 8.5px; font-weight: 800; color: var(--fg); padding: 2px; text-align: center;
}
.lib-folder-mini img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none;
}
.lib-folder-empty-ic {
  grid-column: 1 / -1; grid-row: 1 / -1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--accent-hi); font-size: 11px; font-weight: 700;
}
.lib-fld-lbl { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--fg); }
.lib-fld-input, .lib-fld-filter {
  width: 100%; height: 39px; border-radius: 10px;
  border: 1px solid var(--line2); background: var(--surface2); color: var(--fg);
  padding: 0 12px; font-size: 13.5px; outline: none; box-sizing: border-box;
}
.lib-fld-input:focus, .lib-fld-filter:focus { border-color: var(--accent); }
.lib-fld-pick-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin: 12px 0 8px;
}
.lib-fld-filter { width: auto; min-width: 170px; height: 32px; font-size: 12px; flex: 1; max-width: 220px; }
.lib-fld-book-list {
  max-height: 290px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  padding-inline-end: 2px;
}
.lib-fld-pick-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface2); cursor: pointer; text-align: right;
  transition: border-color .14s, background .14s;
}
.lib-fld-pick-row.selected { border-color: var(--accent); background: var(--accent-bg); }
.lib-fld-chk {
  width: 19px; height: 19px; border-radius: 6px; border: 1.5px solid var(--line2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--on-accent);
  font-size: 12px; font-weight: 800;
}
.lib-fld-pick-row.selected .lib-fld-chk { background: var(--accent); border-color: var(--accent); }
.lib-act-hero {
  display: flex; gap: 12px; align-items: center; padding-bottom: 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.lib-act-section { margin-top: 12px; }
.lib-act-sec-title { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 7px; }
.lib-act-copies { display: flex; flex-direction: column; gap: 6px; }
.lib-act-copy-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface2); color: var(--fg); cursor: pointer; text-align: right;
  transition: border-color 0.16s ease, transform 0.14s var(--ease-spring);
}
.lib-act-copy-btn:hover { border-color: var(--accent-hi); }
.lib-act-copy-btn:active { transform: scale(0.985); }
.lib-act-folder-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-card {
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--rim);
  border-radius: 16px; padding: 14px;
  contain: layout style paint;
  display: flex; gap: 13px; align-items: stretch;
  transition: border-color .15s ease, transform .16s var(--ease-spring);
}
.lib-card:hover { border-color: var(--accent-border); transform: translateY(-2px); box-shadow: var(--card-hover-shadow); }
.lib-card.has-multi { border-color: var(--accent-border); }
.lib-fav-btn.on {
  background: var(--like-bg);
  border-color: rgba(244, 63, 94, 0.48);
  color: var(--like);
}
.lib-thumb {
  width: 78px; height: 104px; min-height: 104px; border-radius: 10px; overflow: hidden;
  position: relative; flex-shrink: 0; background: var(--surface2);
  border: 1px solid var(--line2);
  display: flex; align-items: center; justify-content: center;
}
.lib-thumb img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; padding: 0; z-index: 1;
}
.lib-thumb-mono {
  width: 100%; height: 100%; padding: 8px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: linear-gradient(155deg, var(--c1, #0e4f44), var(--c2, #091e26));
  color: #f8fafc; font-size: 10.5px; font-weight: 800; line-height: 1.35;
}
.lib-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 7px; }
.lib-top-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.lib-title {
  font-size: 14px; font-weight: 800; line-height: 1.38; color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lib-multi-badge {
  flex-shrink: 0; font-size: 10.5px; font-weight: 800; padding: 3px 8px; border-radius: 99px;
  background: var(--accent-bg); border: 1px solid var(--accent-border); color: var(--accent-hi);
  white-space: nowrap;
}
.lib-meta-line {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted);
}
.lib-read-track {
  width: 100%; height: 4px; border-radius: 99px;
  background: var(--surface2); overflow: hidden; margin-top: 3px;
}
.lib-read-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
}
.lib-prog-pill {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  background: rgba(245, 158, 11, 0.14); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.30);
}
.lib-editions {
  display: flex; gap: 5px; flex-wrap: wrap; margin-top: 2px;
}
.lib-ed-btn {
  border: 1px solid var(--line2); background: var(--surface2); color: var(--muted);
  border-radius: 8px; padding: 4px 8px; font-size: 11px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  transition: all .14s;
}
.lib-ed-btn:hover { border-color: var(--accent-hi); color: var(--fg); }
.lib-ed-btn.on {
  background: var(--accent-bg); border-color: var(--accent); color: var(--fg);
}
.lib-ed-fmt { text-transform: uppercase; font-weight: 800; color: var(--fg); }
.lib-ed-btn.on .lib-ed-fmt { color: var(--accent-hi); }
.lib-card-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.btn.danger-solid {
  background: #e11d48; border-color: #fb7185; color: #fff;
}
.btn.danger-solid:hover { background: #be123c; }
.dl-list { display: flex; flex-direction: column; gap: 9px; }
.dl-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.dl-info { flex: 1; min-width: 210px; }
.dl-info strong { display: block; font-size: 14px; margin-bottom: 3px; }
.dl-info small { font-size: 12px; color: var(--muted); }
.pbar { width: 100%; height: 5px; background: var(--surface2); border-radius: 99px; margin-top: 7px; overflow: hidden; }
.pbar > span { display: block; height: 100%; background: var(--accent); transition: width 0.2s linear; }

/* ---------- Modals (Book Detail & Author Hub) ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 14px; }
#authorModal { z-index: 60; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 6, 12, 0.78); }
.modal-sheet {
  position: relative; z-index: 1;
  width: min(820px, 100%); max-height: 92vh;
  background: var(--surface); border: 1px solid var(--line2);
  border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  contain: layout paint;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.44);
}
@keyframes mBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes mSheetIn {
  from { opacity: 0; transform: translate3d(0, 12px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes mSheetUp {
  from { opacity: 0; transform: translate3d(0, 18px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
.modal:not(.hidden) .modal-backdrop { animation: mBackdropIn 0.14s ease both; }
.modal:not(.hidden) .modal-sheet { animation: mSheetIn 0.16s cubic-bezier(0.2, 0.85, 0.3, 1) both; }
.modal:not(.hidden) .sreader-sheet { animation: mSheetUp 0.16s cubic-bezier(0.2, 0.85, 0.3, 1) both; }

/* Settings Accent Swatch Selector */
.accent-dot {
  width: 11px; height: 11px; border-radius: 99px; display: inline-block; flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
}
.choice-opt-btn {
  transition: transform 0.15s var(--ease-spring), border-color 0.18s ease, background 0.18s ease;
}
.choice-opt-btn:active { transform: scale(0.985); }
.modal-sheet.small { width: min(560px, 100%); }
.modal-top {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.modal-top-title { flex: 1; font-weight: 800; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-top-acts { display: flex; gap: 6px; }
.modal-body { flex: 1; overflow-y: auto; padding: 18px; -webkit-overflow-scrolling: touch; overflow-anchor: none; overscroll-behavior: contain; }

.detail-hero { display: flex; gap: 14px; align-items: flex-start; flex-wrap: nowrap; margin-bottom: 11px; }
.detail-cover { width: 108px; height: 152px; border-radius: 11px; object-fit: contain; flex-shrink: 0; background: var(--surface2); border: 1px solid var(--line2); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16); }
.detail-cover img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; padding: 0; z-index: 1;
}
.detail-info { flex: 1; min-width: 0; }
.detail-info h2 { margin: 0 0 6px; font-size: 18px; line-height: 1.32; }
.detail-author-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--line2);
  font-size: 12.5px; font-weight: 700; color: var(--accent-hi);
  cursor: pointer; margin-bottom: 8px;
}
.detail-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 2px; }
.d-badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--line); }
.detail-desc-wrap { position: relative; margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.detail-desc { font-size: 13px; line-height: 1.65; color: var(--muted); white-space: pre-line; margin: 0; }
.detail-desc.clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}
.detail-desc-more, .dl-more-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 7px; padding: 5px 12px; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--line2);
  color: var(--accent-hi); font-size: 12px; font-weight: 700; cursor: pointer;
}
.dl-more-btn { width: 100%; margin-top: 10px; border-radius: 10px; padding: 8px 12px; }
.detail-desc-more svg, .dl-more-btn svg { transition: transform .18s ease; }
.detail-desc-more.open svg, .dl-more-btn.open svg { transform: rotate(180deg); }
.dl-best-pill {
  display: inline-block; font-size: 10.5px; font-weight: 800; padding: 2px 8px;
  border-radius: 99px; background: var(--accent-bg); color: var(--accent-hi);
  border: 1px solid var(--accent-border); margin-inline-end: 5px;
}
.detail-act-bar { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.detail-primary-cta { width: 100%; min-height: 42px; font-size: 13.5px; font-weight: 800; border-radius: 12px; justify-content: center; }
.detail-sec-acts { display: flex; gap: 7px; flex-wrap: nowrap; }
.detail-sec-acts .btn { flex: 1; justify-content: center; min-width: 0; white-space: nowrap; }

.dl-links-box { background: var(--card); border: 1px solid var(--line2); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); border-radius: 14px; padding: 12px 13px; margin-bottom: 14px; contain: layout style; }
.dl-links-head { font-weight: 800; margin-bottom: 6px; font-size: 13px; color: var(--fg); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dl-link-row { padding: 9px 0; border-bottom: 1px solid var(--line); }
.dl-link-row:last-child { border-bottom: none; padding-bottom: 0; }
.dl-link-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }
.dl-link-meta { flex: 1; min-width: 0; }
.dl-link-title-line { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-bottom: 3px; }
.dl-link-lbl { font-size: 12.5px; line-height: 1.35; word-break: break-word; color: var(--fg); }
.dl-link-sub { font-size: 11px; color: var(--muted); }
.dl-link-act { flex-shrink: 0; }
.dl-link-act .btn { white-space: nowrap; }
#detailSimilarBox { contain: layout style; }

/* Author Hub Card */
.author-hero {
  display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap;
  background: var(--surface2); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; margin-bottom: 16px;
}
.author-avatar {
  width: 78px; height: 78px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: var(--accent-bg); color: var(--accent-hi);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; border: 2px solid var(--accent);
}
.author-meta { flex: 1; min-width: 200px; }
.author-meta h2 { margin: 0 0 6px; font-size: 20px; }
.author-meta p { margin: 0 0 8px; font-size: 13px; line-height: 1.65; color: var(--muted); }

.empty-state { text-align: center; padding: 44px 18px; color: var(--muted); }
.empty-ic { display: inline-flex; width: 58px; height: 58px; border-radius: 16px; background: var(--surface2); color: var(--accent-hi); align-items: center; justify-content: center; margin-bottom: 12px; }
.empty-state h3 { color: var(--fg); margin: 0 0 6px; font-size: 17px; }

.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  z-index: 90; background: #0f172a; color: #f8fafc; border: 1px solid var(--accent);
  padding: 10px 18px; border-radius: 99px; font-size: 13px; font-weight: 600;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42); white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 14px) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.toast.toast-pop { animation: toastIn 0.24s var(--ease-spring) both; }
.spin {
  width: 15px; height: 15px; border: 2px solid var(--line2); border-top-color: var(--accent-hi);
  border-radius: 50%; animation: sp 0.7s linear infinite; display: inline-block;
}
.spin.sm { width: 11px; height: 11px; border-width: 1.8px; border-top-color: currentColor; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- Responsive: Tablet & Phone ---------- */
@media (max-width: 680px) {
  .top-bar { padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px; gap: 6px; }
  .top-brand-txt small { display: none; }
  .midad-logo-wordmark { height: 20px; }
  .top-streak-pill { height: 32px; padding: 0 8px; font-size: 12px; gap: 3px; }
  .nav-dock {
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom, 0px));
  }
  .nav-items { justify-content: space-around; gap: 2px; width: 100%; }
  .nav-btn {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 14px;
    font-size: 9.8px;
  }
  .badge { position: absolute; top: 2px; left: 16%; margin: 0; }
  main#mainScroll { padding: calc(var(--topbar-h, 58px) + 10px) 12px 88px; }
  .toast { bottom: 76px; }
  .hero-card { flex-direction: row; text-align: start; padding: 9px 11px; }
  .hero-btns { justify-content: flex-start; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-sheet { border-radius: 18px 18px 0 0; max-height: 94vh; }
  .modal:not(.hidden) .modal-sheet { animation: mSheetUp 0.27s var(--ease-spring) both; }
  .modal-top { position: relative; padding-top: 15px; }
  .modal-top::before {
    content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 99px; background: var(--line2);
  }
  #scribdReaderModal .modal-top::before { display: none; }
}

/* ------------------------------------------------------------------ Arabized Book Cover Designer */
.bcover-fallback.ar-cover,
.detail-cover.ar-cover,
.hero-cover.ar-cover {
  background: linear-gradient(155deg, var(--c1, #0b4f4a), var(--c2, #091e26)) !important;
  color: #fdf8ec !important;
  padding: 18px 16px 14px 12px !important;
  position: relative;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: space-between !important;
  text-align: center;
  overflow: hidden;
}
.ar-cover::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 9px;
  background: linear-gradient(to left, rgba(255,255,255,.22) 0%, rgba(0,0,0,.42) 60%, rgba(255,255,255,.08) 100%);
  pointer-events: none;
}
.ar-cover::before {
  content: "";
  position: absolute;
  top: 7px; bottom: 7px; left: 7px; right: 13px;
  border: 1px solid rgba(246, 211, 134, 0.36);
  border-radius: 5px;
  box-shadow: inset 0 0 0 2px rgba(246, 211, 134, 0.08);
  pointer-events: none;
}
.ar-cov-top {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  z-index: 1; margin-top: 2px;
}
.ar-cov-motif {
  width: 18px; height: 18px; color: #f6d386; opacity: 0.92;
}
.ar-cov-seal {
  font-size: 9px; font-weight: 700; letter-spacing: 0.03em;
  color: rgba(246, 211, 134, 0.88);
}
.ar-cov-title {
  z-index: 1;
  font-size: 13.5px !important; font-weight: 800; line-height: 1.48 !important;
  color: #fffdf7;
  text-shadow: 0 2px 6px rgba(0,0,0,.45);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  padding: 0 4px;
}
.hero-cover.ar-cover .ar-cov-title { font-size: 15px !important; }
.detail-cover.ar-cover .ar-cov-title { font-size: 14px !important; -webkit-line-clamp: 5; }
.ar-cov-foot {
  z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%;
}
.ar-cov-rule {
  width: 36px; height: 1.5px; border-radius: 99px;
  background: linear-gradient(90deg, transparent, #f6d386, transparent);
}
.ar-cov-author {
  font-size: 10.5px !important; font-weight: 600; color: #f7e3b5 !important; opacity: 0.95 !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  padding: 0 6px;
}
.bcover .ar-cov-author {
  padding: 0 4px 0 28px;
}
.hero-cover.ar-cover {
  padding: 12px 13px 10px 9px !important;
}
.hero-cover.ar-cover .ar-cov-motif { width: 14px; height: 14px; }
.hero-cover.ar-cover .ar-cov-seal { display: none; }
.hero-cover.ar-cover .ar-cov-title { font-size: 13px !important; -webkit-line-clamp: 3; }

/* ------------------------------------------------------------------ Multi-Source Mirrors & Telegram Hub */
.dl-src-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700;
  background: var(--accent-bg);
  color: var(--accent-hi); border: 1px solid var(--accent-border);
  margin-left: 6px;
}
.dl-src-pill.tg { background: rgba(56, 189, 248, 0.14); color: #38bdf8; border-color: rgba(56, 189, 248, 0.3); }
[data-theme="light"] .dl-src-pill.tg,
[data-theme="sepia"] .dl-src-pill.tg { color: #0369a1; }
.dl-src-pill.arch { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border-color: rgba(245, 158, 11, 0.28); }
[data-theme="light"] .dl-src-pill.arch,
[data-theme="sepia"] .dl-src-pill.arch { color: #b45309; }
.dl-src-pill.hind { background: rgba(168, 85, 247, 0.14); color: #c084fc; border-color: rgba(168, 85, 247, 0.3); }
[data-theme="light"] .dl-src-pill.hind,
[data-theme="sepia"] .dl-src-pill.hind { color: #7e22ce; }

.tg-modal-box {
  margin-top: 10px; padding: 11px 12px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.22);
}
.tg-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; font-weight: 700; margin-bottom: 8px;
}
.tg-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tg-chip-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--card); color: var(--fg); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .15s, transform .12s;
}
.tg-chip-btn:hover { border-color: #38bdf8; transform: translateY(-1px); }

.tg-hub-panel {
  margin-top: 14px; padding: 9px 12px; border-radius: 13px;
  background: var(--card); border: 1px solid var(--border);
}
.tg-hub-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: transparent; border: 0; color: var(--fg); font-family: inherit;
  font-size: 13.5px; font-weight: 700; cursor: pointer; padding: 2px 0; text-align: right;
}
.tg-hub-toggle-main { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.tg-hub-arrow { transition: transform 0.2s ease; color: var(--muted); flex-shrink: 0; }
.tg-hub-toggle.open .tg-hub-arrow { transform: rotate(180deg); color: var(--accent-hi, var(--accent)); }
.tg-hub-body { margin-top: 10px; }
.tg-add-row {
  display: flex; gap: 6px; margin-bottom: 9px; flex-wrap: wrap; align-items: center;
}
.tg-add-row input {
  flex: 1 1 180px; min-width: 0; padding: 6px 10px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  font-family: inherit; font-size: 12px;
}
.disc-select-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 8px; margin-bottom: 12px;
}
.disc-select-field {
  display: flex; flex-direction: column; gap: 4px;
}
.disc-select-field label {
  font-size: 11px; font-weight: 700; color: var(--muted); padding-inline-start: 2px;
}
.disc-select {
  width: 100%; background: var(--surface); border: 1px solid var(--line2); color: var(--fg);
  border-radius: 12px; padding: 9px 12px; font-family: inherit;
  font-size: 13px; font-weight: 700; cursor: pointer; outline: none;
}
.disc-select.compact {
  width: auto; min-width: 165px; max-width: 260px; padding: 7px 11px; font-size: 12.5px;
}
.home-cat-dropdown-wrap {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
}
.tg-filter-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.tg-filter-bar label {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
}
.tg-cat-select {
  padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--line2); background: var(--surface); color: var(--fg);
  font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.tg-hub-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px;
}
.tg-hub-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 5px;
  padding: 8px 9px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
}
.tg-hub-card-top { display: flex; justify-content: space-between; align-items: center; gap: 5px; }
.tg-hub-card h4 { margin: 0; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-hub-card small {
  color: var(--muted); font-size: 10.5px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.tg-hub-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.tg-hub-actions .btn.sm { padding: 4px 8px; font-size: 11px; border-radius: 8px; }

/* Library Sort Select, Delete Choice & Multi-Copy Chooser Modals */
.lib-sort-select {
  background: var(--surface); border: 1px solid var(--line2); color: var(--fg);
  border-radius: 11px; padding: 8px 11px; font-family: inherit;
  font-size: 12.5px; font-weight: 700; cursor: pointer; outline: none;
}
.bfoot-owned {
  font-family: inherit; font-size: 10.5px; font-weight: 800; line-height: 1.2; cursor: pointer;
  padding: 3px 8px; border-radius: 99px;
  background: var(--accent-bg); color: var(--accent-hi); border: 1px solid rgba(52, 211, 153, 0.32);
}
.choice-stack, .copy-pick-list { display: flex; flex-direction: column; gap: 9px; }
.choice-opt-btn {
  width: 100%; text-align: right; font-family: inherit;
  background: var(--surface2); border: 1px solid var(--line2); color: var(--fg);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.choice-opt-btn:hover { border-color: var(--accent-hi); }
.choice-opt-btn strong { display: block; font-size: 14px; margin-bottom: 3px; }
.choice-opt-btn small { display: block; font-size: 12px; color: var(--muted); line-height: 1.45; }
.choice-opt-btn.danger { background: rgba(244, 63, 94, 0.09); border-color: rgba(244, 63, 94, 0.34); }
.choice-opt-btn.danger strong { color: #fda4af; }
[data-theme="light"] .choice-opt-btn.danger strong { color: #be123c; }
.copy-pick-row {
  background: var(--surface2); border: 1px solid var(--line2); border-radius: 13px;
  padding: 12px 13px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.copy-pick-info { flex: 1; min-width: 180px; }
.copy-pick-name { font-size: 13.5px; font-weight: 800; color: var(--fg); margin-bottom: 4px; word-break: break-word; }
.copy-pick-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.copy-pick-acts { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

/* Search Grouping Badges, Source Origins, Deduplication & Unified 0-100% Progress */
.bcard-variants-badge {
  position: absolute; bottom: 8px; right: 8px; z-index: 3;
  font-size: 10.5px; font-weight: 800; line-height: 1.25;
  padding: 3px 8px; border-radius: 99px;
  background: rgba(27, 28, 31, 0.92); color: var(--accent-hi);
  border: 1px solid var(--accent-border);
  max-width: calc(100% - 16px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.source-origin-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 99px;
  background: rgba(56, 189, 248, 0.14); color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.28);
}
[data-theme="light"] .source-origin-pill,
[data-theme="sepia"] .source-origin-pill {
  background: rgba(2, 132, 199, 0.1); color: #0369a1; border-color: rgba(2, 132, 199, 0.25);
}
.read-prio-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 800;
  padding: 2px 8px; border-radius: 99px;
  background: var(--accent-bg); color: var(--accent-hi);
  border: 1px solid var(--accent-border);
}
.pick-copy-dedup-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; margin-bottom: 12px; border-radius: 12px;
  background: rgba(244, 63, 94, 0.08); border: 1px solid rgba(244, 63, 94, 0.28);
  flex-wrap: wrap;
}
.pick-copy-del-btn, .lib-dedup-btn {
  border-color: rgba(244, 63, 94, 0.34) !important;
  color: #fda4af !important;
}
[data-theme="light"] .pick-copy-del-btn,
[data-theme="light"] .lib-dedup-btn { color: #be123c !important; }

.dl-link-row { position: relative; overflow: hidden; }
.dl-row-progress-wrap {
  width: 100%; margin-top: 8px; display: flex; flex-direction: column; gap: 4px;
}
.dl-row-progress-track {
  width: 100%; height: 6px; border-radius: 99px;
  background: rgba(148, 163, 184, 0.22); overflow: hidden;
}
.dl-row-progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transition: width 0.24s cubic-bezier(.22, .61, .36, 1);
}
.dl-row-progress-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; font-weight: 700; color: var(--accent-hi);
}
.btn.has-prog {
  position: relative; overflow: hidden;
}
.btn-prog-bar {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 0;
  background: rgba(255, 255, 255, 0.22);
  transition: width 0.24s linear; pointer-events: none;
}
.btn.has-prog > *:not(.btn-prog-bar) { position: relative; z-index: 1; }

/* Scribd & Cloud Full-Screen Reading Mode Overlay */
#scribdReaderModal { padding: 0 !important; align-items: stretch !important; justify-content: stretch !important; }
.sreader-sheet {
  width: 100% !important; max-width: 100% !important;
  height: 100% !important;
  max-height: 100% !important; border-radius: 0 !important; border: 0 !important;
  display: flex; flex-direction: column; padding: 0 !important; overflow: hidden;
}
.sreader-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface); flex-wrap: wrap; z-index: 4;
}
.sreader-title-wrap { flex: 1; min-width: 150px; }
.sreader-title {
  font-size: 14px; font-weight: 800; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sreader-dl-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: var(--accent-hi); margin-top: 2px;
}
.sreader-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sreader-theme-btn, .sreader-ctrl-btn {
  padding: 5px 10px; border-radius: 9px; font-family: inherit;
  font-size: 11.5px; font-weight: 700; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--line); color: var(--fg);
}
.sreader-theme-btn.active, .sreader-ctrl-btn.active {
  background: var(--accent-bg); border-color: var(--accent-hi); color: var(--accent-hi);
}
.sreader-body {
  position: relative; flex: 1; min-height: 320px; width: 100%; overflow: hidden;
  background: #080c15; transition: background 0.2s ease;
  display: flex; flex-direction: column;
}
.sreader-frame-clip {
  position: relative; flex: 1; width: 100%; height: 100%; overflow: hidden;
}
.sreader-frame {
  position: absolute; left: 0; top: -48px;
  width: 100%; height: calc(100% + 104px);
  border: 0; display: block; background: transparent;
  transform: scale(var(--sreader-zoom, 1));
  transform-origin: top center;
}
.sreader-body.theme-dark .sreader-frame { filter: invert(0.88) hue-rotate(180deg) contrast(0.95); }
.sreader-body.theme-sepia { background: #efe5cd; }
.sreader-body.theme-sepia .sreader-frame { filter: sepia(0.28); }
.sreader-body.theme-sage { background: #e3ece4; }
.sreader-body.theme-sage .sreader-frame { filter: sepia(0.14) hue-rotate(72deg) saturate(0.85); }
.sreader-body.theme-light { background: #f8fafc; }
.sreader-body.theme-light .sreader-frame { filter: none; }
.sreader-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  font-size: 13px; font-weight: 700; color: var(--muted); pointer-events: none; z-index: 2;
}
.sreader-loading.hidden { display: none; }

/* Reduced Motion Setting & Zero-Lag Orientation Switch Fast-Path + Responsive Landscape Layout */
html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  transition-duration: 0.01ms !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}
html.orient-switching *,
html.orient-switching *::before,
html.orient-switching *::after {
  transition: none !important;
  animation: none !important;
}
@media (orientation: landscape) and (max-height: 620px) {
  .nav-dock { bottom: 8px; padding: 4px 6px; }
  .nav-btn { padding: 7px 12px; font-size: 12px; }
  .top-bar { padding: 7px 14px; }
  .hero-card.hero-continue-card { padding: 9px 12px; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 7px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 10px; }
  .modal-sheet { max-height: 94dvh; }
  .detail-hero { flex-direction: row; align-items: flex-start; gap: 14px; }
  .detail-cover { width: 112px; }
  .sreader-topbar { padding: 5px 10px; gap: 6px; }
  .sreader-sheet { height: 100dvh !important; max-height: 100dvh !important; }
}

/* ---------- Smart Recommendation Engine UI (70 / 20 / 10, Metadata, Ratings, Cold Start) ---------- */
.sec-ratio-pill {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.2px;
  padding: 2px 8px; border-radius: 99px;
}
.sec-ratio-pill.personal {
  background: var(--accent-bg); color: var(--accent-hi); border: 1px solid var(--accent-border);
}
.sec-ratio-pill.horizon {
  background: rgba(56, 189, 248, 0.14); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.32);
}
.sec-ratio-pill.explore {
  background: rgba(245, 158, 11, 0.14); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.34);
}
[data-theme="light"] .sec-ratio-pill.horizon,
[data-theme="sepia"] .sec-ratio-pill.horizon { color: #0369a1; }
[data-theme="light"] .sec-ratio-pill.explore,
[data-theme="sepia"] .sec-ratio-pill.explore { color: #b45309; }

.rec-sub-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap; margin-bottom: 10px;
}
.time-ctx-bar {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 3px; border-radius: 99px;
}
.time-ctx-chip {
  border: none; background: transparent; cursor: pointer;
  padding: 4px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  transition: background 0.16s ease, color 0.16s ease;
}
.time-ctx-chip.on {
  background: var(--accent); color: var(--on-accent);
}

.bcard-reason {
  margin-top: 2px;
  font-size: 10.5px; font-weight: 700; line-height: 1.3;
  color: var(--accent-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bcard-reason.horizon { color: #7dd3fc; }
[data-theme="light"] .bcard-reason.horizon,
[data-theme="sepia"] .bcard-reason.horizon { color: #0284c7; }
.bcard-reason.explore { color: #fcd34d; }
[data-theme="light"] .bcard-reason.explore,
[data-theme="sepia"] .bcard-reason.explore { color: #b45309; }

.detail-micro-tags {
  display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 0;
}
.micro-tag-chip {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--muted);
}
.detail-rate-box {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 10px; padding: 8px 12px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
}
.detail-rate-lbl { font-size: 13px; font-weight: 800; color: var(--fg); }
.star-rating-row { display: inline-flex; align-items: center; gap: 3px; }
.star-btn {
  border: none; background: transparent; padding: 4px; cursor: pointer;
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.14s var(--ease-spring), color 0.14s ease;
}
.star-btn svg { width: 18px; height: 18px; }
.star-btn:hover { transform: scale(1.15); color: #fbbf24; }
.star-btn.on { color: #fbbf24; }
.star-btn.on svg { fill: #fbbf24; }
.detail-rate-status { font-size: 11.5px; font-weight: 700; color: var(--accent-hi); }
.detail-desc-head { font-size: 12.5px; font-weight: 800; color: var(--fg); margin: 2px 0 4px; }

.cohort-strip {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.cohort-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px;
  background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.28);
  color: #7dd3fc;
}
[data-theme="light"] .cohort-pill,
[data-theme="sepia"] .cohort-pill { color: #0369a1; background: rgba(2, 132, 199, 0.1); }

/* Cold Start Onboarding Modal */
.cs-sheet { width: min(680px, 100%); max-height: 92dvh; }
.cs-modal-body { padding: 12px 14px; display: flex; flex-direction: column; }
.cs-lead { margin: 0 0 8px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.cs-cat-section { margin-bottom: 6px; }
.cs-cat-section.collapsed {
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--line);
}
.cs-cat-section.collapsed .cs-step-head { margin-bottom: 0; }
.cs-cat-section.collapsed .cs-cat-grid { display: none; }
.cs-cat-toggle { font-size: 11.5px; font-weight: 800; padding: 2px 6px; }
.cs-books-head { margin-top: 6px; }
.cs-modal-body.cats-collapsed .cs-books-head { margin-top: 2px; }
.cs-step-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 6px; font-size: 13px;
}
.cs-counter {
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--muted);
}
.cs-counter.ready {
  background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent-hi);
}
.cs-cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 6px;
}
.cs-len-section { margin-bottom: 8px; }
.cs-len-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.cs-len-card {
  flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 9px;
}
.cs-len-card strong { display: block; font-size: 11.5px; line-height: 1.3; }
.cs-len-card small { display: block; font-size: 10px; color: var(--muted); line-height: 1.25; }
.cs-cat-card {
  display: flex; align-items: center; gap: 6px; text-align: start;
  padding: 6px 9px; border-radius: 10px; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--line); color: var(--fg);
  font-size: 11.5px; font-weight: 700;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.14s var(--ease-spring);
}
.cs-cat-card svg { width: 15px; height: 15px; flex-shrink: 0; }
.cs-cat-card:active { transform: scale(0.97); }
.cs-cat-card.on {
  background: var(--accent-bg);
  border-color: var(--accent-hi);
  color: var(--accent-hi);
}
.cs-search { margin-bottom: 8px; padding: 8px 11px; font-size: 12.5px; }
.cs-book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 6px;
  max-height: 44dvh; overflow-y: auto; padding: 2px;
}
.cs-modal-body.cats-collapsed .cs-book-grid {
  max-height: calc(74dvh - 115px);
}
.cs-book-card {
  display: flex; flex-direction: column; gap: 2px; text-align: start;
  padding: 7px 10px; border-radius: 10px; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--line); color: var(--fg);
  transition: border-color 0.16s ease, background 0.16s ease;
}
.cs-book-card strong {
  font-size: 12px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cs-book-card small { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-book-card.on {
  background: var(--accent-bg);
  border-color: var(--accent-hi);
}
.cs-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
@media (max-width: 520px) {
  .cs-len-grid { grid-template-columns: 1fr; gap: 5px; }
  .cs-cat-grid { grid-template-columns: repeat(2, 1fr); gap: 5px; }
  .cs-book-grid { grid-template-columns: 1fr; max-height: 44dvh; }
  .cs-modal-body.cats-collapsed .cs-book-grid { max-height: calc(76dvh - 110px); }
}

/* ---------- Reading-First Continue Hero + Companion + Next Book Subrow ---------- */
.home-lead-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.home-lead-grid.filtered-out {
  display: none;
}
.home-lead-grid .hero-card {
  margin-bottom: 0;
  min-width: 0;
}
.hero-card.hero-continue-card {
  display: block;
  text-align: start;
  padding: 9px 12px;
}
.home-lead-subrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}
.home-lead-subrow.no-next {
  grid-template-columns: minmax(0, 1fr);
}
.hero-next-host { min-width: 0; display: flex; }
.hero-next-host .hero-next-card { width: 100%; }
.hero-main-spotlight {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.hero-main-spotlight.compact .hero-main-cov {
  width: 56px;
  height: 80px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}
.hero-main-spotlight.compact .hero-title {
  font-size: 14px;
  line-height: 1.32;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-sub-line {
  margin: 0 0 6px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-main-spotlight.compact .hero-btns {
  gap: 5px;
  flex-wrap: nowrap;
  align-items: center;
}
.hero-main-spotlight.compact .hero-btns .btn {
  padding: 4px 9px;
  font-size: 11.5px;
  min-height: 30px;
  height: 30px;
  border-radius: 8px;
  white-space: nowrap;
}
.hero-main-spotlight.compact .hero-btns .btn.hero-like-icon-btn {
  width: 30px;
  padding: 0;
  justify-content: center;
  flex-shrink: 0;
}
.hero-main-spotlight.compact .hero-btns .btn.hero-continue-cta,
.hero-btns .btn.hero-continue-cta {
  padding: 5px 12px;
  min-height: 30px;
  height: 30px;
  font-size: 11.5px;
  font-weight: 800;
  border-radius: 8px;
  flex: 0 0 auto;
  justify-content: center;
  box-shadow: 0 2px 6px var(--accent-bg);
}
.hero-author-chip {
  min-width: 0;
  max-width: 120px;
}
.hero-author-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-main-cov {
  flex-shrink: 0;
}
.hero-kicker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}
.hero-kicker-row .hero-kicker {
  margin-bottom: 0;
  padding: 2px 8px;
  font-size: 10.5px;
}
.hero-kicker.resume {
  color: var(--accent-hi);
}
.hero-opt-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.14s var(--ease-spring), border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}
.hero-opt-toggle svg { width: 13px; height: 13px; }
.hero-opt-toggle:hover { border-color: var(--accent-hi); color: var(--fg); }
.hero-opt-toggle.on {
  background: var(--surface2);
  border-color: var(--line2);
  color: var(--accent-hi);
}
.hero-submeta {
  font-size: 11.5px;
  color: var(--accent-hi);
  font-weight: 700;
  margin: 0 0 6px;
}
.hero-prog-wrap {
  margin: 0 0 7px;
}
.hero-prog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.hero-prog-head strong {
  color: var(--accent-hi);
  font-weight: 800;
}
.hero-prog-track {
  height: 6px;
  border-radius: 99px;
  background: var(--surface2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.hero-prog-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transition: width 0.35s var(--ease-spring);
}
.hero-pull-quote {
  margin: 0 0 8px;
  padding: 7px 10px;
  border-radius: 11px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-inline-start: 3px solid var(--accent-hi);
}
.hero-quote-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  color: var(--accent-hi);
  margin-bottom: 2px;
}
.hero-quote-tag svg { width: 11px; height: 11px; }
.hero-quote-txt {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-quote-meta {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
}
.hero-next-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line2);
  box-shadow: inset 0 1px 0 var(--rim);
  cursor: pointer;
  min-width: 0;
  transition: transform 0.18s var(--ease-spring), border-color 0.18s ease, box-shadow 0.18s ease;
}
.hero-next-card:hover {
  border-color: var(--accent-hi);
  transform: translateY(-2px);
  box-shadow: var(--card-hover-shadow);
}
.hero-next-kicker {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-hi);
}
.hero-next-kicker svg { width: 13px; height: 13px; }
.hero-next-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.hero-next-cov {
  width: 66px;
  height: 94px;
  border-radius: 9px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  font-size: 10px;
  font-weight: 800;
  border: 1px solid var(--line2);
}
.hero-next-cov.ar-cover .ar-cov-motif { width: 11px; height: 11px; }
.hero-next-cov.ar-cover .ar-cov-seal { display: none; }
.hero-next-cov.ar-cover .ar-cov-title { font-size: 10px !important; -webkit-line-clamp: 3; }
.hero-next-info { flex: 1; min-width: 0; }
.hero-next-title {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-next-author {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-hi);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-next-meta {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-next-why {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero-next-btn { width: 100%; justify-content: center; }

/* Unified Smart Library Mix Toolbar */
.smart-mix-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.smart-mix-toolbar .chips-row {
  padding: 0;
  margin: 0;
  flex-wrap: nowrap;
  width: 100%;
}
.smart-mix-toolbar .chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.smart-mix-toolbar .sec-ratio-pill {
  font-size: 10px;
  padding: 1px 6px;
}
.smart-mix-toolbar .chip.on .sec-ratio-pill {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

/* ---------- Duolingo-Style Animated Reading Companion Widget ---------- */
.companion-host { min-width: 0; }
.companion-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  height: 100%;
  padding: 11px 12px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line2);
  box-shadow: inset 0 1px 0 var(--rim);
  position: relative;
  overflow: hidden;
  min-width: 0;
  transition: border-color 0.24s ease, background 0.24s ease;
}
.companion-card.mood-completed {
  border-color: var(--accent-border);
  background: var(--card);
}
.companion-card.mood-eager {
  border-color: var(--line2);
  background: var(--card);
}
.companion-card.mood-angry {
  border-color: rgba(244, 63, 94, 0.45);
  background: var(--card);
}
.companion-card.mood-frozen {
  border-color: rgba(56, 189, 248, 0.48);
  background: var(--card);
}
.comp-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.comp-mood-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--line2);
  background: var(--surface2);
  color: var(--accent-hi);
}
.comp-mood-badge.mood-completed { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent-hi); }
.comp-mood-badge.mood-angry { background: rgba(244, 63, 94, 0.16); border-color: rgba(244, 63, 94, 0.44); color: #fb7185; }
.comp-mood-badge.mood-frozen { background: rgba(56, 189, 248, 0.18); border-color: rgba(56, 189, 248, 0.46); color: #38bdf8; }
[data-theme="light"] .comp-mood-badge.mood-angry,
[data-theme="sepia"] .comp-mood-badge.mood-angry { color: #be123c; }
[data-theme="light"] .comp-mood-badge.mood-frozen,
[data-theme="sepia"] .comp-mood-badge.mood-frozen { color: #0369a1; }

.comp-top-chips {
  display: flex;
  align-items: center;
  gap: 6px;
}
.comp-streak-pill,
.comp-freeze-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 800;
  background: var(--surface2);
  border: 1px solid var(--line);
}
.comp-streak-pill { color: #fbbf24; border-color: rgba(245, 158, 11, 0.34); }
.comp-streak-pill svg { width: 13px; height: 13px; color: #f59e0b; }
[data-theme="light"] .comp-streak-pill,
[data-theme="sepia"] .comp-streak-pill { color: #b45309; }
.comp-freeze-pill { color: #38bdf8; border-color: rgba(56, 189, 248, 0.3); }
.comp-freeze-pill svg { width: 13px; height: 13px; }
[data-theme="light"] .comp-freeze-pill,
[data-theme="sepia"] .comp-freeze-pill { color: #0284c7; }
.comp-gear-btn { width: 30px; height: 30px; }

.comp-hero-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.comp-mascot-btn {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 15px;
  background: var(--surface2);
  border: 1px solid var(--line2);
  padding: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s var(--ease-spring), border-color 0.2s ease;
}
.comp-mascot-btn:hover { transform: scale(1.04); border-color: var(--accent-hi); }
.comp-mascot-btn:active { transform: scale(0.92); }
.companion-mascot-svg { width: 100%; height: 100%; overflow: visible; }

@keyframes companionFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-4px); }
}
@keyframes companionCelebrate {
  0%, 100% { transform: translateY(0px) rotate(0deg) scale(1); }
  25% { transform: translateY(-6px) rotate(-4deg) scale(1.04); }
  55% { transform: translateY(-3px) rotate(4deg) scale(1.03); }
}
@keyframes companionAngryShake {
  0%, 60%, 100% { transform: translateX(0px) rotate(0deg); }
  66% { transform: translateX(-3px) rotate(-3deg); }
  74% { transform: translateX(3px) rotate(3deg); }
  82% { transform: translateX(-2px) rotate(-2deg); }
  90% { transform: translateX(2px) rotate(2deg); }
}
@keyframes companionFrozenShiver {
  0%, 70%, 100% { transform: translateX(0px); }
  74% { transform: translateX(-2px); }
  78% { transform: translateX(2px); }
  82% { transform: translateX(-1.5px); }
  86% { transform: translateX(1.5px); }
}
@keyframes compPulseSoft {
  0%, 100% { opacity: 0.72; transform: scale(0.97); }
  50% { opacity: 1; transform: scale(1.04); }
}
@keyframes compPupilLook {
  0%, 42%, 100% { transform: translateX(0px); }
  48%, 58% { transform: translateX(-1.4px); }
  66%, 78% { transform: translateX(1.2px); }
}

.companion-mascot-svg.mood-eager { animation: companionFloat 3.1s ease-in-out infinite; }
.companion-mascot-svg.mood-completed { animation: companionCelebrate 1.85s ease-in-out infinite; }
.companion-mascot-svg.mood-angry { animation: companionAngryShake 2.3s ease-in-out infinite; }
.companion-mascot-svg.mood-frozen { animation: companionFrozenShiver 2.5s linear infinite; }
.companion-mascot-svg .owl-pupil { animation: compPupilLook 4.4s ease-in-out infinite; }
.companion-mascot-svg .celebrate-sparks,
.companion-mascot-svg .angry-steam,
.companion-mascot-svg .ice-overlay {
  transform-box: fill-box;
  transform-origin: center;
  animation: compPulseSoft 1.8s ease-in-out infinite;
}

.comp-speech-col { flex: 1; min-width: 0; }
.comp-quip-bubble {
  padding: 6px 9px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.45;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 6px;
}
.comp-task-box { display: flex; flex-direction: column; gap: 5px; }
.comp-task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.comp-task-head strong { color: var(--fg); font-weight: 800; }
.comp-prog-track {
  height: 8px;
  border-radius: 99px;
  background: var(--surface2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.comp-prog-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transition: width 0.35s var(--ease-spring);
}
.companion-card.mood-angry .comp-prog-fill {
  background: linear-gradient(90deg, #e11d48, #fb923c);
}
.companion-card.mood-frozen .comp-prog-fill {
  background: linear-gradient(90deg, #0284c7, #7dd3fc);
}
.comp-task-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.comp-actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.comp-actions-row .btn {
  flex: 1;
  justify-content: center;
  min-width: 84px;
  min-height: 30px;
  padding: 5px 8px;
  font-size: 11.5px;
}
.comp-thaw-btn { width: 100%; justify-content: center; }

.comp-config-drawer {
  margin-top: 2px;
  padding: 11px;
  border-radius: 13px;
  background: var(--surface2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comp-cfg-grp {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.comp-cfg-row {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.comp-cfg-lbl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--muted);
}
.comp-cfg-lbl svg { width: 13px; height: 13px; }
.comp-goal-pills,
.comp-preview-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.comp-goal-pill,
.comp-mood-chip {
  padding: 5px 10px;
  border-radius: 99px;
  border: 1px solid var(--line2);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.comp-goal-pill.on,
.comp-mood-chip.on {
  background: var(--accent-bg);
  border-color: var(--accent-hi);
  color: var(--accent-hi);
}
.comp-num-inp,
.comp-time-inp {
  padding: 5px 9px;
  border-radius: 9px;
  border: 1px solid var(--line2);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}
.comp-num-inp { width: 68px; text-align: center; }

/* ---------- Book Reviews & Ratings System ---------- */
.d-badge-rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.34);
}
.d-badge-rating svg { width: 12px; height: 12px; fill: #fbbf24; }
[data-theme="light"] .d-badge-rating,
[data-theme="sepia"] .d-badge-rating { color: #b45309; }
[data-theme="light"] .d-badge-rating svg,
[data-theme="sepia"] .d-badge-rating svg { fill: #d97706; }

.reviews-sec { margin: 12px 0; contain: layout style; }
.reviews-overview {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  margin-bottom: 9px;
}
.reviews-score-col { text-align: center; }
.reviews-avg-num { font-size: 25px; font-weight: 900; line-height: 1.05; color: var(--fg); }
.reviews-avg-stars { display: inline-flex; gap: 2px; margin: 3px 0 2px; }
.rev-star { display: inline-flex; color: var(--line2); }
.rev-star svg { width: 12px; height: 12px; }
.rev-star.on { color: #fbbf24; }
.rev-star.on svg { fill: #fbbf24; }
.reviews-avg-cnt { font-size: 10.5px; color: var(--muted); font-weight: 600; }

.reviews-bars-col { display: flex; flex-direction: column; gap: 3px; }
.rbar-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.rbar-lbl { width: 11px; text-align: center; font-weight: 800; }
.rbar-track { flex: 1; height: 6px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--line); overflow: hidden; }
.rbar-fill { height: 100%; border-radius: 99px; background: #f59e0b; }
.rbar-cnt { width: 18px; text-align: end; font-weight: 700; }

.review-composer {
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface2);
  border: 1px solid var(--line);
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.composer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.composer-top strong { font-size: 13px; font-weight: 800; }
.review-tag-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.review-textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 74px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line2);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
}
.review-textarea:focus { outline: none; border-color: var(--accent-hi); }
.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.composer-hint { font-size: 11px; color: var(--muted); }

.reviews-sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.reviews-sort-lbl { font-size: 12.5px; font-weight: 800; color: var(--muted); }
.reviews-list { display: flex; flex-direction: column; gap: 7px; }
.review-card {
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.review-card.mine {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}
.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.review-author-row { display: flex; align-items: center; gap: 9px; }
.review-avatar {
  width: 30px;
  height: 30px;
  border-radius: 99px;
  background: var(--accent-bg);
  color: var(--accent-hi);
  border: 1px solid var(--accent-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  flex-shrink: 0;
}
.review-author-name { font-size: 12.5px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.review-mine-pill {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--accent-bg);
  color: var(--accent-hi);
  font-weight: 800;
}
.review-stars-mini { display: flex; gap: 2px; margin-top: 2px; }
.review-tag-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--accent-bg);
  color: var(--accent-hi);
  border: 1px solid var(--accent-border);
}
.review-body-txt {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg);
}
.review-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.review-helpful-btn,
.review-del-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 9px;
  border: 1px solid var(--line2);
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.review-helpful-btn svg,
.review-del-btn svg { width: 13px; height: 13px; }
.review-helpful-btn.on {
  border-color: var(--accent-hi);
  background: var(--accent-bg);
  color: var(--accent-hi);
}
.review-del-btn { color: #fb7185; border-color: rgba(244, 63, 94, 0.26); }
.reviews-empty { padding: 12px 14px; border-radius: 12px; background: var(--surface2); font-size: 12.5px; color: var(--muted); text-align: center; }
.reviews-ext-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 99px;
  background: var(--accent-bg); color: var(--accent-hi); border: 1px solid var(--accent-border);
  margin-inline-start: 6px;
}
.reviews-loading-note {
  font-size: 11.5px; color: var(--muted); padding: 6px 2px;
}

/* Compact 2-Column Settings Sheet */
.modal-sheet.settings-sheet {
  width: min(740px, 100%);
  max-height: 89vh;
}
#settingsModal .modal-body {
  padding: 12px 14px;
}
.settings-compact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.set-card {
  padding: 10px 11px;
  border-radius: 13px;
  background: var(--surface2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.set-card-full {
  grid-column: 1 / -1;
}
.set-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.set-card-head strong {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--fg);
}
.set-card-head small {
  font-size: 10.5px;
  color: var(--muted);
}
.set-inline-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.set-inline-row .chips-row { padding: 0; margin: 0; }
.set-cats-wrap { flex-wrap: wrap; padding: 0; gap: 5px; }
.set-card .seg-row { margin-bottom: 0; }
.set-card .seg-row button {
  padding: 5px 8px;
  font-size: 11px;
  gap: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.set-hint {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

/* Responsive Breakpoints (Tablet + Desktop side-by-side -> Mobile 375px safe) */
@media (max-width: 600px) {
  .settings-compact-grid { grid-template-columns: 1fr; }
}
@media (max-width: 500px) {
  .home-lead-subrow { grid-template-columns: 1fr; }
  .hero-main-spotlight { gap: 10px; }
  .hero-main-spotlight.compact .hero-main-cov { width: 52px; height: 76px; }
  .reviews-overview { grid-template-columns: 82px minmax(0, 1fr); gap: 10px; padding: 9px 10px; }
}
html[data-motion="reduced"] .companion-mascot-svg,
html[data-motion="reduced"] .companion-mascot-svg * {
  animation: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .companion-mascot-svg,
  .companion-mascot-svg * {
    animation: none !important;
  }
}

/* About Developer Modal */
.modal-sheet.about-sheet {
  width: min(390px, 100%);
}
.about-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 6px 4px;
}
.about-crest {
  width: 78px;
  height: 78px;
  border-radius: 20px;
  background: var(--logo-frame-bg);
  padding: 5px;
  border: 2px solid var(--accent-border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}
.about-app-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--fg);
  letter-spacing: -0.2px;
}
.about-dev-line {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  margin: 0;
}
.about-dev-line strong {
  color: var(--accent-hi);
  font-weight: 800;
}
.about-links {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.about-link-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 13px;
  background: var(--surface2);
  border: 1px solid var(--line2);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s var(--ease-spring), border-color 0.16s ease, background 0.16s ease;
}
.about-link-btn:hover {
  border-color: var(--accent-hi);
  background: var(--accent-bg);
}
.about-link-btn:active { transform: scale(0.98); }
.about-link-left {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--accent-hi);
  font-weight: 800;
}
.about-link-left svg { width: 17px; height: 17px; }
.about-link-val {
  direction: ltr;
  unicode-bidi: isolate;
  font-weight: 800;
  color: var(--fg);
}
.about-donate-btn {
  border-color: color-mix(in srgb, var(--accent-hi) 42%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-bg) 90%, transparent), var(--surface2));
}
.about-donate-btn:hover {
  border-color: var(--accent-hi);
}

/* ---------- Daily Literary Quote Strip ---------- */
.modal-sheet.habit-sheet {
  width: min(460px, 100%);
}
.daily-quote-strip {
  margin: 0 0 8px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.035);
  padding: 6px 10px;
}
.daily-quote-strip:empty { display: none; }
.dq-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dq-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--accent-hi);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dq-mark svg { width: 12px; height: 12px; }
.dq-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg);
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dq-author {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.dq-next-btn {
  flex-shrink: 0;
  color: var(--muted);
}
.dq-next-btn:hover { color: var(--accent-hi); }

/* ---------- Refined Files / Downloads Workspace Layout ---------- */
#tab-downloads .lib-hero {
  padding: 10px 14px;
  gap: 10px;
  border-radius: 15px;
  margin-bottom: 10px;
}
#tab-downloads .lib-sort-select {
  height: 36px;
  padding: 0 10px;
  font-size: 12px;
}
#tab-downloads .lib-view-seg button {
  padding: 5px 10px;
  font-size: 11.5px;
}
#tab-downloads #btnNewLibFolder {
  height: 36px;
  padding: 0 11px;
}
@media (max-width: 600px) {
  #tab-downloads .lib-hero {
    padding: 10px 12px;
    gap: 8px;
  }
  #tab-downloads .lib-hero small#dlFolderHint {
    display: none;
  }
  #tab-downloads .lib-hero-acts {
    width: 100%;
    justify-content: flex-start;
  }
  #tab-downloads .lib-search-box {
    flex: 1 1 100%;
    max-width: none;
  }
  #tab-downloads .lib-toolbar-ctrls {
    width: 100%;
    justify-content: space-between;
  }
  #tab-downloads .lib-sort-select {
    flex: 1 1 140px;
    min-width: 0;
  }
}
#tab-downloads .lib-grid:not(.compact) {
  grid-template-columns: repeat(auto-fill, minmax(336px, 1fr));
  gap: 14px;
}
#tab-downloads .lib-card:not(.compact) {
  padding: 14px;
  gap: 14px;
  align-items: stretch;
  border-radius: 16px;
}
#tab-downloads .lib-thumb {
  width: 84px;
  height: 122px;
  border-radius: 11px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
  flex-shrink: 0;
}
#tab-downloads .lib-thumb .lib-thumb-mono {
  padding: 6px;
  font-size: 10px;
}
#tab-downloads .lib-thumb .ar-cov-title { font-size: 11px; line-height: 1.3; }
#tab-downloads .lib-thumb .ar-cov-author { font-size: 9px; }
#tab-downloads .lib-thumb .ar-cov-seal { font-size: 8px; padding: 1px 5px; }
#tab-downloads .lib-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
#tab-downloads .lib-title {
  font-size: 14.5px;
  line-height: 1.35;
}
#tab-downloads .lib-card-acts {
  gap: 6px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
#tab-downloads .lib-card-acts .btn.sm {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 11.5px;
}
@media (max-width: 560px) {
  #tab-downloads .lib-grid:not(.compact) {
    grid-template-columns: minmax(0, 1fr);
    gap: 11px;
  }
  #tab-downloads .lib-card:not(.compact) {
    padding: 12px;
    gap: 11px;
  }
  #tab-downloads .lib-thumb {
    width: 72px;
    height: 106px;
  }
  .modal-sheet {
    border-radius: 18px 18px 0 0;
  }
  .detail-hero { gap: 11px; margin-bottom: 10px; }
  .detail-cover { width: 96px; height: 136px; }
  .detail-info h2 { font-size: 16.5px; }
}

.mtproto-cfg-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin: 8px 0;
}
.mtproto-inp {
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--surface2);
  border: 1px solid var(--line2);
  color: var(--fg);
  font-size: 12px;
  direction: ltr;
}
.mtproto-inp::placeholder { color: var(--muted); opacity: 0.85; }
@media (max-width: 680px) {
  .mtproto-cfg-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------- Audiobooks Tab & Player & Persistent Mini Bar ---------------- */
#tab-audiobooks { padding-bottom: 100px; }
.ab-hero {
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: 14px;
  padding: 9px 12px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.ab-hero-main { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.ab-hero-ic {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent-bg); border: 1px solid var(--accent-border); color: var(--accent-hi);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ab-hero-copy { min-width: 0; flex: 1; }
.ab-hero-titleline { display: flex; align-items: center; flex-wrap: nowrap; gap: 6px; }
.ab-hero-titleline h3 { margin: 0; font-size: 14.5px; font-weight: 800; color: var(--fg); white-space: nowrap; }
.ab-widget-hint {
  font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-bg); border: 1px solid var(--accent-border); color: var(--accent-hi);
  white-space: nowrap;
}
.ab-hero-copy small { display: block; margin-top: 1px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-hero-acts { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ab-hero-acts .btn { padding: 5px 10px; min-height: 30px; font-size: 11.5px; white-space: nowrap; }

.ab-player-card {
  background: linear-gradient(135deg, var(--surface2), var(--card));
  border: 1px solid var(--accent-border);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.ab-pl-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ab-pl-cov {
  width: 78px; height: 52px; border-radius: 10px; overflow: hidden; flex-shrink: 0;
  background: #0d1520; border: 1px solid var(--accent-border);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.ab-pl-cov img { width: 100%; height: 100%; object-fit: contain; display: block; background: #0d1520; }
.ab-pl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ab-pl-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.ab-mode-badge {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent-hi); border: 1px solid var(--accent-border);
}
.ab-mode-badge.offline { background: rgba(245, 158, 11, 0.14); color: var(--gold-hi); border-color: rgba(245, 158, 11, 0.34); }
.ab-pl-chap { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.ab-pl-title { font-size: 14.5px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-pl-author { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-spd-btn { min-width: 48px; font-weight: 700; font-size: 11.5px; direction: ltr; flex-shrink: 0; }

.ab-pl-seek-row { display: flex; align-items: center; gap: 10px; margin: 12px 0 10px; direction: ltr; }
.ab-time-txt { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 42px; text-align: center; }
.ab-seek-slider { flex: 1; min-width: 0; accent-color: var(--accent); cursor: pointer; height: 5px; }

.ab-pl-ctrls { display: flex; align-items: center; justify-content: center; gap: 12px; }
.ab-delta-btn { min-width: 52px; font-weight: 700; font-size: 11.5px; }
.ab-play-main-btn {
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 6px 16px rgba(4, 120, 87, 0.28); transition: transform 0.15s ease;
}
.ab-play-main-btn:active { transform: scale(0.94); }

.ab-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  margin-bottom: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 13px; padding: 8px 10px;
}
.ab-search-box {
  display: flex; align-items: center; gap: 6px; flex: 1 1 240px; min-width: 0;
  background: var(--surface2); border: 1px solid var(--line2); border-radius: 10px; padding: 2px 8px;
}
.ab-search-box input {
  flex: 1; min-width: 0; background: transparent; border: none; color: var(--fg);
  font-size: 12.5px; outline: none; padding: 5px 0;
}
.ab-search-box input::placeholder { color: var(--muted); }
.ab-mode-seg { flex: 0 1 auto; width: 100%; margin-bottom: 0; }
.ab-mode-seg button { padding: 5px 8px; font-size: 11px; }

.ab-offline-wrap {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; margin-bottom: 14px;
}
.ab-offline-list { display: flex; flex-direction: column; gap: 8px; }
.ab-offline-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--line);
}
.ab-offline-row-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ab-offline-row-main strong { font-size: 13px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-offline-row-main span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-offline-row-acts { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.ab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 9px; }
.ab-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px; display: flex; gap: 10px; align-items: stretch;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.ab-card.wide-cov { flex-direction: column; gap: 10px; }
.ab-card:hover { border-color: var(--accent-border); box-shadow: var(--card-hover-shadow); }
.ab-card-cov {
  width: 88px; height: 96px; border-radius: 11px; overflow: hidden; flex-shrink: 0;
  position: relative; background: rgba(15, 23, 42, 0.08); align-self: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.ab-card-cov img { width: 100%; height: 100%; object-fit: cover; display: block; background: rgba(15, 23, 42, 0.08); }
.ab-card.wide-cov .ab-card-cov {
  width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 12px; background: #0d1520; align-self: stretch;
}
.ab-card.wide-cov .ab-card-cov img { width: 100%; height: 100%; object-fit: contain; background: #0d1520; }
.ab-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.ab-card-title { font-size: 14px; font-weight: 800; color: var(--fg); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ab-card-author { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-card-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.ab-tag {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 7px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--muted);
}
.ab-tag.accent { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent-hi); }
.ab-tag.offline { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.32); color: var(--gold-hi); }
.ab-card-acts { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; border-top: 1px solid var(--line); }

.ab-mini-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 84px;
  width: min(600px, calc(100vw - 20px));
  z-index: 34;
  background: var(--elevated);
  border: 1px solid var(--accent-border);
  border-radius: 16px;
  padding: 7px 11px 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.ab-mini-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ab-mini-play {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer;
}
.ab-mini-info { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.ab-mini-info strong { font-size: 12.5px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-mini-info span { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-mini-jumps { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
.ab-mini-delta {
  padding: 4px 7px; font-size: 10.5px; font-weight: 800;
  border-radius: 9px; min-height: 26px; line-height: 1;
}
.ab-mini-seek-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.ab-mini-slider { flex: 1; height: 18px; margin: 0; }
.ab-mini-seek-row .ab-time-txt { font-size: 10.5px; min-width: 38px; text-align: center; }

.ab-modal-hero { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 10px; flex-wrap: nowrap; }
.ab-modal-cov { width: 74px; height: 90px; border-radius: 10px; overflow: hidden; flex-shrink: 0; background: rgba(15, 23, 42, 0.08); }
.ab-modal-cov img { width: 100%; height: 100%; object-fit: contain; display: block; }
.ab-modal-cov.wide { width: 100%; max-width: 240px; height: auto; aspect-ratio: 16 / 9; background: #0d1520; }
.ab-modal-cov.wide img { background: #0d1520; }
.ab-modal-meta { flex: 1; min-width: 0; }
.ab-modal-meta h3 { margin: 0 0 3px; font-size: 15.5px; color: var(--fg); line-height: 1.3; }
.ab-modal-meta p { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ab-mode-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-bottom: 10px; }
.ab-mode-acts .btn { width: 100%; justify-content: center; white-space: nowrap; }
.ab-chapters-list { display: flex; flex-direction: column; gap: 6px; max-height: 52dvh; overflow-y: auto; }
.ab-chapter-row {
  display: flex; flex-direction: column; gap: 5px;
  padding: 8px 10px; border-radius: 11px; background: var(--card); border: 1px solid var(--line);
}
.ab-chapter-row.playing { border-color: var(--accent); background: var(--accent-bg); }
.ab-ch-top { display: flex; align-items: center; gap: 7px; width: 100%; min-width: 0; }
.ab-ch-title { flex: 1; min-width: 0; font-size: 12.5px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-ch-mv-pair { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; }
.ab-ch-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.ab-ch-meta { font-size: 11px; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-chapter-acts { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; }
.ab-chapter-acts .btn { padding: 4px 9px; min-height: 28px; font-size: 11.5px; white-space: nowrap; }

@media (max-width: 600px) {
  .ab-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .ab-card-cov { width: 68px; min-height: 94px; }
  .ab-mini-bar { bottom: 78px; }
}

.ab-pl-top-acts { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ab-sleep-btn.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-hi); }
.ab-cat-pills { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; padding-bottom: 2px; scrollbar-width: none; }
.ab-cat-pills::-webkit-scrollbar { display: none; }
.ab-tag.licensed { background: rgba(99, 102, 241, 0.14); border-color: rgba(99, 102, 241, 0.34); color: #a5b4fc; }
[data-theme="light"] .ab-tag.licensed, [data-theme="sepia"] .ab-tag.licensed { color: #4338ca; }

.ab-ch-tools {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 10px; margin-bottom: 8px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
}
.ab-ch-tools-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.ab-ch-tools-acts { justify-content: space-between; padding-top: 5px; border-top: 1px dashed var(--line); }
.ab-ch-acts-pair { display: inline-flex; align-items: center; gap: 6px; flex: 1; justify-content: flex-end; }
.ab-ch-acts-pair .btn { padding: 5px 10px; min-height: 30px; font-size: 11.5px; white-space: nowrap; }
.ab-ch-lbl { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.ab-ch-total { font-size: 11.5px; color: var(--muted); }
.ab-ch-summary { font-size: 11.5px; font-weight: 800; color: var(--accent-hi, var(--accent)); }
.ab-ch-num {
  width: 56px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); font-size: 12px; font-weight: 700; text-align: center;
}
.ab-ch-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.ab-ch-pill {
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 700; cursor: pointer;
}
.ab-ch-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ab-ch-chk-wrap { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; }
.ab-ch-chk { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.ab-ch-mv { min-width: 26px; width: 26px; height: 26px; padding: 0; font-size: 12px; font-weight: 800; }
.ab-chapter-row.unselected { opacity: 0.52; }
@media (max-width: 600px) {
  .ab-chapter-row { flex-wrap: wrap; }
  .ab-chapter-acts { flex-wrap: wrap; }
}
