/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Colors */
  --color-bg: #ffffff;
  --color-text: #000000;
  --color-text-muted: #666666;
  --color-text-subtle: #999999;
  --color-accent: #d4002a;
  --color-border: #e0e0e0;
  --color-border-light: #f0f0f0;
  --color-surface: #f8f8f6;
  --color-reader-bg: #ffffff;
  --color-reader-text: #1a1a1a;
  --color-reader-muted: #888888;
  --color-reader-toolbar: #f5f5f5;
  --color-reader-border: #e0e0e0;

  /* Typography */
  --font-primary: 'Libre Franklin', 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  --text-xs: 0.6875rem;   /* 11px */
  --text-sm: 0.75rem;     /* 12px */
  --text-base: 0.875rem;  /* 14px */
  --text-md: 1rem;        /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.375rem;    /* 22px */
  --text-2xl: 1.75rem;    /* 28px */
  --text-3xl: 2.25rem;    /* 36px */
  --text-4xl: 3rem;       /* 48px */
  --text-5xl: 4rem;       /* 64px */

  /* Letter spacing */
  --tracking-tight: -0.02em;
  --tracking-normal: -0.01em;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Layout */
  --header-height: 56px;
  --reader-toolbar-height: 56px;
  --reader-header-height: 52px;
  --max-width: 1400px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
  --transition-flip: 600ms cubic-bezier(0.645, 0.045, 0.355, 1.0);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-primary);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
  line-height: inherit;
}

input, select {
  font-family: inherit;
}

img, canvas {
  display: block;
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   SITE HEADER
   ============================================================ */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-8);
  height: 100%;
}

.site-title {
  font-size: var(--text-md);
  font-weight: 900;
  letter-spacing: var(--tracking-tight);
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

.site-title:hover {
  opacity: 0.6;
}

/* Site Nav */
.site-nav {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.site-nav::-webkit-scrollbar { display: none; }

.nav-link {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-4);
  white-space: nowrap;
  transition: color var(--transition-fast);
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: var(--space-4);
  right: var(--space-4);
  height: 2px;
  background: var(--color-text);
  transform: scaleX(0);
  transition: transform var(--transition-fast);
}

.nav-link:hover {
  color: var(--color-text);
}

.nav-link--active {
  color: var(--color-text);
}

.nav-link--active::after {
  transform: scaleX(1);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-shrink: 0;
}

.search-input {
  width: 180px;
  height: 32px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text);
  padding: 0 var(--space-2);
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-input::placeholder {
  color: var(--color-text-subtle);
}

.search-input:focus {
  border-color: var(--color-text);
}

.sort-select {
  height: 32px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: 0 var(--space-4) 0 var(--space-2);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23666' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 10px;
  min-width: 120px;
}

/* ============================================================
   LOADING STATE
   ============================================================ */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-24) var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.loading-dots {
  display: flex;
  gap: var(--space-2);
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: bounce 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================================
   LIBRARY — HERO SECTION
   ============================================================ */
.hero-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-12) var(--space-8) 0;
}

.hero-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  cursor: pointer;
  overflow: hidden;
  min-height: 480px;
}

.hero-card:hover .hero-image-wrap img,
.hero-card:hover .hero-cover-placeholder {
  transform: scale(1.02);
}

.hero-card:hover .hero-title {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.hero-image-wrap {
  overflow: hidden;
  background: var(--color-surface);
  position: relative;
}

.hero-image-wrap .cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 400ms ease;
}

.hero-image-wrap .cover-img.loaded {
  opacity: 1;
}

.hero-cover-placeholder {
  width: 100%;
  height: 100%;
  min-height: 480px;
  display: flex;
  align-items: flex-end;
  padding: var(--space-8);
  transition: transform var(--transition-slow);
}

.hero-info {
  padding: var(--space-12) var(--space-12) var(--space-12) var(--space-10);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--color-bg);
}

.hero-category {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-4);
}

.hero-title {
  font-size: var(--text-4xl);
  font-weight: 900;
  letter-spacing: var(--tracking-tight);
  line-height: 1.05;
  margin-bottom: var(--space-4);
}

.hero-subtitle {
  font-size: var(--text-lg);
  font-weight: 300;
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.hero-meta {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
  display: flex;
  gap: var(--space-4);
}

.hero-cta {
  margin-top: var(--space-8);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-accent);
}

