@charset "utf-8";

/* ==========================================================================
   OFFLINE TYPOGRAPHY DEFINITIONS
   ========================================================================== */
@font-face {
  font-family: 'Literata';
  src: url('fonts/literata-2.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('fonts/lora-3.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('fonts/lora-4.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Garamond';
  src: url('fonts/eb-garamond-0.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-1.woff2') format('woff2');
  font-weight: 400 600 700;
  font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('fonts/newsreader-5.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
}

/* ==========================================================================
   GLOBAL UTILITIES
   ========================================================================== */
[hidden] {
  display: none !important;
}

/* ==========================================================================
   COLOR THEMES
   ========================================================================== */
:root {
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-reading: 'Literata', Georgia, serif;
  --reading-size: 18px;
  --reading-leading: 1.8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="paper"] {
  --bg-page: #F8F6F0;
  --bg-surface: #FFFFFF;
  --bg-soft: #EFECE3;
  --bg-sidebar: #F2EFE7;
  --border-color: #E2DDD2;
  --text-main: #212529;
  --text-muted: #6C757D;
  --accent: #2E5A3D;
  --accent-hover: #22432D;
  --accent-light: #E5EFE8;
  --card-shadow: 0 4px 14px rgba(0,0,0,0.06);
  --pdf-filter: none;
}

html[data-theme="sepia"] {
  --bg-page: #F4ECD8;
  --bg-surface: #FCF7EB;
  --bg-soft: #E8DDBC;
  --bg-sidebar: #EDE3C9;
  --border-color: #DDD0AC;
  --text-main: #3B2E1E;
  --text-muted: #7E6C54;
  --accent: #78522A;
  --accent-hover: #5F3F1D;
  --accent-light: #F0E2C8;
  --card-shadow: 0 4px 14px rgba(60,40,10,0.07);
  --pdf-filter: sepia(0.6) brightness(0.95);
}

html[data-theme="night"] {
  --bg-page: #1D2125;
  --bg-surface: #242A2F;
  --bg-soft: #2D343A;
  --bg-sidebar: #171A1E;
  --border-color: #333B42;
  --text-main: #E3E8EC;
  --text-muted: #95A1AC;
  --accent: #7FA88B;
  --accent-hover: #97C0A3;
  --accent-light: #253329;
  --card-shadow: 0 4px 16px rgba(0,0,0,0.35);
  --pdf-filter: invert(0.88) hue-rotate(180deg) brightness(0.88);
}

html[data-theme="oled"] {
  --bg-page: #000000;
  --bg-surface: #111111;
  --bg-soft: #1E1E1E;
  --bg-sidebar: #0A0A0A;
  --border-color: #242424;
  --text-main: #ECECEC;
  --text-muted: #888888;
  --accent: #92BA9E;
  --accent-hover: #A9D1B5;
  --accent-light: #162419;
  --card-shadow: 0 4px 18px rgba(0,0,0,0.6);
  --pdf-filter: invert(1) hue-rotate(180deg) contrast(1.1);
}

html[data-theme="velvet"] {
  --bg-page: #251B23;
  --bg-surface: #30242E;
  --bg-soft: #3D2E3A;
  --bg-sidebar: #1E151C;
  --border-color: #483745;
  --text-main: #EFE4EB;
  --text-muted: #BBA6B5;
  --accent: #D48FA8;
  --accent-hover: #E3A7BD;
  --accent-light: #3D2633;
  --card-shadow: 0 4px 18px rgba(0,0,0,0.4);
  --pdf-filter: invert(0.88) hue-rotate(290deg);
}

/* ==========================================================================
   GLOBAL RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

/* ==========================================================================
   APP LAYOUT (SIDEBAR & MAIN VIEW)
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: 100dvh;
  width: 100vw;
  background: var(--bg-page);
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 16px;
  padding-top: calc(16px + var(--safe-top));
  padding-bottom: calc(16px + var(--safe-bottom));
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

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

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.brand-sub {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.close-sidebar {
  display: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-group-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin: 18px 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-muted);
  transition: all 0.15s;
}

.nav-link svg {
  width: 18px;
  height: 18px;
}

.nav-link:hover {
  background: var(--bg-soft);
  color: var(--text-main);
}

.nav-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-link .badge {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text-muted);
}

.nav-link.active .badge {
  background: var(--accent);
  color: #FFFFFF;
}

.format-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.format-dot.pdf { background: #D9383A; }
.format-dot.epub { background: #2B78C5; }
.format-dot.txt { background: #7C5CB7; }

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.storage-info {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 10px;
}

.storage-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.storage-progress {
  height: 6px;
  background: var(--bg-soft);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.storage-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.storage-stats {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}

.sidebar-btn:hover {
  background: var(--bg-soft);
  color: var(--text-main);
}

.sidebar-btn svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   MAIN CONTENT & TOPBAR
   ========================================================================== */
.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: 70px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  padding-top: calc(16px + var(--safe-top));
  background: var(--bg-page);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.menu-btn {
  display: none;
}

.view-header-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.view-header-title h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.count-indicator {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  transition: background 0.15s;
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.icon-button:hover {
  background: var(--bg-soft);
}

.primary-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #FFFFFF;
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: all 0.15s;
}

.primary-add-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.primary-add-btn svg {
  width: 16px;
  height: 16px;
}

/* Toolbar */
.toolbar {
  padding: 0 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-container {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0 12px;
  height: 42px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  margin-right: 10px;
  flex-shrink: 0;
}

.search-container input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
}

.search-clear {
  font-size: 20px;
  color: var(--text-muted);
  padding: 0 4px;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.filter-pills::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 550;
  background: var(--bg-soft);
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.15s;
}

.filter-pill:hover {
  color: var(--text-main);
}

.filter-pill.active {
  background: var(--text-main);
  color: var(--bg-page);
}

/* ==========================================================================
   BOOKS GRID & LIST VIEW
   ========================================================================== */
.library-body {
  padding: 8px 24px 32px;
  flex: 1;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
}

.books-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Book Card */
.book-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--card-shadow);
  transition: transform 0.18s, box-shadow 0.18s;
  position: relative;
  cursor: pointer;
}

.book-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.1);
}

