@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

:root {
  /* Premium Dark Theme (Default) */
  --bg-base: #0f1115;
  --bg-elevated: #161920;
  --bg-glass: rgba(22, 25, 32, 0.7);
  --bg-glass-hover: rgba(35, 40, 52, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  
  --text-primary: #f1f3f5;
  --text-secondary: #a0a8b5;
  --text-tertiary: #6b7280;
  
  --accent-primary: #818cf8; /* Soft Indigo */
  --accent-primary-hover: #6366f1;
  --accent-glow: rgba(129, 140, 248, 0.25);
  
  --accent-secondary: #f472b6; /* Soft Pink */
  --status-success: #34d399;
  --status-error: #f87171;
  --status-warning: #fbbf24;

  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-reading: 'Lora', Georgia, serif;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 20px var(--accent-glow);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  --reader-max-width: 800px;
}

[data-theme="light"] {
  --bg-base: #f9fafb;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.8);
  --bg-glass-hover: rgba(243, 244, 246, 0.9);
  
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.15);
  
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #9ca3af;
  
  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-glow: rgba(79, 70, 229, 0.2);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 15px 30px -5px rgba(0, 0, 0, 0.08);
}

[data-theme="sepia"] {
  --bg-base: #f4ecd8;
  --bg-elevated: #fdf6e3;
  --bg-glass: rgba(253, 246, 227, 0.85);
  --bg-glass-hover: rgba(244, 236, 216, 0.95);
  --border-subtle: rgba(133, 105, 78, 0.15);
  --border-strong: rgba(133, 105, 78, 0.3);
  --text-primary: #433422;
  --text-secondary: #5c4b37;
  --text-tertiary: #85694e;
  --accent-primary: #d46a6a;
  --accent-primary-hover: #b55050;
  --accent-glow: rgba(212, 106, 106, 0.2);
}

[data-theme="oled"] {
  --bg-base: #000000;
  --bg-elevated: #0a0a0a;
  --bg-glass: rgba(10, 10, 10, 0.8);
  --bg-glass-hover: rgba(20, 20, 20, 0.9);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-tertiary: #666666;
  --accent-primary: #a78bfa;
  --accent-primary-hover: #8b5cf6;
  --accent-glow: rgba(167, 139, 250, 0.3);
}

/* ── Resets & Global ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  background: var(--bg-base);
}

body {
  font-family: var(--font-ui);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* Focus Accessibility */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Layout Framework ── */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main.main-content {
  flex: 1;
  padding-top: 72px; /* Header height */
  padding-bottom: 40px;
}

/* ── Header / Navigation ── */
.header-glass {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 32px;
  z-index: 100;
  transition: background var(--transition-smooth);
}

.brand {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-right: 40px;
  user-select: none;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-item {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  background: transparent;
  border: none;
}

.nav-item:hover, .nav-item[aria-current="page"] {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.nav-spacer { flex: 1; }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.avatar-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow);
}

.avatar-btn::-webkit-details-marker {
  display: none;
}
.avatar-btn {
  list-style: none;
}

/* Dropdown Menu */
.dropdown-menu {
  position: absolute;
  top: 60px;
  right: 0;
  width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-fast);
  z-index: 200;
}

.dropdown-menu.show,
details[open] > .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-base);
  color: var(--text-primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 0;
}

/* ── UI Components ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--accent-glow);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--text-secondary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.input-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-field {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.input-field:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-smooth);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: all var(--transition-smooth);
  position: relative;
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--bg-base);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-primary);
}

/* Tabs */
.tab-list {
  display: flex;
  gap: 8px;
  background: var(--bg-base);
  padding: 6px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-btn[aria-selected="true"] {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ── Hero / Landing ── */
.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 72px);
  text-align: center;
  padding: 40px 20px;
  background: radial-gradient(circle at top center, var(--accent-glow) 0%, transparent 60%);
}

.hero-title {
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 24px;
  background: linear-gradient(180deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 40px;
  font-weight: 400;
}

/* ── Book Grid (Library) ── */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 32px;
}

.section-header {
  margin-bottom: 32px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.book-card {
  display: flex;
  flex-direction: column;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  group: hover;
}

.book-cover-wrap {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
  position: relative;
  margin-bottom: 16px;
}

.book-cover-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  pointer-events: none;
}