/* ============================================================
   LIBRARY — FILTER BAR
   ============================================================ */
.library-toolbar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-8) var(--space-8) var(--space-4);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border-light);
}

.library-count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.library-count strong {
  color: var(--color-text);
  font-weight: 700;
}

/* ============================================================
   LIBRARY — CATALOG GRID
   ============================================================ */
.catalog-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-8);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-12) var(--space-8);
}

/* Catalog Card */
.catalog-card {
  cursor: pointer;
  position: relative;
}

.catalog-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

.card-image-wrap {
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--color-surface);
  margin-bottom: var(--space-4);
  position: relative;
}

.cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 400ms ease;
}

.cover-img.loaded {
  opacity: 1;
}

.card-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  padding: var(--space-5);
  transition: transform var(--transition-slow);
}

.catalog-card:hover .card-cover-placeholder,
.catalog-card:hover .card-image-wrap img {
  transform: scale(1.03);
}

.placeholder-title {
  font-size: var(--text-lg);
  font-weight: 900;
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  color: rgba(0,0,0,0.75);
  word-break: break-word;
}

.card-category {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  margin-bottom: var(--space-2);
}

.card-title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: 1.15;
  margin-bottom: var(--space-1);
  transition: text-decoration var(--transition-fast);
}

.catalog-card:hover .card-title {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.card-subtitle {
  font-size: var(--text-base);
  font-weight: 300;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.card-meta {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

/* PDF cover loading state */
.cover-loading {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.cover-loading-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 40%;
  background: rgba(0,0,0,0.2);
  animation: cover-scan 1.2s ease-in-out infinite;
}

@keyframes cover-scan {
  0%   { left: -40%; }
  100% { left: 100%; }
}

/* No results */
.no-results {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--text-base);
}

/* ============================================================
   READER — LAYOUT
   ============================================================ */
#reader-view {
  position: fixed;
  inset: 0;
  background: var(--color-reader-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}

/* Reader Header */
.reader-header {
  position: relative;
  z-index: 10;
  height: var(--reader-header-height);
  background: var(--color-reader-bg);
  border-bottom: 1px solid var(--color-reader-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  flex-shrink: 0;
}

.reader-back {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-reader-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex-shrink: 0;
  transition: color var(--transition-fast);
  padding: var(--space-2) var(--space-3);
  margin-left: calc(-1 * var(--space-3));
}

.reader-back:hover {
  color: var(--color-reader-text);
}

.reader-title {
  flex: 1;
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--color-reader-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-page-indicator {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-reader-muted);
  flex-shrink: 0;
}

/* Reading progress bar */
.reading-progress {
  height: 2px;
  background: var(--color-accent);
  transition: width var(--transition-base);
  width: 0%;
  flex-shrink: 0;
}

/* Reader Stage */
.reader-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

/* Click zones */
.reader-click-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20%;
  z-index: 5;
  opacity: 0;
}

.reader-click-prev { left: 0; cursor: w-resize; }
.reader-click-next { right: 0; cursor: e-resize; }

/* ============================================================
   READER — BOOK
   ============================================================ */
.reader-book-viewport {
  perspective: 2000px;
  perspective-origin: 50% 50%;
  position: relative;
  /* Size is set dynamically by JS */
}

.reader-book {
  position: relative;
  display: flex;
  transform-style: preserve-3d;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.8);
}

/* Page halves */
.book-page {
  width: 50%;
  position: relative;
  overflow: hidden;
  background: #f0ebe3;
}

.book-page canvas {
  width: 100%;
  height: auto;
  display: block;
}

.page-blank {
  position: absolute;
  inset: 0;
  background: #f5f2ee;
}

.book-page-left .page-blank {
  background: linear-gradient(to right, #f0ebe3, #f5f2ee);
}

.book-page-right .page-blank {
  background: linear-gradient(to left, #f0ebe3, #f5f2ee);
}

/* Spine */
.book-spine {
  width: 4px;
  flex-shrink: 0;
  background: linear-gradient(to right, #888, #ccc, #888);
  position: relative;
  z-index: 2;
}

/* ============================================================
   READER — FLIP CARD (3D page turn)
   ============================================================ */
.flip-card {
  position: absolute;
  top: 0;
  height: 100%;
  /* width is set by JS to match one page-half */
  transform-style: preserve-3d;
  pointer-events: none;
  z-index: 10;
  will-change: transform;
}

.flip-card[data-dir="forward"] {
  right: 0;
  transform-origin: left center;
}

.flip-card[data-dir="backward"] {
  left: 0;
  transform-origin: right center;
}

.flip-card.is-flipping {
  transition: transform var(--transition-flip);
}

.flip-card[data-dir="forward"].is-flipping {
  transform: rotateY(-180deg);
}

.flip-card[data-dir="backward"].is-flipping {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.flip-face canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.flip-face-back {
  transform: rotateY(180deg);
}

/* Shadow overlays during flip */
.flip-shadow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.flip-shadow-front {
  background: linear-gradient(to left, rgba(0,0,0,0) 60%, rgba(0,0,0,0.2) 100%);
  opacity: 0;
  transition: opacity var(--transition-flip);
}

.flip-shadow-back {
  background: linear-gradient(to right, rgba(0,0,0,0) 60%, rgba(0,0,0,0.2) 100%);
  opacity: 0;
  transition: opacity var(--transition-flip);
}

.flip-card.is-flipping .flip-shadow-front,
.flip-card.is-flipping .flip-shadow-back {
  opacity: 1;
}

/* ============================================================
   READER — BOTTOM TOOLBAR
   ============================================================ */
.reader-toolbar {
  height: var(--reader-toolbar-height);
  background: var(--color-reader-toolbar);
  border-top: 1px solid var(--color-reader-border);
  flex-shrink: 0;
  transform: translateY(0);
  transition: transform var(--transition-base);
}

.toolbar-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 100%;
  padding: 0 var(--space-6);
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.toolbar-center {
  flex: 1;
  padding: 0 var(--space-6);
}

.toolbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-reader-muted);
  border-radius: 2px;
  transition: color var(--transition-fast), background var(--transition-fast);
  text-decoration: none;
}

.toolbar-btn:hover,
.toolbar-btn[aria-pressed="true"] {
  color: var(--color-reader-text);
  background: rgba(255,255,255,0.08);
}

/* Page scrubber */
.page-scrubber {
  width: 100%;
  height: 2px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-reader-border);
  outline: none;
  cursor: pointer;
  border-radius: 1px;
}

.page-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-reader-text);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.page-scrubber::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

.page-scrubber::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-reader-text);
  border: none;
  cursor: pointer;
}

