/* ==========================================================================
   CapbairPlus E-Library - Modern Dark Design System
   Matches Obsidian WorkflowUiCsharpPoc standards:
   - Fixed Deep Midnight Slate (#020617)
   - Warm Amber Gold (#e0a458)
   - 3D Procedural Hardcover Book Jackets & Spines
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=DM+Sans:wght@400;500;600;700&family=Noto+Serif+TC:wght@600;700&display=swap');

:root {
  --bg: #020617;
  --bg-soft: #070d1e;
  --panel: #0a0f1f;
  --panel-2: #0e1526;
  --panel-3: #131c31;
  --panel-hover: #16223b;
  --border: #1e2740;
  --border-strong: #2c3654;
  --text: #eef1fa;
  --text-dim: #8792ab;
  --text-muted: #5e6982;

  --accent: #e0a458;
  --accent-dim: #b9823f;
  --accent-tint: #f0c98a;
  --accent-glow: rgba(224, 164, 88, 0.22);

  --format-epub: #10b981;
  --format-epub-bg: rgba(16, 185, 129, 0.12);
  --format-pdf: #f43f5e;
  --format-pdf-bg: rgba(244, 63, 94, 0.12);
  --format-mobi: #38bdf8;
  --format-mobi-bg: rgba(56, 189, 248, 0.12);

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;

  --font-head: 'Space Grotesk', 'DM Sans', -apple-system, 'Noto Sans TC', sans-serif;
  --font-body: 'DM Sans', -apple-system, 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  --font-serif: 'Noto Serif TC', 'Songti TC', Georgia, serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Ambient lighting background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: 
    radial-gradient(ellipse 65% 50% at 50% -10%, rgba(224, 164, 88, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 85% 20%, rgba(56, 189, 248, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 15% 60%, rgba(16, 185, 129, 0.04) 0%, transparent 60%);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ==========================================================================
   Global Header & Navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 19px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand-logo svg {
  color: var(--accent);
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px 2px var(--accent-glow);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a,
.nav-links button,
.nav-links summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active,
.nav-links summary:hover,
.nav-links summary.active {
  color: var(--text);
  background: var(--panel-2);
}

.nav-links a.active,
.nav-links summary.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown details {
  position: relative;
}

.nav-dropdown summary {
  list-style: none;
}

.nav-dropdown summary::-webkit-details-marker {
  display: none;
}

.nav-dropdown details[open] summary svg {
  transform: rotate(180deg);
}

.nav-dropdown summary svg {
  transition: transform 0.18s ease;
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 120;
  min-width: 172px;
  padding: 7px;
  background: #0a1020;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
}

.nav-dropdown-menu-right {
  right: 0;
  left: auto;
}

.nav-dropdown-menu a {
  width: 100%;
  padding: 9px 11px;
  border-bottom: 0;
}

.nav-dropdown-menu a.active {
  border-bottom: 0;
  background: var(--panel-3);
}

.header-search {
  flex: 1;
  max-width: 320px;
  min-width: 180px;
  position: relative;
}

body.is-reader-mode .desktop-nav,
body.is-reader-mode .header-search {
  display: none;
}

.header-search input {
  width: 100%;
  padding: 9px 16px 9px 38px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 30px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: all 0.25s ease;
}

.header-search input:focus {
  border-color: var(--accent);
  background: var(--panel-2);
  box-shadow: 0 0 14px var(--accent-glow);
}

.header-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

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

.user-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-dim);
}

.user-tag .avatar-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */
.btn-prime {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--accent);
  color: #020617;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(224, 164, 88, 0.3);
  transition: all 0.2s ease;
}