.book-card:hover .book-cover-wrap, .book-card:focus-visible .book-cover-wrap {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-smooth);
}

.book-card:hover .book-cover-img {
  transform: scale(1.05);
}

.book-meta-tags {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
}

.tag {
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.1);
}

.book-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 4px;
}

.book-author {
  font-size: 0.9rem;
  color: var(--text-tertiary);
}

/* Reader Navigation */
.reader-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
  margin-top: 40px;
  border-radius: var(--radius-lg);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
  position: sticky;
  bottom: 16px;
  z-index: 100;
  gap: 12px;
}
.reader-nav button {
  flex: 1;
  padding: 12px;
  font-size: 1rem;
}


/* ── Reader Experience ── */
.reader-wrapper {
  max-width: var(--reader-max-width);
  margin: 0 auto;
  padding: 60px 24px 120px;
}

.chapter-header {
  margin-bottom: 60px;
  text-align: center;
}

.chapter-title {
  font-family: var(--font-reading);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.chapter-content {
  font-family: var(--font-reading);
  font-size: 1.25rem; /* Dynamic based on settings */
  line-height: 1.9;
  color: var(--text-primary);
}

.chapter-content p,
.chapter-content p[class],
.chapter-content div[class] > p,
.chapter-content .calibre1 p,
.chapter-content .calibre5,
.chapter-content .calibre9 {
  margin-bottom: 1.6em !important;
  text-indent: 0 !important;
  display: block !important;
}
/* Ensure EPUB divs don't collapse spacing */
.chapter-content div[class] {
  margin-bottom: 0.8em;
}
/* Kill EPUB span styling that might hide text */
.chapter-content span[class] {
  display: inline !important;
}

.chapter-content h1, .chapter-content h2, .chapter-content h3 {
  font-family: var(--font-ui);
  font-weight: 700;
  margin: 2em 0 1em;
  line-height: 1.3;
}

.chapter-content hr {
  border: none;
  text-align: center;
  margin: 3em 0;
}
.chapter-content hr::after {
  content: '***';
  letter-spacing: 0.5em;
  color: var(--text-tertiary);
  font-size: 1.2rem;
}

.reader-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 80px;
  padding-top: 40px;
  border-top: 1px solid var(--border-subtle);
}

/* ── Admin Dashboard ── */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 72px);
  background: var(--bg-base);
}

.admin-sidebar {
  width: 280px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  padding: 32px 20px;
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow-y: auto;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 4px;
}

.admin-nav-item:hover, .admin-nav-item:focus-visible {
  background: var(--bg-base);
  color: var(--text-primary);
}

.admin-nav-item[aria-current="page"] {
  background: var(--accent-glow);
  color: var(--accent-primary);
}

.admin-content {
  flex: 1;
  padding: 40px 48px;
  max-width: 1200px;
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.stat-card.highlight {
  background: linear-gradient(135deg, var(--accent-glow) 0%, transparent 100%);
  border-color: rgba(129, 140, 248, 0.3);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Data Tables */
.data-table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 16px 24px;
  background: var(--bg-base);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.95rem;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-base); }

/* ── Interactive Splitter UI ── */
.splitter-container {
  display: flex;
  gap: 24px;
  height: 600px;
}

.splitter-editor, .splitter-preview {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.splitter-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-base);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.splitter-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ── Settings Panel Details ── */
.settings-group {
  margin-bottom: 24px;
}
.settings-group-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}
.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