/* ============================================================
   READER — THUMBNAIL SIDEBAR
   ============================================================ */
.reader-thumbnails {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 160px;
  background: rgba(0,0,0,0.85);
  border-left: 1px solid var(--color-reader-border);
  overflow-y: auto;
  z-index: 20;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}

.reader-thumbnails::-webkit-scrollbar { width: 4px; }
.reader-thumbnails::-webkit-scrollbar-track { background: transparent; }
.reader-thumbnails::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

.thumbnails-list {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.thumbnail-item {
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  transition: border-color var(--transition-fast);
}

.thumbnail-item:hover,
.thumbnail-item.active {
  border-color: var(--color-accent);
}

.thumbnail-item canvas {
  width: 100%;
  display: block;
}

.thumbnail-num {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 9px;
  color: rgba(255,255,255,0.6);
  line-height: 1;
}

/* ============================================================
   RELATED CATALOGS
   ============================================================ */
.related-catalogs {
  position: absolute;
  bottom: calc(var(--reader-toolbar-height) + var(--space-8));
  left: 50%;
  transform: translateX(-50%);
  width: min(90vw, 800px);
  background: rgba(0,0,0,0.9);
  border: 1px solid var(--color-reader-border);
  padding: var(--space-6) var(--space-8);
  z-index: 15;
}

.related-title {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-reader-muted);
  margin-bottom: var(--space-4);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.related-card {
  cursor: pointer;
  padding: var(--space-3);
  border: 1px solid var(--color-reader-border);
  transition: border-color var(--transition-fast);
}

.related-card:hover {
  border-color: rgba(255,255,255,0.3);
}

.related-card-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-reader-text);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-1);
}