.book-cover {
  height: 210px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 16px;
  text-align: center;
  overflow: hidden;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.jacket-decor {
  width: 64px;
  height: 80px;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.jacket-decor svg {
  width: 32px;
  height: 32px;
  opacity: 0.5;
}

.jacket-title {
  font-family: var(--font-reading);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.jacket-author {
  font-size: 11px;
  color: var(--text-muted);
}

.format-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 6px;
  border-radius: 5px;
  color: #FFFFFF;
  text-transform: uppercase;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.format-badge.pdf { background: #D9383A; }
.format-badge.epub { background: #2B78C5; }
.format-badge.txt { background: #7C5CB7; }

.fav-badge-icon {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.45);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFD166;
}
.fav-badge-icon svg { width: 12px; height: 12px; fill: #FFD166; }

.book-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.book-title {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-author {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 10px;
}

.book-progress-box {
  margin-top: auto;
}

.book-progress-bar {
  height: 4px;
  background: var(--bg-soft);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.book-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.book-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* List View variant */
.books-grid.list-view .book-card {
  flex-direction: row;
  height: 80px;
}

.books-grid.list-view .book-cover {
  width: 60px;
  height: 100%;
  flex-shrink: 0;
  padding: 6px;
}
.books-grid.list-view .jacket-decor { display: none; }
.books-grid.list-view .jacket-title { display: none; }
.books-grid.list-view .jacket-author { display: none; }

.books-grid.list-view .book-info {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.books-grid.list-view .book-title-col {
  display: flex;
  flex-direction: column;
  max-width: 60%;
}

.books-grid.list-view .book-progress-box {
  width: 160px;
  margin-top: 0;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.empty-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-icon-wrap svg {
  width: 36px;
  height: 36px;
}

.empty-state h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  margin-bottom: 24px;
}

.empty-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.primary-button, .secondary-button, .danger-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.primary-button {
  background: var(--accent);
  color: #FFFFFF;
}
.primary-button:hover { background: var(--accent-hover); }

.secondary-button {
  background: var(--bg-soft);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.secondary-button:hover { background: var(--bg-surface); }

.danger-btn {
  background: #FEE2E2;
  color: #DC2626;
}
.danger-btn:hover { background: #FECACA; }

/* Mobile Dock */
.mobile-dock {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  z-index: 40;
  justify-content: space-around;
  align-items: center;
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 550;
  color: var(--text-muted);
  padding: 6px 12px;
}

.dock-item svg {
  width: 20px;
  height: 20px;
}

.dock-item.active {
  color: var(--accent);
}

/* ==========================================================================
   FULLSCREEN IN-BOOK READER
   ========================================================================== */
.reader-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-page);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.reader-topbar {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + var(--safe-top));
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  z-index: 20;
}

.reader-bottombar {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
  z-index: 20;
}

.reader-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.progress-slider {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.mini-btn {
  width: 32px;
  height: 32px;
}

.reader-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reader-page-stats {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 550;
}

.reader-controls-tools {
  display: flex;
  gap: 8px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 550;
  background: var(--bg-soft);
  color: var(--text-main);
}

.tool-icon {
  font-weight: 700;
  font-size: 13px;
}

.theme-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
}
.current-theme-dot {
  background: var(--accent);
}

/* Reader Viewport */
.reader-viewport {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  padding: 16px 20px;
}

.tap-zone {
  position: absolute;
  top: 60px;
  bottom: 90px;
  z-index: 10;
}
.tap-left { left: 0; width: 25%; }
.tap-center { left: 25%; right: 25%; }
.tap-right { right: 0; width: 25%; }

/* PDF Viewport */
.pdf-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#pdfCanvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  filter: var(--pdf-filter);
  transition: filter 0.2s;
}

/* Text Viewport */
.text-container {
  max-width: 680px;
  width: 100%;
  padding: 24px 20px;
}

.text-body {
  font-family: var(--font-reading);
  font-size: var(--reading-size);
  line-height: var(--reading-leading);
  color: var(--text-main);
  user-select: text;
  -webkit-user-select: text;
}

.text-body p {
  margin-bottom: 1.4em;
  text-align: justify;
  text-justify: inter-word;
}

.text-body h1, .text-body h2, .text-body h3 {
  margin: 1.5em 0 0.8em;
  font-family: var(--font-ui);
  line-height: 1.25;
}

/* TOC Drawer */
.toc-drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 320px;
  max-width: 85%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  z-index: 120;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.toc-tabs {
  display: flex;
  gap: 8px;
}

.toc-tab {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.toc-tab.active {
  background: var(--bg-soft);
  color: var(--text-main);
}

.toc-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
  color: var(--text-main);
  transition: background 0.15s;
}
.toc-item:hover {
  background: var(--bg-soft);
}
.toc-item.active {
  color: var(--accent);
  font-weight: 600;
}

/* ==========================================================================
   MODALS & DIALOGS
   ========================================================================== */
dialog {
  border: none;
  background: transparent;
  padding: 0;
  margin: auto;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.settings-sheet, .sheet-modal {
  width: 440px;
  max-width: 90vw;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  overflow: hidden;
  color: var(--text-main);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.sheet-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.sheet-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pref-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.theme-selector {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.theme-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
}

.swatch {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-reading);
  font-size: 14px;
  border: 2px solid transparent;
}
.swatch.paper { background: #F8F6F0; color: #212529; border-color: #E2DDD2; }
.swatch.sepia { background: #F4ECD8; color: #3B2E1E; border-color: #DDD0AC; }
.swatch.night { background: #1D2125; color: #E3E8EC; border-color: #333B42; }
.swatch.oled { background: #000000; color: #ECECEC; border-color: #333333; }
.swatch.velvet { background: #251B23; color: #EFE4EB; border-color: #483745; }

.theme-choice.active .swatch {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
}
.slider-row input {
  flex: 1;
  accent-color: var(--accent);
}
.slider-val {
  min-width: 40px;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
}

.font-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.font-choice {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 550;
  text-align: left;
}
.font-choice.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.sheet-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-soft);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1F2937;
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 550;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 200;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Spinner */
.reader-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   MOBILE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .close-sidebar {
    display: flex;
  }
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 45;
  }

  .main-content {
    margin-left: 0;
    padding-bottom: calc(64px + var(--safe-bottom));
  }

  .menu-btn {
    display: flex;
  }

  .topbar {
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-top));
  }

  .view-header-title h1 {
    font-size: 19px;
  }

  .toolbar {
    padding: 0 16px 12px;
  }

  .library-body {
    padding: 4px 16px 24px;
  }

  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
  }

  .book-cover {
    height: 175px;
    padding: 12px;
  }

  .mobile-dock {
    display: flex;
  }
}