/* ── Utilities ── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
.w-full { width: 100%; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-4 { gap: 16px; }

/* ── Footer ── */
.site-footer { background:var(--bg-elevated); border-top:1px solid var(--border-subtle); margin-top:auto; }
.footer-inner { max-width:1200px; margin:0 auto; padding:48px 32px 32px; display:flex; gap:48px; flex-wrap:wrap; }
.footer-brand { flex:1; min-width:200px; }
.footer-logo { font-size:1.5rem; font-weight:800; background:linear-gradient(135deg,var(--accent-primary),var(--accent-secondary)); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
.footer-tagline { margin-top:8px; font-size:0.9rem; color:var(--text-tertiary); line-height:1.6; }
.footer-links { display:flex; gap:40px; flex-wrap:wrap; }
.footer-col { display:flex; flex-direction:column; gap:10px; min-width:120px; }
.footer-col-title { font-size:0.78rem; font-weight:700; text-transform:uppercase; letter-spacing:0.06em; color:var(--text-secondary); margin-bottom:4px; }
.footer-link { background:none; border:none; color:var(--text-tertiary); font-size:0.9rem; cursor:pointer; text-align:left; padding:0; transition:color var(--transition-fast); }
.footer-link:hover { color:var(--accent-primary); }
.footer-link-text { color:var(--text-tertiary); font-size:0.9rem; }
.footer-bottom { border-top:1px solid var(--border-subtle); padding:20px 32px; text-align:center; font-size:0.85rem; color:var(--text-tertiary); }

/* ── Header Search ── */
.header-search { flex:1; max-width:340px; margin:0 16px; }
.search-inner { position:relative; }
.search-icon { position:absolute; left:12px; top:50%; transform:translateY(-50%); font-size:0.9rem; pointer-events:none; opacity:0.6; }
.search-input { width:100%; background:var(--bg-elevated); border:1px solid var(--border-subtle); border-radius:var(--radius-full); padding:8px 16px 8px 36px; color:var(--text-primary); font-family:var(--font-ui); font-size:0.9rem; transition:all var(--transition-fast); }
.search-input:focus { outline:none; border-color:var(--accent-primary); box-shadow:0 0 0 3px var(--accent-glow); }
.search-input::placeholder { color:var(--text-tertiary); }

/* ── Dropdown header ── */
.dropdown-header { padding:10px 12px 4px; font-size:0.8rem; font-weight:600; color:var(--text-tertiary); text-transform:uppercase; letter-spacing:0.05em; }

/* ── Form error ── */
.form-error { color:var(--status-error); font-size:0.9rem; margin-bottom:16px; padding:10px 14px; background:rgba(248,113,113,0.08); border-radius:var(--radius-sm); border:1px solid rgba(248,113,113,0.2); }

/* ── Settings extras ── */
.settings-desc { font-size:0.82rem; color:var(--text-secondary); margin-top:2px; }
.settings-control { display:flex; align-items:center; gap:8px; }
.settings-value { font-variant-numeric:tabular-nums; min-width:36px; text-align:center; font-weight:600; font-size:0.95rem; }
.theme-swatches { display:flex; gap:8px; }
.theme-swatch { width:36px; height:36px; border-radius:var(--radius-full); border:2px solid var(--border-subtle); cursor:pointer; font-size:1rem; display:flex; align-items:center; justify-content:center; transition:all var(--transition-fast); }
.theme-swatch:hover, .theme-swatch.active { border-color:var(--accent-primary); box-shadow:0 0 0 3px var(--accent-glow); }
.color-picker { width:40px; height:36px; padding:2px; border:1px solid var(--border-strong); border-radius:var(--radius-sm); background:var(--bg-base); cursor:pointer; }
.range-input { flex:1; accent-color:var(--accent-primary); cursor:pointer; }
.toggle-switch { position:relative; display:inline-block; width:44px; height:24px; flex-shrink:0; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-track { position:absolute; inset:0; background:var(--border-strong); border-radius:var(--radius-full); cursor:pointer; transition:background var(--transition-fast); }
.toggle-track::after { content:''; position:absolute; width:18px; height:18px; border-radius:50%; background:#fff; top:3px; left:3px; transition:transform var(--transition-fast); }
.toggle-switch input:checked + .toggle-track { background:var(--accent-primary); }
.toggle-switch input:checked + .toggle-track::after { transform:translateX(20px); }

/* ── Skeleton loaders ── */
.skeleton { background:linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-glass-hover) 50%, var(--bg-elevated) 75%); background-size:200% 100%; animation:shimmer 1.5s infinite; border-radius:var(--radius-md); }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.skeleton-card { aspect-ratio:2/3; border-radius:var(--radius-md); }
.skeleton-title { height:18px; width:80%; margin-top:12px; border-radius:var(--radius-sm); }
.skeleton-subtitle { height:14px; width:50%; margin-top:8px; border-radius:var(--radius-sm); }

/* ── Book Detail Modal ── */
.book-modal-content { max-width:680px !important; }
.book-detail { display:flex; gap:32px; }
.book-detail-cover { width:180px; flex-shrink:0; border-radius:var(--radius-md); overflow:hidden; aspect-ratio:2/3; background:var(--bg-base); box-shadow:var(--shadow-lg); }
.book-detail-cover img { width:100%; height:100%; object-fit:cover; }
.book-detail-info { flex:1; }
.book-detail-title { font-size:1.6rem; font-weight:700; line-height:1.2; margin-bottom:6px; }
.book-detail-author { color:var(--text-secondary); margin-bottom:16px; font-size:0.95rem; }
.book-detail-meta { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:20px; }
.badge { padding:4px 12px; border-radius:var(--radius-full); font-size:0.78rem; font-weight:600; background:var(--bg-base); border:1px solid var(--border-subtle); color:var(--text-secondary); }
.badge-accent { background:var(--accent-glow); border-color:rgba(129,140,248,0.3); color:var(--accent-primary); }
.book-detail-desc { font-size:0.95rem; line-height:1.7; color:var(--text-secondary); margin-bottom:24px; max-height:120px; overflow-y:auto; }
.book-detail-actions { display:flex; gap:12px; flex-wrap:wrap; }

/* ── Heart / Save button ── */
.btn-heart { background:none; border:1px solid var(--border-strong); border-radius:var(--radius-full); width:36px; height:36px; display:flex; align-items:center; justify-content:center; cursor:pointer; transition:all var(--transition-fast); font-size:1.1rem; color:var(--text-tertiary); }
.btn-heart:hover, .btn-heart.saved { color:var(--accent-secondary); border-color:var(--accent-secondary); background:rgba(244,114,182,0.1); }
.book-card-actions { position:absolute; bottom:8px; right:8px; display:flex; gap:6px; opacity:0; transition:opacity var(--transition-fast); }
.book-card:hover .book-card-actions, .book-card:focus-within .book-card-actions { opacity:1; }

/* ── Audio Player redesign ── */
.audio-footer { position:fixed; bottom:0; left:0; right:0; background:var(--bg-glass); backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px); border-top:1px solid var(--border-strong); z-index:400; transform:translateY(100%); transition:transform var(--transition-smooth); }
.audio-footer.active { transform:translateY(0); }
.audio-inner { max-width:1200px; margin:0 auto; padding:12px 24px; display:flex; align-items:center; gap:20px; }
.audio-book-info { flex:1; min-width:0; }
.audio-title { font-weight:600; font-size:0.95rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.audio-chapter { font-size:0.8rem; color:var(--text-tertiary); margin-top:2px; }
.audio-controls { display:flex; align-items:center; gap:8px; }
.audio-play-btn { width:44px !important; height:44px !important; }
.audio-progress-wrap { flex:2; display:flex; align-items:center; gap:10px; min-width:0; }
.audio-time { font-size:0.82rem; color:var(--text-tertiary); font-variant-numeric:tabular-nums; white-space:nowrap; }
.audio-bar { flex:1; height:5px; background:var(--bg-elevated); border-radius:var(--radius-full); position:relative; cursor:pointer; }
.audio-bar:hover { height:7px; }
.audio-fill { height:100%; background:var(--accent-primary); border-radius:var(--radius-full); transition:width 0.1s linear; pointer-events:none; }
.audio-extras { display:flex; align-items:center; gap:4px; }
.audio-speed-btn { font-size:0.82rem; font-weight:700; padding:6px 10px !important; }

/* ── Reader toolbar (floating side) ── */
.reader-toolbar { position:fixed; right:24px; top:50%; transform:translateY(-50%); display:flex; flex-direction:column; gap:8px; z-index:50; opacity:0; transition:opacity var(--transition-smooth); pointer-events:none; }
.reader-toolbar.visible { opacity:1; pointer-events:auto; }
.reader-tool-btn { width:40px; height:40px; background:var(--bg-elevated); border:1px solid var(--border-subtle); border-radius:var(--radius-full); display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:1rem; color:var(--text-secondary); transition:all var(--transition-fast); box-shadow:var(--shadow-md); }
.reader-tool-btn:hover { background:var(--accent-glow); border-color:var(--accent-primary); color:var(--accent-primary); }
.reader-tool-btn.active { background:var(--accent-primary); color:#fff; border-color:var(--accent-primary); }

/* ── My Library page ── */
.my-lib-card { display:flex; gap:16px; background:var(--bg-elevated); border:1px solid var(--border-subtle); border-radius:var(--radius-lg); padding:20px; transition:all var(--transition-fast); cursor:pointer; }
.my-lib-card:hover { border-color:var(--accent-primary); transform:translateY(-2px); box-shadow:var(--shadow-md); }
.my-lib-cover { width:60px; height:90px; flex-shrink:0; border-radius:var(--radius-sm); overflow:hidden; background:var(--bg-base); }
.my-lib-cover img { width:100%; height:100%; object-fit:cover; }
.my-lib-info { flex:1; min-width:0; }
.my-lib-title { font-size:1rem; font-weight:600; margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.my-lib-author { font-size:0.85rem; color:var(--text-tertiary); margin-bottom:10px; }
.progress-bar-wrap { background:var(--bg-base); border-radius:var(--radius-full); height:4px; margin-bottom:6px; overflow:hidden; }
.progress-bar-fill { height:100%; background:var(--accent-primary); border-radius:var(--radius-full); transition:width var(--transition-smooth); }
.my-lib-meta { font-size:0.8rem; color:var(--text-tertiary); }

/* ── Spinner / Loading ── */
.spinner { width:24px; height:24px; border:3px solid var(--border-subtle); border-top-color:var(--accent-primary); border-radius:50%; animation:spin 0.8s linear infinite; margin:0 auto 16px; }
@keyframes spin { to { transform:rotate(360deg); } }
.loading-state { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:60px 20px; color:var(--text-secondary); }

/* ── Responsive ── */
@media (max-width:768px) {
  .header-glass { padding:0 16px; }
  .header-search { display:none; }
  .page-container { padding:24px 16px; }
  .book-grid { grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:20px; }
  .admin-layout { flex-direction:column; }
  .admin-sidebar { width:100%; height:auto; position:static; }
  .footer-inner { flex-direction:column; gap:32px; }
  .book-detail { flex-direction:column; }
  .book-detail-cover { width:120px; }
  .reader-toolbar { right:12px; }
  .audio-inner { padding:10px 16px; gap:12px; }
  .audio-book-info { display:none; }
}
@media (max-width:480px) {
  .book-grid { grid-template-columns:repeat(2,1fr); gap:14px; }
  .brand { font-size:1.2rem; margin-right:16px; }
}


/* ── Button Small Variant ── */
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

/* ── Admin Nav Active State ── */
.admin-nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-primary);
  font-weight: 600;
}
.admin-nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}
.admin-nav-item.active svg, .admin-nav-item:hover svg {
  opacity: 1;
}