.related-card-cat {
  font-size: var(--text-xs);
  color: var(--color-reader-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================
   KEYBOARD SHORTCUTS OVERLAY
   ============================================================ */
.shortcuts-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shortcuts-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}

.shortcuts-content {
  position: relative;
  background: var(--color-bg);
  padding: var(--space-8) var(--space-10);
  min-width: 360px;
  max-width: 90vw;
}

.shortcuts-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-6);
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  line-height: 1;
  transition: color var(--transition-fast);
}

.shortcuts-close:hover {
  color: var(--color-text);
}

.shortcuts-heading {
  font-size: var(--text-base);
  font-weight: 900;
  letter-spacing: var(--tracking-tight);
  text-transform: uppercase;
  margin-bottom: var(--space-6);
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.shortcut-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
}

.shortcut-row dt {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
  min-width: 80px;
}

.shortcut-row dd {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

kbd {
  font-family: var(--font-primary);
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 2px 6px;
  display: inline-block;
  letter-spacing: 0;
}

/* ============================================================
   LOADING OVERLAY (for PDF loading)
   ============================================================ */
.pdf-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  background: var(--color-reader-bg);
  z-index: 50;
}

/* Animated book icon */
.pdf-loading-book {
  width: 56px;
  height: 44px;
  position: relative;
}

.pdf-loading-book .book-spine {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 4px;
  height: 100%;
  background: var(--color-accent);
  border-radius: 1px;
  z-index: 2;
}

.pdf-loading-book .book-page {
  position: absolute;
  top: 2px;
  width: 24px;
  height: 40px;
  background: #f0ede8;
  border-radius: 1px 3px 3px 1px;
  transform-origin: left center;
  animation: page-flip 1.4s ease-in-out infinite;
}

.pdf-loading-book .book-page:nth-child(2) { left: 28px; transform-origin: left center; border-radius: 3px 1px 1px 3px; animation: page-flip-right 1.4s ease-in-out infinite; }
.pdf-loading-book .book-page:nth-child(3) { left: 4px; animation-delay: 0.2s; background: #e8e4de; }
.pdf-loading-book .book-page:nth-child(4) { left: 28px; animation-delay: 0.2s; background: #e8e4de; border-radius: 3px 1px 1px 3px; animation: page-flip-right 1.4s ease-in-out infinite; animation-delay: 0.2s; }

@keyframes page-flip {
  0%, 30%  { transform: rotateY(0deg); }
  60%, 100% { transform: rotateY(-30deg); }
}

@keyframes page-flip-right {
  0%, 30%  { transform: rotateY(0deg); }
  60%, 100% { transform: rotateY(30deg); }
}

.pdf-loading-label {
  font-size: var(--text-sm);
  color: var(--color-reader-muted);
  letter-spacing: 0.04em;
}

.pdf-loading-bar-track {
  width: 160px;
  height: 2px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.pdf-loading-bar {
  height: 100%;
  background: var(--color-accent);
  width: 0%;
  transition: width 300ms ease;
  border-radius: 2px;
}

.pdf-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  color: var(--color-reader-muted);
  font-size: var(--text-sm);
  padding: var(--space-8);
  text-align: center;
}

.pdf-error strong {
  color: var(--color-reader-text);
  font-size: var(--text-base);
  font-weight: 700;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .catalog-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-title {
    font-size: var(--text-3xl);
  }
}

@media (max-width: 768px) {
  .header-inner {
    padding: 0 var(--space-4);
    gap: var(--space-4);
  }

  .site-nav {
    display: none;
  }

  .search-input {
    width: 120px;
  }

  .sort-select {
    display: none;
  }

  .catalog-grid {
    grid-template-columns: 1fr;
    padding: var(--space-4);
    gap: var(--space-8);
  }

  .hero-card {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-cover-placeholder {
    min-height: 280px;
  }

  .hero-info {
    padding: var(--space-6);
  }

  .hero-title {
    font-size: var(--text-2xl);
  }

  .hero-section {
    padding: var(--space-6) var(--space-4) 0;
  }

  /* Single page mode on mobile */
  .book-page-left {
    display: none;
  }

  .book-page-right {
    width: 100%;
  }

  .book-spine {
    display: none;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }

  .reader-thumbnails {
    width: 120px;
  }

  .toolbar-center {
    padding: 0 var(--space-3);
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .flip-card.is-flipping {
    transition: none !important;
  }

  .flip-card {
    transition: none !important;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