.btn-prime:hover {
  background: var(--accent-tint);
  color: #020617;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(224, 164, 88, 0.45);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 20px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--panel-3);
  border-color: var(--border-strong);
  color: #fff;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* ==========================================================================
   Homepage Hero Showcase
   ========================================================================== */
.hero-showcase {
  position: relative;
  background: linear-gradient(135deg, rgba(14, 21, 38, 0.8) 0%, rgba(10, 15, 31, 0.6) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  margin-bottom: 40px;
  overflow: hidden;
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.5);
}

.hero-showcase::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 40px;
  align-items: center;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(224, 164, 88, 0.12);
  border: 1px solid rgba(224, 164, 88, 0.28);
  border-radius: 20px;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.hero-title {
  font-family: var(--font-head);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 14px;
  color: #fff;
  letter-spacing: -0.02em;
}

.hero-desc {
  font-size: 15px;
  color: var(--text-dim);
  margin: 0 0 28px;
  line-height: 1.7;
  max-width: 580px;
}

.hero-stats {
  display: flex;
  gap: 32px;
  margin-bottom: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-spotlight {
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
}

.spotlight-card {
  width: 220px;
  aspect-ratio: 2 / 3;
  transform: rotateY(-12deg) rotateX(4deg);
  transition: transform 0.4s ease;
  box-shadow: 
    -12px 20px 40px rgba(0, 0, 0, 0.7),
    0 0 25px var(--accent-glow);
  border-radius: 4px;
}

.spotlight-card:hover {
  transform: rotateY(-4deg) rotateX(2deg) translateY(-8px);
}

/* ==========================================================================
   Category Quick Pills Bar
   ========================================================================== */
.category-bar-wrap {
  margin-bottom: 36px;
}

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

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  letter-spacing: -0.01em;
}

.category-pills {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 30px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.cat-pill:hover,
.cat-pill.active {
  background: var(--panel-3);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.cat-pill.active {
  background: rgba(224, 164, 88, 0.15);
  color: var(--accent);
}

.cat-count {
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.cat-pill.active .cat-count {
  background: rgba(224, 164, 88, 0.25);
  color: var(--accent);
}

/* ==========================================================================
   3D Book Cards Grid & Book Jackets
   ========================================================================== */
.book-shelf-section {
  margin-bottom: 48px;
}

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

.book-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: all 0.25s ease;
  position: relative;
}

.book-card:hover {
  background: var(--panel-2);
  border-color: var(--border-strong);
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.5);
  transform: translateY(-4px);
}

.book-cover-container {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  margin-bottom: 12px;
  perspective: 600px;
}

.book-cover-link {
  display: block;
  width: 100%;
  height: 100%;
}

.book-cover-3d {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 
    -4px 6px 16px rgba(0, 0, 0, 0.5),
    0 1px 3px rgba(255, 255, 255, 0.08);
  transition: all 0.25s ease;
}

.book-card:hover .book-cover-3d {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 
    -6px 12px 24px rgba(0, 0, 0, 0.65),
    0 0 15px var(--accent-glow);
}

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

/* 3D Book spine crease shadow */
.book-spine-crease {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 14px;
  background: linear-gradient(90deg, 
    rgba(0,0,0,0.5) 0%, 
    rgba(255,255,255,0.12) 20%, 
    rgba(0,0,0,0.3) 50%, 
    transparent 100%);
  pointer-events: none;
  z-index: 2;
}

.book-page-edge {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(90deg, 
    rgba(0,0,0,0.3) 0%, 
    rgba(240, 235, 220, 0.7) 100%);
  pointer-events: none;
  z-index: 2;
}

/* ==========================================================================
   Procedural 3D Hardcover Jackets (For 99.8% of books without covers)
   ========================================================================== */
.hardcover-jacket {
  width: 100%;
  height: 100%;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

/* Theme Palettes */
.theme-0 { background: linear-gradient(145deg, #441822 0%, #1c080e 100%); border-left: 3px solid #6b2636; }
.theme-1 { background: linear-gradient(145deg, #0e2440 0%, #06111f 100%); border-left: 3px solid #1a3c69; }
.theme-2 { background: linear-gradient(145deg, #0c3422 0%, #05160e 100%); border-left: 3px solid #165638; }
.theme-3 { background: linear-gradient(145deg, #3d240e 0%, #1a0f05 100%); border-left: 3px solid #6b3f18; }
.theme-4 { background: linear-gradient(145deg, #181c28 0%, #0a0c12 100%); border-left: 3px solid #2d3448; }
.theme-5 { background: linear-gradient(145deg, #2f163b 0%, #140819 100%); border-left: 3px solid #542769; }
.theme-6 { background: linear-gradient(145deg, #3c1912 0%, #1a0a07 100%); border-left: 3px solid #662a1e; }
.theme-7 { background: linear-gradient(145deg, #0d2e33 0%, #051417 100%); border-left: 3px solid #174e57; }

.jacket-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(240, 201, 138, 0.22);
  border-radius: 2px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.4);
}

.jacket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(240, 201, 138, 0.18);
  padding-bottom: 6px;
}

.jacket-icon {
  font-size: 14px;
}

.jacket-cat {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent-tint);
  letter-spacing: 0.05em;
}

.jacket-body {
  text-align: center;
  padding: 10px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.jacket-title {
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.35;
  letter-spacing: 0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.jacket-ornament {
  font-size: 9px;
  color: var(--accent);
  opacity: 0.65;
  margin-top: 8px;
  letter-spacing: 3px;
}

.jacket-footer {
  border-top: 1px solid rgba(240, 201, 138, 0.18);
  padding-top: 6px;
  text-align: center;
}

.jacket-author {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Quick action overlay */
.book-quick-actions {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  border-radius: 4px;
  transition: opacity 0.2s ease;
  z-index: 5;
}

.book-card:hover .book-quick-actions {
  opacity: 1;
  pointer-events: auto;
}

.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  width: 105px;
  justify-content: center;
  transition: transform 0.15s ease;
}

.quick-btn.read-btn {
  background: var(--accent);
  color: #020617;
}

.quick-btn.read-btn:hover {
  background: var(--accent-tint);
  transform: scale(1.05);
}

.quick-btn.detail-btn {
  background: var(--panel-3);
  color: #fff;
  border: 1px solid var(--border-strong);
}

.quick-btn.detail-btn:hover {
  background: var(--panel-hover);
  transform: scale(1.05);
}

.quick-btn.download-btn {
  background: rgba(20, 184, 166, 0.92);
  color: #fff;
}

.quick-btn.download-btn:hover {
  background: #14b8a6;
  color: #fff;
}

/* Book info text below cover */
.book-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.book-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.book-category-tag {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-format-tags {
  display: flex;
  gap: 4px;
}

.format-pill {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.format-epub { background: var(--format-epub-bg); color: var(--format-epub); border: 1px solid rgba(16, 185, 129, 0.3); }
.format-pdf { background: var(--format-pdf-bg); color: var(--format-pdf); border: 1px solid rgba(244, 63, 94, 0.3); }
.format-mobi { background: var(--format-mobi-bg); color: var(--format-mobi); border: 1px solid rgba(56, 189, 248, 0.3); }

.book-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-title a:hover {
  color: var(--accent);
}

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

/* ==========================================================================
   Catalog Page & Filter Search Panel
   ========================================================================== */
.catalog-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.catalog-title {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.catalog-filter-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.catalog-filter-card input,
.catalog-filter-card select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 14px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s ease;
}

.catalog-filter-card input:focus,
.catalog-filter-card select:focus {
  border-color: var(--accent);
}

.catalog-search-input {
  flex: 2;
  min-width: 220px;
}

.catalog-cat-select {
  flex: 1;
  min-width: 180px;
}

/* ==========================================================================
   Magazine Library
   ========================================================================== */
.magazine-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.magazine-content-page {
  width: min(100%, 1100px);
  margin-inline: auto;
  padding: clamp(18px, 3vw, 32px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.folder-link-label {
  cursor: default;
}

.magazine-sidebar {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 108px);
  overflow: hidden;
  background: rgba(10, 15, 31, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.magazine-left-rail {
  display: grid;
  grid-template-rows: minmax(150px, 1fr) minmax(0, 2fr);
  gap: 14px;
}

.magazine-left-rail .reading-list-panel,
.magazine-left-rail .folder-panel {
  min-height: 0;
  overflow: auto;
}

.magazine-left-rail .reading-list-panel {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.side-panel-head {
  margin-bottom: 14px;
}

.side-kicker,
.eyebrow {
  display: block;
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-panel-head h2 {
  margin: 0;
  color: #fff;
  font-family: var(--font-head);
  font-size: 18px;
}

.muted {
  color: var(--text-dim);
}

.folder-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folder-tree-row {
  display: flex;
  align-items: center;
  min-width: 0;
}

.folder-tree-row[hidden] {
  display: none;
}

.folder-tree-row.depth-1 { padding-left: 12px; }
.folder-tree-row.depth-2 { padding-left: 24px; }
.folder-tree-row.depth-3 { padding-left: 36px; }
.folder-tree-row.depth-4 { padding-left: 48px; }
.folder-tree-row.depth-5 { padding-left: 60px; }

.folder-tree-toggle,
.folder-tree-spacer {
  flex: 0 0 24px;
  width: 24px;
  height: 28px;
}

.folder-tree-toggle {
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  border-radius: 4px;
  font: 700 17px/1 var(--font-body);
  cursor: pointer;
}

.folder-tree-toggle:hover {
  background: var(--panel-3);
}

.folder-tree-row .folder-link {
  flex: 1;
  min-width: 0;
}

.folder-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
}

.folder-link span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-link strong {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 11px;
}

.folder-link:hover,
.folder-link.active {
  background: var(--panel-3);
  color: var(--text);
}

.folder-link.active {
  box-shadow: inset 3px 0 0 var(--accent);
}


.magazine-main {
  min-width: 0;
}

.magazine-head {
  margin-bottom: 16px;
}

.magazine-filter {
  margin-bottom: 16px;
}

.magazine-selection-form {
  min-width: 0;
}

.magazine-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
}

.magazine-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.add-reading-list-btn {
  display: none;
}

.magazine-shell.is-selecting-reading-list .add-reading-list-btn {
  display: inline-flex;
}

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

.magazine-card {
  position: relative;
}

.magazine-card .book-card {
  height: 100%;
}

.magazine-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 12;
  display: none;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.86);
  border: 1px solid var(--border-strong);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.magazine-shell.is-selecting-reading-list .magazine-check {
  display: inline-flex;
}

.magazine-check input {
  accent-color: var(--accent);
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.queue-item a {
  min-width: 0;
}

.queue-item span,
.queue-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-item span {
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}

.queue-item small {
  color: var(--text-muted);
  font-size: 11px;
}

.queue-item form {
  margin: 0;
}

.queue-item button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.queue-item button:hover {
  color: #fff;
  border-color: var(--accent);
}

/* Pagination bar */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.page-btn-group {
  display: flex;
  gap: 6px;
}

.page-btn {
  padding: 6px 14px;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: all 0.2s ease;
}

.page-btn:hover:not(.disabled) {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.page-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ==========================================================================
   Book Details Page
   ========================================================================== */
.book-detail-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 48px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  margin-top: 20px;
  box-shadow: 0 18px 45px -12px rgba(0, 0, 0, 0.6);
}

.detail-cover-box {
  width: 100%;
  aspect-ratio: 2 / 3;
}

.detail-cover-box .book-cover-3d {
  box-shadow: 
    -8px 16px 36px rgba(0, 0, 0, 0.7),
    0 0 25px var(--accent-glow);
}

.detail-info-box {
  display: flex;
  flex-direction: column;
}

.detail-cat-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.detail-title {
  font-family: var(--font-head);
  font-size: clamp(24px, 3.2vw, 36px);
  font-weight: 700;
  color: #fff;
  margin: 0 0 10px;
  line-height: 1.25;
}

.detail-author {
  font-size: 16px;
  color: var(--text-dim);
  margin: 0 0 24px;
}

.detail-desc-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
  font-size: 14.5px;
  color: var(--text-dim);
  line-height: 1.7;
}

.detail-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: auto;
}

/* ==========================================================================
   Reader Room
   ========================================================================== */
.reader-shell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.7);
  margin-top: 10px;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  gap: 20px;
  flex-wrap: wrap;
}

.reader-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.reader-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel-3);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.reader-back-btn:hover {
  background: var(--panel-hover);
  color: #fff;
  border-color: var(--border-strong);
}

.reader-info {
  min-width: 0;
}

.reader-cat {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  display: block;
}

.reader-book-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 500px;
}

.reader-author {
  font-size: 12px;
  color: var(--text-dim);
  display: block;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.reader-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
}

.reader-pill-btn:hover {
  background: var(--panel-hover);
  color: #fff;
  border-color: var(--border-strong);
}

.reader-pill-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent-tint);
}

.reader-pill-btn.fav-btn {
  color: var(--accent);
}

.reader-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
  gap: 16px;
  flex-wrap: wrap;
}

.reader-progress-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
}

.reader-progress-info strong {
  color: var(--accent);
}

.pdf-progress-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdf-progress-ctrl input {
  width: 70px;
  padding: 4px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #fff;
  text-align: center;
  font-size: 13px;
}

.image-reader-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}

.image-reader-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 18px;
  padding: 24px;
  background: #090e1a;
  min-height: calc(100dvh - 210px);
  cursor: pointer;
  overflow: auto;
  user-select: none;
}

.image-reader-page img {
  max-width: 100%;
  max-height: calc(100dvh - 250px);
  object-fit: contain;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  border-radius: 4px;
}

.image-reader-page.double-page img {
  max-width: calc(50% - 9px);
}

.image-reader-page:fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 12px;
  background: #05070d;
  overflow: auto;
}

.image-reader-page:fullscreen img {
  max-height: calc(100vh - 24px);
}

.reader-frame:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #05070d;
}

.epub-controls {
  display: contents;
}

.desktop-epub-nav {
  position: fixed;
  top: 50%;
  z-index: 1800;
  width: 52px;
  height: 82px;
  padding: 0;
  color: #fff;
  font: 500 46px/1 var(--font-body);
  background: rgba(4, 8, 18, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
  transform: translateY(-50%);
}

.desktop-epub-prev { left: 12px; }
.desktop-epub-next { right: 12px; }

.epub-scroll-mode .desktop-epub-nav {
  display: none;
}

#epub-status[hidden] {
  display: none !important;
}

.reader-frame {
  width: 100%;
  height: calc(100dvh - 190px);
  min-height: 680px;
  border: none;
  background: #0f1422;
}

.reader-frame:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.mobile-pdf-reader,
.mobile-reader-controls,
.tablet-reader-controls {
  display: none;
}

.reader-immersive-back {
  display: none;
}

body.is-reader-mode .site-header,
body.is-reader-mode .mobile-bottom-bar {
  display: none;
}

body.is-reader-mode .app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.pdf-reader-shell {
  width: 100%;
  height: 100dvh;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.pdf-reader-shell .reader-toolbar {
  height: 58px;
  padding: 6px 12px;
}

.pdf-reader-shell .reader-subbar {
  display: none;
}

.reader-logout-form {
  display: inline-flex;
  margin: 0;
}

.desktop-pdf-reader {
  position: relative;
  display: flex;
  height: calc(100dvh - 58px);
  min-height: 0;
  background: #05070d;
}

.desktop-pdf-reader > .mobile-reader-status {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  padding: 12px 18px;
  color: #fff;
  background: rgba(15, 20, 34, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  transform: translate(-50%, -50%);
}

.desktop-pdf-reader.is-loading .desktop-pdf-pages,
.desktop-pdf-reader.is-loading .desktop-pdf-nav,
.desktop-pdf-reader.is-loading .desktop-pdf-progress {
  visibility: hidden;
}

.desktop-pdf-stage {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  outline: none;
}

.desktop-pdf-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: calc(100% - 140px);
  height: 100%;
}

.desktop-pdf-pages canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
}

.desktop-pdf-pages canvas[hidden] {
  display: none !important;
}

.desktop-pdf-nav {
  position: absolute;
  top: 50%;
  z-index: 4;
  width: 52px;
  height: 82px;
  padding: 0;
  color: #fff;
  font-size: 46px;
  background: rgba(4, 8, 18, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  transform: translateY(-50%);
}

.desktop-pdf-prev { left: 12px; }
.desktop-pdf-next { right: 12px; }
.desktop-pdf-nav:disabled { opacity: 0.28; }

.desktop-pdf-progress {
  position: absolute;
  bottom: 10px;
  left: 50%;
  z-index: 4;
  padding: 7px 13px;
  color: #fff;
  background: rgba(4, 8, 18, 0.82);
  border-radius: 999px;
  transform: translateX(-50%);
}

.desktop-scroll-pages {
  display: none;
}

.mobile-scroll-pages {
  display: none;
}

.pdf-reader-shell.desktop-scroll-mode .desktop-pdf-stage {
  display: block;
  overflow: auto;
}

.pdf-reader-shell.desktop-scroll-mode .desktop-pdf-pages,
.pdf-reader-shell.desktop-scroll-mode .desktop-pdf-nav,
.pdf-reader-shell.desktop-scroll-mode .desktop-pdf-progress {
  display: none;
}

.pdf-reader-shell.desktop-scroll-mode .desktop-scroll-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 12px;
}

.desktop-scroll-page {
  display: flex;
  width: 100%;
  align-items: flex-start;
  justify-content: center;
}

.desktop-scroll-pages canvas {
  display: block;
  max-width: none;
  height: auto;
  background: #fff;
}

.desktop-scroll-pages canvas[hidden] {
  display: none !important;
}

body.reader-immersive-active .site-header,
body.reader-immersive-active .site-footer,
body.reader-immersive-active .mobile-bottom-bar {
  display: none !important;
}

body.reader-immersive-active .app-shell {
  width: 100vw !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.mobile-reader-controls button {
  font: 700 12px/1 var(--font-body);
}

.epub-viewer {
  width: 100%;
  height: calc(100dvh - 190px);
  min-height: 680px;
  background: #f7f3e8;
  color: #1f2933;
  overflow: hidden;
  cursor: auto;
  outline: none;
}

.epub-viewer.scroll-mode {
  overflow: auto;
}

.epub-viewer.page-mode {
  overflow: hidden;
}

.epub-viewer iframe {
  background: #f7f3e8;
}

.epub-viewer:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  background: #f7f3e8;
}

/* ==========================================================================
   Admin File Manager
   ========================================================================== */
.file-manager-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.file-manager-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 14px 36px -18px rgba(0, 0, 0, 0.7);
}

.file-manager-panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.file-root-list {
  display: grid;
  gap: 10px;
}

.file-root-link {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-2);
  word-break: break-all;
}

.file-root-link small {
  color: var(--text-dim);
}

.file-root-link.active {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.file-toolbar,
.folder-up-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.breadcrumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--accent-tint);
  font-weight: 700;
}

.breadcrumbs a + a::before {
  content: "/";
  margin-right: 8px;
  color: var(--text-dim);
}

.inline-admin-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-admin-form input {
  min-width: 190px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
}

.file-admin-table td {
  vertical-align: top;
}

.file-row-actions {
  display: grid;
  gap: 8px;
}

@media (max-width: 980px) {
  .file-manager-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Empty Shelf State
   ========================================================================== */
.empty-shelf {
  text-align: center;
  padding: 80px 20px;
  background: var(--panel);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  max-width: 600px;
  margin: 40px auto;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.8;
}

.empty-shelf h3 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 8px;
}

/* ==========================================================================
   Authentication & Login Card (ComfyUI Inspired)
   ========================================================================== */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 280px);
  padding: 40px 16px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: 
    0 24px 60px -15px rgba(0, 0, 0, 0.8),
    0 0 1px rgba(224, 164, 88, 0.2);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-badge {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.auth-title {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 8px;
}

.auth-desc {
  font-size: 13.5px;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-with-icon input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 44px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.input-with-icon input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--panel-3);
}

.auth-submit-btn {
  width: 100%;
  height: 46px;
  margin-top: 8px;
  font-size: 15px;
  border-radius: var(--radius);
  cursor: pointer;
}

.auth-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ==========================================================================
   Notice & Feedback
   ========================================================================== */
.notice {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notice.danger {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fca5a5;
}

/* ==========================================================================
   Hero Search Box (Quick & Mobile Discovery)
   ========================================================================== */
.hero-search-box {
  margin: 20px 0 24px;
  display: flex;
  gap: 10px;
  max-width: 580px;
  width: 100%;
}

.hero-search-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.hero-search-input-wrap svg {
  position: absolute;
  left: 14px;
  color: var(--accent);
  pointer-events: none;
}

.hero-search-input-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 44px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: all 0.2s ease;
}

.hero-search-input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--panel-3);
}

.hero-search-btn {
  height: 46px;
  padding: 0 22px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #020617;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hero-search-btn:hover {
  box-shadow: 0 4px 16px var(--accent-glow);
  filter: brightness(1.08);
}

/* ==========================================================================
   Site Footer
   ========================================================================== */
.site-footer {
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 36px 20px;
  color: var(--text-dim);
  font-size: 13.5px;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

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

.footer-title {
  font-family: var(--font-head);
  font-weight: 700;
  color: #fff;
}

.footer-links-col {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-links-col a {
  color: var(--text-dim);
}

.footer-links-col a:hover {
  color: var(--accent);
}

.format-note {
  color: var(--text-muted);
  font-size: 12.5px;
}

/* ==========================================================================
   Mobile Bottom Navigation Bar (Hidden by default on Desktop)
   ========================================================================== */
.mobile-bottom-bar {
  display: none;
}

/* ==========================================================================
   Responsive Adaptations & Mobile RWD System
   ========================================================================== */

/* Tablet & Smaller Laptops (<= 1024px) */
@media (max-width: 1024px) {
  .hero-grid {
    grid-template-columns: 1fr 280px;
    gap: 28px;
  }
}

/* Medium Tablets & Large Phones (<= 900px) */
@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  .hero-spotlight {
    display: none;
  }
  .book-detail-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .detail-cover-box {
    max-width: 220px;
    margin: 0 auto;
  }
}

/* Mobile Devices (<= 768px) - Full Mobile App Experience */
@media (max-width: 768px) {
  /* Page shell with safe bottom padding for the bottom bar */
  .app-shell {
    padding: 16px 14px calc(76px + env(safe-area-inset-bottom, 0px));
  }

  /* Immersive Reader Mode */
  body.is-reader-mode .site-header {
    display: none;
  }

  body.is-reader-mode .app-shell {
    padding: 0 !important;
    max-width: 100% !important;
  }

  body.is-reader-mode .mobile-bottom-bar {
    display: none !important;
  }

  /* Header adjustments */
  .site-header {
    height: 56px;
  }

  .header-inner {
    height: 56px;
    padding: 0 14px;
    gap: 12px;
  }

  .desktop-nav {
    display: none; /* Handed over to mobile bottom tab bar */
  }

  .header-search {
    display: none;
  }

  .brand-logo {
    font-size: 17px;
  }

  .user-nav .user-tag {
    padding: 4px 8px;
  }

  .user-nav .user-name {
    display: none;
  }

  .user-nav .logout-btn {
    padding: 5px 10px;
    font-size: 12px;
  }

  .user-nav .login-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Mobile Bottom Navigation Bar */
  .mobile-bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: rgba(10, 15, 31, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-dim);
    text-decoration: none;
    min-width: 52px;
    min-height: 48px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
  }

  .mobile-tab.active {
    color: var(--accent);
  }

  .mobile-tab:active {
    transform: scale(0.95);
  }

  .mobile-tab svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
  }

  .mobile-tab-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
  }

  /* Hero Banner */
  .hero-showcase {
    padding: 22px 16px;
    border-radius: var(--radius);
  }

  .hero-badge {
    font-size: 11.5px;
    padding: 4px 10px;
    margin-bottom: 12px;
  }

  .hero-title {
    font-size: clamp(20px, 5.5vw, 26px);
    line-height: 1.3;
    margin: 0 0 10px;
  }

  .hero-desc {
    font-size: 13.5px;
    line-height: 1.6;
    margin-bottom: 16px;
  }

  .hero-search-box {
    margin: 16px 0 20px;
    flex-direction: column;
    gap: 8px;
  }

  .hero-search-btn {
    width: 100%;
    height: 42px;
  }

  .hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 12px 8px;
    margin-bottom: 20px;
  }

  .stat-num {
    font-size: 16px;
  }

  .stat-label {
    font-size: 10px;
  }

  .hero-actions {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .hero-actions .btn-prime,
  .hero-actions .btn-secondary {
    width: 100%;
    height: 44px;
    justify-content: center;
    text-align: center;
    font-size: 14px;
  }

  /* Category pills */
  .category-bar-wrap {
    margin: 20px 0 16px;
  }

  .category-pills {
    gap: 8px;
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

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

  .category-pill {
    padding: 6px 14px;
    font-size: 12.5px;
    flex-shrink: 0;
  }

  /* 2-Column Responsive Book Grid */
  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 10px;
  }

  .book-card,
  .book-info {
    min-width: 0;
  }

  .book-cover-container {
    display: contents;
  }

  .book-cover-link {
    order: 0;
    aspect-ratio: 2 / 3;
  }

  .book-info {
    order: 1;
  }

  .shelf-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 14px;
  }

  .shelf-head .shelf-title {
    font-size: 18px;
  }

  /* Touch optimizations: actions sit below the cover on mobile. */
  .book-quick-actions {
    position: static;
    order: 2;
    inset: auto;
    flex-flow: row wrap;
    align-items: stretch;
    justify-content: stretch;
    gap: 6px;
    margin-top: 6px;
    padding: 0;
    opacity: 1;
    pointer-events: auto;
    background: transparent;
    backdrop-filter: none;
  }

  .quick-btn {
    flex: 1 1 58px;
    width: auto;
    min-height: 34px;
    padding: 5px 6px;
    font-size: 11px;
    border-radius: 4px;
  }

  .book-info {
    padding: 8px 2px 2px;
  }

  .book-meta-row {
    gap: 4px;
    margin-bottom: 4px;
  }

  .book-category-tag {
    font-size: 10px;
  }

  .format-pill {
    font-size: 9px;
    padding: 2px 5px;
  }

  .book-title {
    font-size: 13px;
    line-height: 1.35;
    height: 2.7em;
    -webkit-line-clamp: 2;
  }

  .book-author {
    font-size: 11px;
  }

  /* 3D Hardcover Jackets on Mobile */
  .jacket-inner {
    inset: 3px 3px 3px 12px;
    padding: 10px 8px;
  }

  .jacket-head {
    gap: 4px;
    padding-bottom: 6px;
  }

  .jacket-icon {
    font-size: 13px !important;
  }

  .jacket-cat {
    font-size: 9.5px !important;
  }

  .jacket-title {
    font-size: 12px !important;
    line-height: 1.35 !important;
    -webkit-line-clamp: 3 !important;
  }

  .jacket-ornament {
    display: none;
  }

  .jacket-footer {
    padding-top: 6px;
  }

  .jacket-author {
    font-size: 10.5px !important;
  }

  /* Catalog Page (Books/Index) */
  .catalog-head {
    margin-bottom: 16px;
  }

  .catalog-title {
    font-size: 20px;
  }

  .catalog-filter-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
  }

  .catalog-search-input,
  .catalog-cat-select {
    width: 100%;
    min-width: unset;
    height: 42px;
    font-size: 14px;
  }

  .catalog-filter-card .btn-prime,
  .catalog-filter-card .btn-secondary {
    width: 100%;
    height: 42px;
    justify-content: center;
    text-align: center;
  }

  .magazine-shell {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .magazine-sidebar {
    position: static;
    width: 100%;
    max-height: 260px;
    padding: 12px;
  }

  .reading-list-panel {
    order: 2;
  }

  .magazine-main {
    order: 1;
    width: 100%;
  }

  .folder-panel {
    order: 0;
  }

  .magazine-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .magazine-toolbar .btn-prime {
    width: 100%;
  }

  .magazine-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 10px;
  }

  .pagination-container {
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-top: 24px;
  }

  .page-btn {
    padding: 8px 12px;
    font-size: 12.5px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
  }

  /* Book Details Page */
  .book-detail-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px 16px;
    margin-top: 6px;
  }

  .detail-cover-box {
    max-width: 180px;
    margin: 0 auto;
  }

  .detail-title {
    font-size: 20px;
    line-height: 1.3;
    margin-bottom: 8px;
  }

  .detail-author {
    font-size: 13.5px;
    margin-bottom: 16px;
  }

  .detail-desc-card {
    padding: 14px;
    font-size: 13.5px;
    margin-bottom: 20px;
  }

  .detail-actions {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .detail-actions .btn-prime,
  .detail-actions .btn-secondary,
  .detail-actions form,
  .detail-actions form button {
    width: 100%;
    height: 46px;
    justify-content: center;
    text-align: center;
    font-size: 14px;
  }

  /* Reader Page */
  .reader-shell {
    border-radius: 0;
    border: none;
    margin: 0;
  }

  .reader-toolbar {
    padding: 8px 10px;
    gap: 8px;
  }

  .reader-meta {
    gap: 8px;
    min-width: unset;
  }

  .reader-back-btn {
    padding: 6px 8px;
    font-size: 12px;
  }

  .reader-back-btn .back-text {
    display: none;
  }

  .reader-info .reader-cat {
    display: none;
  }

  .reader-book-title {
    font-size: 13.5px;
    max-width: 130px;
  }

  .reader-author {
    display: none;
  }

  .reader-actions {
    gap: 6px;
  }

  .reader-pill-btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  .reader-subbar {
    padding: 6px 10px;
    font-size: 11.5px;
  }

  .reader-frame,
  .epub-viewer {
    height: calc(100dvh - 92px);
    min-height: calc(100dvh - 92px);
  }

  .desktop-pdf-reader {
    display: none;
  }

  .mobile-pdf-reader {
    display: flex;
    flex: 1;
    min-height: calc(100dvh - 92px);
    padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    background: #05070d;
  }

  .mobile-pdf-stage {
    display: flex;
    flex: 1;
    align-items: flex-start;
    justify-content: center;
    min-height: 0;
    padding: 8px;
    overflow: auto;
    overscroll-behavior: contain;
  }

#pdf-mobile-canvas {
    display: block;
    max-width: none;
    background: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  }

  .mobile-reader-status {
    padding: 10px 14px;
    color: var(--text-dim);
    text-align: center;
    background: var(--panel-2);
  }

  .mobile-reader-status.danger {
    color: #fecaca;
  }

  .mobile-reader-controls {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(5, 8, 18, 0.96);
    border-top: 1px solid var(--border-strong);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
  }

  .mobile-reader-controls button {
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    color: var(--text);
    background: var(--panel-3);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
  }

  .mobile-reader-controls button:disabled {
    opacity: 0.35;
  }

  .mobile-reader-progress {
    min-width: 52px;
    color: var(--accent-tint);
    text-align: center;
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
  }

  .mobile-pdf-controls {
    gap: 4px;
  }

  .mobile-pdf-controls button {
    min-width: 40px;
    padding: 0 7px;
    font-size: 11px;
  }

  .epub-viewer {
    padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  }

  body.reader-immersive-active {
    overflow: hidden;
  }

  .reader-shell.reader-immersive {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    width: 100vw;
    height: 100dvh;
    margin: 0;
    overflow: hidden;
    background: #05070d;
  }

  .reader-shell.reader-immersive .reader-immersive-back,
  .reader-shell:fullscreen .reader-immersive-back {
    position: fixed;
    top: max(10px, env(safe-area-inset-top, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    z-index: 2147483646;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    color: #fff;
    text-decoration: none;
    background: rgba(4, 8, 18, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }

  .reader-shell.reader-immersive .reader-toolbar,
  .reader-shell.reader-immersive .reader-subbar,
  .reader-shell.reader-immersive .epub-controls,
  .reader-shell.reader-immersive .image-reader-controls {
    display: none;
  }

  .reader-shell.reader-immersive .mobile-pdf-reader,
  .reader-shell.reader-immersive .epub-viewer {
    height: calc(100dvh - 62px - env(safe-area-inset-bottom, 0px));
    min-height: 0;
  }

  .image-reader-page {
    min-height: calc(100dvh - 92px);
    padding: 10px;
  }

  .image-reader-page img {
    max-height: calc(100dvh - 112px);
  }

  /* Auth / Login Page */
  .auth-wrap {
    padding: 20px 12px;
    min-height: calc(100dvh - 180px);
  }

  .auth-card {
    padding: 24px 18px;
    border-radius: var(--radius);
  }

  .auth-title {
    font-size: 20px;
  }

  .auth-desc {
    font-size: 12.5px;
  }

  /* Footer */
  .site-footer {
    padding: 24px 16px;
    margin-bottom: 58px;
    font-size: 12px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .footer-links-col {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

#pdf-mobile-canvas[hidden] {
  display: none !important;
}

/* Tablet reader controls: iPad portrait and landscape. */
@media (min-width: 769px) and (max-width: 1024px),
       (min-width: 769px) and (max-width: 1366px) and (any-pointer: coarse) {
  .desktop-epub-nav {
    display: none;
  }

  .epub-scroll-mode .tablet-page-nav {
    display: none;
  }

  body.is-reader-mode .desktop-pdf-reader {
    display: none;
  }

  body.is-reader-mode .mobile-pdf-reader {
    display: flex;
    flex: 1;
    min-height: calc(100dvh - 150px);
    flex-direction: column;
    background: #05070d;
  }

  body.is-reader-mode .mobile-pdf-stage {
    display: flex;
    flex: 1;
    align-items: flex-start;
    justify-content: center;
    min-height: 0;
    padding: 12px 72px;
    overflow: auto;
    overscroll-behavior: contain;
  }

  body.is-reader-mode #pdf-mobile-canvas {
    display: block;
    max-width: none;
    background: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  }

  .reader-shell.mobile-pdf-scroll-mode .mobile-pdf-stage {
    display: block;
    padding: 0;
    overflow: auto;
    background: #05070d;
  }

  .reader-shell.mobile-pdf-scroll-mode #pdf-mobile-canvas {
    display: none;
  }

  .reader-shell.mobile-pdf-scroll-mode .mobile-scroll-pages {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .reader-shell.mobile-pdf-scroll-mode .mobile-scroll-page {
    display: flex;
    width: 100%;
    align-items: flex-start;
    justify-content: center;
    background: #fff;
  }

  .reader-shell.mobile-pdf-scroll-mode .mobile-scroll-page canvas {
    display: block;
    max-width: 100%;
    height: auto;
    background: #fff;
  }

  .reader-shell.mobile-pdf-scroll-mode .tablet-page-nav,
  .reader-shell.mobile-pdf-scroll-mode .tablet-reader-progress,
  .reader-shell.mobile-pdf-scroll-mode .tablet-reader-tools {
    display: none;
  }

  body.is-reader-mode .mobile-reader-status {
    padding: 10px 14px;
    color: var(--text-dim);
    text-align: center;
    background: var(--panel-2);
  }

  .tablet-reader-controls {
    display: contents;
  }

  .tablet-page-nav,
  .tablet-reader-progress,
  .tablet-reader-tools {
    position: fixed;
    z-index: 1800;
    color: #fff;
    background: rgba(4, 8, 18, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(12px);
    opacity: 0.9;
    transition: opacity 0.18s ease, background 0.18s ease;
  }

  .tablet-page-nav:hover,
  .tablet-page-nav:focus-visible,
  .tablet-page-nav:active,
  .tablet-reader-tools:hover,
  .tablet-reader-tools:focus-within {
    opacity: 1;
    background: rgba(4, 8, 18, 0.88);
  }

  .tablet-page-nav {
    top: 50%;
    width: 54px;
    height: 76px;
    padding: 0;
    border-radius: 12px;
    font: 500 46px/1 var(--font-body);
    transform: translateY(-50%);
  }

  .tablet-page-prev {
    left: max(14px, env(safe-area-inset-left, 0px));
  }

  .tablet-page-next {
    right: max(14px, env(safe-area-inset-right, 0px));
  }

  .tablet-page-nav:disabled {
    opacity: 0.32;
    pointer-events: none;
  }

  .tablet-reader-progress {
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    min-width: 74px;
    padding: 9px 14px;
    border-radius: 999px;
    text-align: center;
    font-size: 13px;
    font-weight: 750;
    transform: translateX(-50%);
  }

  .tablet-reader-tools {
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    display: flex;
    gap: 5px;
    padding: 5px;
    border-radius: 10px;
  }

  .tablet-reader-tools button {
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border: 0;
    border-radius: 7px;
    font: 700 12px/1 var(--font-body);
  }

  body.reader-immersive-active {
    overflow: hidden;
  }

  .reader-shell.reader-immersive {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    width: 100vw;
    height: 100dvh;
    margin: 0;
    overflow: hidden;
    background: #05070d;
  }

  .reader-shell .reader-immersive-back {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    z-index: 2147483646;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 48px;
    padding: 0 16px;
    color: #fff;
    text-decoration: none;
    background: rgba(4, 8, 18, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 999px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  }

  .reader-shell.reader-immersive .reader-toolbar,
  .reader-shell.reader-immersive .reader-subbar,
  .reader-shell.reader-immersive .epub-controls,
  .reader-shell.reader-immersive .image-reader-controls {
    display: none;
  }

  .reader-shell.reader-immersive .mobile-pdf-reader,
  .reader-shell.reader-immersive .epub-viewer {
    height: 100dvh;
    min-height: 0;
  }
}

/* Extra Small Phones (<= 380px) */
@media (max-width: 380px) {
  .book-grid {
    gap: 10px 8px;
  }
  .reader-book-title {
    max-width: 100px;
  }
  .stat-num {
    font-size: 14px;
  }
  .stat-label {
    font-size: 9.5px;
  }
}


.reading-metrics { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin:18px 0; }
.reading-metric { border:1px solid var(--border, #d9e2df); background:var(--surface, #fff); border-radius:8px; padding:16px; display:grid; gap:6px; }
.reading-metric span { color:var(--muted, #64748b); font-size:.82rem; }
.reading-metric strong { font-size:1.45rem; }
.reading-filter { display:grid; grid-template-columns:repeat(6,minmax(110px,1fr)) auto; gap:10px; align-items:end; }
.reading-filter input,.reading-filter select { width:100%; min-height:42px; }
.table-scroll { overflow-x:auto; }
.reading-table { min-width:850px; }
@media (max-width: 760px) { .reading-metrics { grid-template-columns:1fr; } .reading-filter { grid-template-columns:1fr 1fr; } }
.profile-form { max-width:820px; display:grid; gap:16px; }
.profile-form label { display:grid; gap:7px; font-weight:700; }
.profile-form input,.profile-form textarea { width:100%; }
.profile-contact { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:16px; align-items:end; }
.profile-form .privacy-toggle { display:flex; grid-template-columns:none; flex-direction:row; align-items:center; font-weight:500; }
.privacy-toggle input { width:auto; }
.member-profile { max-width:760px; }
.member-profile dl { display:grid; grid-template-columns:140px 1fr; gap:10px 18px; }
.discussion-layout{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:24px}.discussion-list,.post-list{display:grid;gap:10px}.discussion-row,.discussion-post,.discussion-compose,.book-discussion{border:1px solid var(--border,#26334b);border-radius:8px;padding:16px;background:var(--surface,#0b1325)}.discussion-row{display:flex;justify-content:space-between;color:inherit;text-decoration:none}.discussion-row span:first-child,.discussion-compose{display:grid;gap:8px}.discussion-row small,.discussion-post time{display:block;color:var(--muted,#94a3b8);font-size:.8rem}.discussion-post header{display:flex;justify-content:space-between;gap:12px}.discussion-reply{margin:12px 0 0 28px;padding:12px;border-left:3px solid var(--accent,#dca54b)}.discussion-compose label{display:grid;gap:7px}.discussion-search{display:flex;gap:10px;margin-bottom:16px}.discussion-search input{flex:1}.book-discussion{margin-top:24px}@media(max-width:800px){.discussion-layout{grid-template-columns:1fr}}
.admin-tabs{display:flex;gap:4px;overflow-x:auto;border-bottom:1px solid var(--border,#26334b);margin-bottom:18px}.admin-tabs a{padding:11px 14px;color:var(--muted,#94a3b8);text-decoration:none;white-space:nowrap;border-bottom:2px solid transparent}.admin-tabs a.active{color:var(--accent,#e7ad4e);border-bottom-color:currentColor}.row-actions{display:flex;gap:6px;flex-wrap:wrap}.row-actions form{margin:0}

/* ==========================================================================
   Professional Administration Workspace
   ========================================================================== */
body.is-admin-mode {
  --admin-bg: #0b0d10;
  --admin-surface: #12151a;
  --admin-surface-2: #181c22;
  --admin-border: #2a3039;
  --admin-text: #f4f6f8;
  --admin-muted: #9aa3af;
  --admin-accent: #d79a43;
  --admin-success: #39a875;
  --admin-warning: #c99045;
  --admin-danger: #d65d67;
  background: var(--admin-bg);
}

body.is-admin-mode::before { display: none; }
body.is-admin-mode .app-shell { max-width: 1600px; padding-top: 26px; }
body.is-admin-mode .site-footer { background: #090b0e; border-top-color: var(--admin-border); }

.admin-workspace,
body.is-admin-mode .app-shell > section,
body.is-admin-mode .app-shell > form,
body.is-admin-mode .app-shell > table,
body.is-admin-mode .app-shell > div { color: var(--admin-text); }

body.is-admin-mode .admin-tabs {
  gap: 2px;
  margin: 0 0 28px;
  padding: 0 4px;
  border-bottom: 1px solid var(--admin-border);
}

body.is-admin-mode .admin-tabs a {
  padding: 10px 16px 12px;
  color: var(--admin-muted);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0;
}

body.is-admin-mode .admin-tabs a:hover { color: var(--admin-text); background: var(--admin-surface); }
body.is-admin-mode .admin-tabs a.active { color: var(--admin-accent); border-bottom-color: var(--admin-accent); }

.admin-page-header,
body.is-admin-mode .page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 22px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.admin-page-header h1,
body.is-admin-mode .page-head h1 { margin: 2px 0 5px; color: var(--admin-text); font-size: 27px; line-height: 1.2; letter-spacing: 0; }
.admin-page-header p,
body.is-admin-mode .page-head p { margin: 0; color: var(--admin-muted); }
.admin-page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.admin-page-actions form { margin: 0; }

.admin-btn,
body.is-admin-mode .button,
body.is-admin-mode button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid var(--admin-border);
  border-radius: 5px;
  color: var(--admin-text);
  background: var(--admin-surface-2);
  font: 650 13px/1.2 var(--font-body);
  letter-spacing: 0;
  cursor: pointer;
}

.admin-btn:hover,
body.is-admin-mode .button:hover { color: #fff; border-color: #49515d; background: #22272f; }
.admin-btn-primary,
body.is-admin-mode .button:not(.secondary):not(.danger) { color: #17120b; border-color: var(--admin-accent); background: var(--admin-accent); }
.admin-btn-danger,
body.is-admin-mode .button.danger { color: #fff; border-color: #8e3d46; background: #7d343d; }

.admin-metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 18px;
  border: 1px solid var(--admin-border);
  background: var(--admin-surface);
}

.admin-metric-strip > div { padding: 16px 18px; border-right: 1px solid var(--admin-border); }
.admin-metric-strip > div:last-child { border-right: 0; }
.admin-metric-strip span { display: block; color: var(--admin-muted); font-size: 12px; }
.admin-metric-strip strong { display: block; margin-top: 3px; color: var(--admin-text); font: 700 23px/1.2 var(--font-head); }

.admin-toolbar,
body.is-admin-mode .search-panel {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(4, minmax(130px, 1fr)) auto auto;
  gap: 9px;
  margin: 0 0 16px;
  padding: 13px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  background: var(--admin-surface);
}

.admin-toolbar input,
.admin-toolbar select,
body.is-admin-mode input,
body.is-admin-mode select,
body.is-admin-mode textarea {
  min-height: 38px;
  padding: 8px 11px;
  color: var(--admin-text);
  background: #0d1014;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  outline: none;
}

.admin-toolbar input:focus,
.admin-toolbar select:focus,
body.is-admin-mode input:focus,
body.is-admin-mode select:focus,
body.is-admin-mode textarea:focus { border-color: var(--admin-accent); box-shadow: 0 0 0 2px rgba(215,154,67,.12); }

.admin-table-surface,
body.is-admin-mode .table-scroll,
body.is-admin-mode > .admin-table { overflow-x: auto; border: 1px solid var(--admin-border); border-radius: 6px; background: var(--admin-surface); }
body.is-admin-mode .admin-table { width: 100%; margin: 0; border-collapse: collapse; background: transparent; }
body.is-admin-mode .admin-table th { padding: 11px 13px; color: #bdc5cf; background: #171a1f; border-bottom: 1px solid var(--admin-border); font-size: 11px; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; text-align: left; }
body.is-admin-mode .admin-table td { padding: 12px 13px; color: #dce1e7; border-bottom: 1px solid #242932; vertical-align: middle; }
body.is-admin-mode .admin-table tbody tr:hover { background: #171b21; }
body.is-admin-mode .admin-table tbody tr:last-child td { border-bottom: 0; }
body.is-admin-mode .admin-table td strong { color: #fff; font-weight: 650; }
body.is-admin-mode .admin-table td small { display: block; color: var(--admin-muted); margin-top: 2px; }

.admin-batchbar,
body.is-admin-mode .pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding: 10px 13px;
  color: var(--admin-muted);
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}
.admin-batchbar > div { display: flex; gap: 7px; }

.admin-status,
body.is-admin-mode .notice { margin-bottom: 16px; padding: 10px 13px; border: 1px solid #35516b; border-radius: 5px; color: #cce4f4; background: #152330; }
.admin-status.success { border-color: #285e48; color: #c9f0dc; background: #13271f; }
.admin-status.warning { border-color: #6e532c; color: #f1d5a7; background: #2a2114; }
.admin-status.error { border-color: #713b42; color: #f5c8cd; background: #2b171a; }

.admin-badge { display: inline-flex; padding: 3px 7px; border: 1px solid var(--admin-border); border-radius: 999px; color: #c3cad3; background: #1b1f25; font-size: 11px; font-weight: 700; white-space: nowrap; }
.admin-badge.success { color: #a9e6c8; border-color: #2f654d; background: #14271f; }
.admin-badge.warning { color: #ebcb96; border-color: #6d522d; background: #2b2215; }
.admin-badge.danger { color: #efb8bd; border-color: #744049; background: #2c191c; }

.admin-job-panel { margin-bottom: 18px; padding: 17px; border: 1px solid var(--admin-border); border-radius: 6px; background: var(--admin-surface); }
.admin-job-heading { display: flex; justify-content: space-between; gap: 20px; }
.admin-job-heading h2 { margin: 3px 0; font-size: 17px; }
.admin-job-heading p { margin: 0; color: var(--admin-muted); }
.admin-job-state { color: var(--admin-accent); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.admin-progress-track { height: 7px; margin: 16px 0 12px; overflow: hidden; background: #090b0e; border: 1px solid #252a31; border-radius: 2px; }
.admin-progress-track span { display: block; height: 100%; background: var(--admin-accent); transition: width .25s ease; }
.admin-job-stats { display: flex; flex-wrap: wrap; gap: 18px; color: var(--admin-muted); font-size: 12px; }
.admin-job-stats strong { color: var(--admin-text); }

.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--admin-border);
  border-top: 0;
  background: var(--admin-surface);
  color: var(--admin-muted);
}
.admin-pagination > div { display: flex; gap: 8px; }
.admin-btn.disabled { opacity: .38; pointer-events: none; }

body.is-admin-mode .reading-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 16px;
  border: 1px solid var(--admin-border);
  background: var(--admin-surface);
}
body.is-admin-mode .reading-metric { padding: 15px 17px; border: 0; border-right: 1px solid var(--admin-border); border-radius: 0; background: transparent; box-shadow: none; }
body.is-admin-mode .reading-metric:last-child { border-right: 0; }
body.is-admin-mode .reading-metric span { color: var(--admin-muted); font-size: 12px; }
body.is-admin-mode .reading-metric strong { color: var(--admin-text); font-size: 21px; }
body.is-admin-mode .reading-filter { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)) auto auto; gap: 9px; margin-bottom: 16px; padding: 13px; border: 1px solid var(--admin-border); border-radius: 6px; background: var(--admin-surface); }
body.is-admin-mode .pill { color: #c9d0d8; background: #1c2128; border-color: #353c46; }
body.is-admin-mode .file-manager-panel { border-color: var(--admin-border); background: var(--admin-surface); box-shadow: none; }
body.is-admin-mode .file-toolbar { border-bottom-color: var(--admin-border); }

body.is-admin-mode .form-card,
body.is-admin-mode .panel,
body.is-admin-mode fieldset { border-color: var(--admin-border); background: var(--admin-surface); box-shadow: none; }

body.is-admin-mode .page-head .actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
body.is-admin-mode .page-head .actions form { margin: 0; }
body.is-admin-mode .file-manager-main { min-width: 0; }
body.is-admin-mode .file-admin-table th:last-child,
body.is-admin-mode .file-admin-table td:last-child { width: 1%; white-space: nowrap; }
.file-actions-menu { position: relative; }
.file-actions-menu > summary { list-style: none; }
.file-actions-menu > summary::-webkit-details-marker { display: none; }
.file-actions-menu[open] > summary { border-color: var(--admin-accent); color: var(--admin-accent); }
.file-actions-menu .file-row-actions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  width: min(520px, 72vw);
  padding: 12px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  background: #171a1f;
  box-shadow: 0 18px 45px rgba(0,0,0,.45);
}
.file-actions-menu .inline-admin-form { display: grid; grid-template-columns: minmax(180px, 1fr) auto; }
.file-actions-menu .inline-admin-form input { width: 100%; min-width: 0; }
.file-actions-menu .file-row-actions > form:last-child { display: flex; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--admin-border); }

@media (max-width: 1100px) {
  .admin-toolbar, body.is-admin-mode .search-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.is-admin-mode .reading-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-metric-strip > div { border-bottom: 1px solid var(--admin-border); }
}

@media (max-width: 700px) {
  body.is-admin-mode .app-shell { padding: 16px 12px 76px; }
  .admin-page-header, body.is-admin-mode .page-head { flex-direction: column; }
  .admin-toolbar, body.is-admin-mode .search-panel { grid-template-columns: 1fr; }
  .admin-metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-job-heading, .admin-batchbar, .admin-pagination, body.is-admin-mode .pagination-bar { align-items: stretch; flex-direction: column; }
  .admin-batchbar > div { overflow-x: auto; }
  .admin-pagination > div { overflow-x: auto; }
}

.category-access-toolbar,
.category-permission-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0;
}
.category-access-toolbar label { font-weight: 650; }
body.is-admin-mode .category-access-toolbar input,
body.is-admin-mode .category-permission-heading input { width: min(100%, 360px); min-height: 44px; }
.category-access-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.category-access-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 64px;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--admin-border, var(--border));
  border-radius: 6px;
  background: var(--admin-surface, var(--panel));
}
.category-access-card[hidden] { display: none; }
.category-access-card > div,
.category-access-card > span { min-width: 0; }
.category-access-card strong,
.category-access-card small { display: block; overflow-wrap: anywhere; }
.category-access-card small { margin-top: 3px; color: var(--admin-muted, var(--text-dim)); }
.category-access-card form { display: flex; align-items: center; gap: 8px; margin: 0; }
body.is-admin-mode .category-access-card button,
.category-access-card input[type="checkbox"] { min-height: 44px; }
.category-permission-panel { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--admin-border, var(--border)); }
.category-permission-heading { align-items: center; }
.category-permission-heading h2 { margin: 0 0 4px; font-size: 18px; }
.category-permission-heading p { margin: 0; }
.permission-toggle { justify-content: flex-start; cursor: pointer; }
.permission-toggle input[type="checkbox"] { width: 22px; min-width: 22px; margin: 0; }

@media (max-width: 768px) {
  .category-access-toolbar,
  .category-permission-heading { align-items: stretch; flex-direction: column; }
  .category-access-toolbar input,
  .category-permission-heading input { width: 100%; }
  .category-access-grid { grid-template-columns: 1fr; }
  .category-access-card { align-items: stretch; flex-direction: column; }
  .category-access-card form { justify-content: space-between; }
  .permission-toggle { align-items: center; flex-direction: row; }
}

/* ==========================================================================
   Homepage Library Index & Featured Recommendations
   ========================================================================== */
.home-library-layout {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  transition: grid-template-columns 220ms ease;
}

.home-library-layout.is-directory-open {
  grid-template-columns: 280px minmax(0, 1fr);
}

.home-library-content { min-width: 0; }

.library-directory {
  position: sticky;
  top: 82px;
  z-index: 20;
  width: 100%;
  height: calc(100vh - 106px);
  min-height: 420px;
  overflow: hidden;
  color: var(--text);
  background: linear-gradient(180deg, #10182a 0%, #080d1b 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.directory-rail-toggle,
.directory-mobile-toggle,
.directory-close,
.directory-backdrop {
  font: inherit;
  cursor: pointer;
}

.directory-rail-toggle {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 58px;
  min-height: 100%;
  padding: 18px 7px;
  color: var(--text-dim);
  background: transparent;
  border: 0;
}

.directory-rail-toggle:hover { color: var(--accent-tint); }

.directory-toggle-symbol {
  display: grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  color: #08101e;
  background: var(--accent);
  border-radius: 50%;
  font: 700 22px/1 var(--font-head);
  box-shadow: 0 8px 20px rgba(224, 164, 88, 0.24);
}

.directory-rail-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  writing-mode: vertical-rl;
}

.directory-panel {
  position: absolute;
  inset: 0;
  width: 280px;
  padding: 18px 14px 24px;
  overflow: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-12px);
  transition: opacity 160ms ease, transform 220ms ease;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.is-directory-open .directory-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.is-directory-open .directory-rail-toggle {
  opacity: 0;
  pointer-events: none;
}

.directory-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 14px;
  border-bottom: 1px solid var(--border);
}

.directory-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font: 700 9px/1.2 var(--font-head);
  letter-spacing: 0.2em;
}

.directory-panel-head h2 {
  margin: 0;
  font: 700 19px/1.3 var(--font-head);
}

.directory-close {
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  color: var(--text-dim);
  background: var(--panel-3);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 22px;
}

.directory-all-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  margin: 12px 0 8px;
  padding: 0 12px;
  color: var(--accent-tint);
  background: rgba(224, 164, 88, 0.1);
  border: 1px solid rgba(224, 164, 88, 0.32);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
}

.directory-groups { display: grid; gap: 4px; }

.directory-group {
  border-bottom: 1px solid rgba(44, 54, 84, 0.55);
}

.directory-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 8px 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  list-style: none;
}

.directory-group summary::-webkit-details-marker { display: none; }
.directory-group summary::before { content: '+'; color: var(--accent); margin-right: 2px; }
.directory-group[open] summary::before { content: '−'; }
.directory-group summary > :first-child { flex: 1; }

.directory-count {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.directory-category-list {
  display: grid;
  gap: 2px;
  padding: 0 2px 10px 20px;
}

.directory-category-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 6px 8px;
  color: var(--text-dim);
  border-radius: 5px;
  font-size: 12px;
}

.directory-category-list a:hover {
  color: var(--text);
  background: var(--panel-hover);
}

.directory-category-list a span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.directory-category-list a span:last-child { color: var(--text-muted); }
.directory-category-list .directory-group-link { color: var(--accent); font-weight: 700; }
.directory-mobile-toggle,
.directory-backdrop { display: none; }

.featured-book-entry {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.featured-book-entry .book-card { flex: 1; }

.featured-reason {
  display: -webkit-box;
  min-height: 4.4em;
  margin: 10px 5px 0;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.featured-reason span { color: var(--accent); }

.detail-recommendation {
  margin: -10px 0 24px;
  padding: 16px 18px;
  background: rgba(224, 164, 88, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}

.detail-recommendation-label {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.detail-recommendation p { margin: 0; color: var(--text); }

@media (min-width: 1200px) {
  .featured-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .home-library-layout,
  .home-library-layout.is-directory-open {
    display: block;
  }

  .directory-mobile-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    margin: 20px 0 0;
    padding: 5px 14px 5px 6px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    font-weight: 700;
  }

  .directory-mobile-toggle .directory-toggle-symbol {
    width: 34px;
    min-width: 34px;
    height: 34px;
  }

  .library-directory {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1200;
    width: min(86vw, 340px);
    height: 100dvh;
    min-height: 0;
    border-width: 0 1px 0 0;
    border-radius: 0;
    transform: translateX(-101%);
    transition: transform 220ms ease;
  }

  .is-directory-open .library-directory { transform: translateX(0); }
  .directory-rail-toggle { display: none; }
  .directory-panel,
  .is-directory-open .directory-panel {
    width: 100%;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .directory-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1190;
    background: rgba(2, 6, 23, 0.74);
    border: 0;
  }

  .is-directory-open .directory-backdrop { display: block; }
  body.is-directory-drawer-open { overflow: hidden; }
}

@media (max-width: 600px) {
  .featured-reason {
    min-height: 5.6em;
    margin-inline: 2px;
    font-size: 11.5px;
    -webkit-line-clamp: 4;
  }
}