/* ── Book Landing Page ── */
.book-landing { max-width: 1000px; margin: 0 auto; padding: 40px 32px; }
.book-landing-hero { display: flex; gap: 40px; margin-bottom: 48px; }
.book-landing-cover { width: 240px; flex-shrink: 0; aspect-ratio: 2/3; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); background: var(--bg-elevated); }
.book-landing-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-landing-info { flex: 1; }
.book-landing-title { font-size: 2.2rem; font-weight: 800; line-height: 1.2; margin-bottom: 8px; letter-spacing: -0.02em; }
.book-landing-author { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 12px; }
.book-landing-desc { font-size: 1rem; line-height: 1.8; color: var(--text-secondary); margin-bottom: 24px; max-height: 200px; overflow-y: auto; }
.book-landing-actions { display: flex; gap: 16px; align-items: center; }
.book-landing-toc { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 32px; }

/* TOC List */
.toc-list { display: flex; flex-direction: column; }
.toc-item { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); text-decoration: none; transition: all var(--transition-fast); border-radius: 0; }
.toc-item:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.toc-item:last-child { border-bottom: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.toc-item:hover { background: var(--bg-base); color: var(--text-primary); }
.toc-item.toc-current { background: var(--accent-glow); color: var(--accent-primary); font-weight: 600; }
.toc-num { font-size: 0.82rem; font-weight: 700; color: var(--text-tertiary); min-width: 60px; }
.toc-title { flex: 1; font-size: 0.95rem; }
.toc-words { font-size: 0.78rem; color: var(--text-tertiary); white-space: nowrap; }

@media (max-width: 768px) {
  .book-landing-hero { flex-direction: column; align-items: center; text-align: center; }
  .book-landing-cover { width: 180px; }
  .book-landing-actions { justify-content: center; }
}
