/* ═══════════════════════════════════════════
   READING ROOM — Design System
   Private library study room aesthetic
   Dark amber/sepia palette + editorial typography
   ═══════════════════════════════════════════ */

/* ─── Fonts ─── */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400;1,600&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&display=swap');

/* ─── CSS Custom Properties ─── */
:root {
  /* Dark theme (default) — warm study room */
  --color-bg: oklch(13% 0.012 55);
  --color-bg-alt: oklch(16% 0.010 50);
  --color-surface: oklch(18% 0.012 50);
  --color-surface-hover: oklch(21% 0.012 48);
  --color-surface-elevated: oklch(23% 0.010 45);
  --color-border: oklch(30% 0.015 50);
  --color-border-subtle: oklch(22% 0.008 45);

  --color-text: oklch(88% 0.010 55);
  --color-text-secondary: oklch(65% 0.020 50);
  --color-text-muted: oklch(48% 0.015 50);
  --color-text-inverse: oklch(12% 0.010 55);

  --color-accent: oklch(62% 0.13 55);
  --color-accent-glow: oklch(62% 0.13 55 / 0.15);
  --color-accent-subtle: oklch(52% 0.07 45);
  --color-accent-secondary: oklch(55% 0.10 340); /* rose */

  --color-success: oklch(58% 0.12 145);
  --color-warning: oklch(68% 0.12 75);

  /* Typography */
  --font-serif: 'Crimson Text', 'Noto Serif SC', 'SimSun', serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --text-xs: clamp(0.7rem, 0.68rem + 0.1vw, 0.75rem);
  --text-sm: clamp(0.8rem, 0.78rem + 0.1vw, 0.875rem);
  --text-base: clamp(0.95rem, 0.92rem + 0.15vw, 1.05rem);
  --text-lg: clamp(1.1rem, 1.04rem + 0.3vw, 1.25rem);
  --text-xl: clamp(1.35rem, 1.22rem + 0.65vw, 1.75rem);
  --text-2xl: clamp(1.75rem, 1.5rem + 1.25vw, 2.5rem);
  --text-3xl: clamp(2.25rem, 1.8rem + 2.25vw, 3.75rem);

  /* Motion */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --transition-fast: 150ms var(--ease-out-expo);
  --transition-base: 300ms var(--ease-out-quart);
  --transition-slow: 500ms var(--ease-out-quart);

  /* Spacing */
  --space-xs: clamp(0.25rem, 0.23rem + 0.1vw, 0.375rem);
  --space-sm: clamp(0.5rem, 0.45rem + 0.25vw, 0.75rem);
  --space-md: clamp(1rem, 0.9rem + 0.5vw, 1.5rem);
  --space-lg: clamp(1.5rem, 1.3rem + 1vw, 2.5rem);
  --space-xl: clamp(2.5rem, 2rem + 2.5vw, 5rem);
  --space-2xl: clamp(4rem, 3rem + 5vw, 8rem);

  /* Layout */
  --max-width: 72rem;
  --content-width: 48rem;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
}

/* ─── Light theme ─── */
[data-theme="light"] {
  --color-bg: oklch(95% 0.008 55);
  --color-bg-alt: oklch(92% 0.006 50);
  --color-surface: oklch(98% 0.005 55);
  --color-surface-hover: oklch(94% 0.008 50);
  --color-surface-elevated: oklch(100% 0 0);
  --color-border: oklch(85% 0.015 50);
  --color-border-subtle: oklch(90% 0.008 45);

  --color-text: oklch(15% 0.010 55);
  --color-text-secondary: oklch(35% 0.020 50);
  --color-text-muted: oklch(50% 0.015 50);
  --color-text-inverse: oklch(92% 0.006 55);

  --color-accent-glow: oklch(62% 0.13 55 / 0.08);
}

/* ─── Page Loader ─── */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  transition: opacity 0.5s var(--ease-out-quart), visibility 0.5s;
}
.page-loader.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loader-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}
.loader-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--color-border-subtle);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: loader-spin 0.8s linear infinite;
}
.loader-text {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-style: italic;
  color: var(--color-text-secondary);
  letter-spacing: 0.08em;
  animation: loader-pulse 1.6s ease-in-out infinite;
}
@keyframes loader-spin {
  to { transform: rotate(360deg); }
}
@keyframes loader-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background var(--transition-slow), color var(--transition-slow);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Typography ─── */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { margin-bottom: var(--space-md); }

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: oklch(72% 0.14 55); }

.font-sans { font-family: var(--font-sans); }

/* ─── Layout ─── */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.content-container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* ─── Navigation ─── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: oklch(13% 0.012 55 / 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--color-border-subtle);
  transition: background var(--transition-slow), border-color var(--transition-slow);
}

[data-theme="light"] .nav {
  background: oklch(95% 0.008 55 / 0.85);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
  height: 56px;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.nav-link {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  letter-spacing: 0.01em;
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-accent);
  background: var(--color-accent-glow);
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: var(--space-xs);
}

.theme-toggle:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ─── Hero Section ─── */
.hero {
  padding: var(--space-2xl) 0 var(--space-xl);
  text-align: center;
}

.hero-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-accent);
  background: var(--color-accent-glow);
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--space-lg);
}

.hero-title {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-md);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero-title em {
  font-style: italic;
  color: var(--color-accent);
}

.hero-subtitle {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: 300;
  color: var(--color-text-secondary);
  max-width: 32em;
  margin: 0 auto var(--space-xl);
  line-height: 1.6;
}

/* ─── Stat Cards ─── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-md);
  max-width: var(--content-width);
  margin: 0 auto;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  transition: all var(--transition-base);
}

.stat-card:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border);
  transform: translateY(-2px);
}

.stat-value {
  display: block;
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ─── Section ─── */
.section {
  padding: var(--space-xl) 0;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.section-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
}

.section-more {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}
.section-more:hover { color: var(--color-accent); }

/* ─── Book Grid ─── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-md);
}

.book-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition-base);
  cursor: pointer;
  position: relative;
}

.book-card:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px oklch(0% 0 0 / 0.3);
}

.book-cover {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--color-bg-alt);
  display: block;
}

.book-info {
  padding: var(--space-sm);
}

.book-title {
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.book-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}

.book-badge.finished {
  background: oklch(58% 0.12 145 / 0.2);
  color: var(--color-success);
}

/* ─── Filters ─── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.filter-btn {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 400;
  padding: 6px 18px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 20px;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.filter-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-inverse);
}

/* ─── Book Detail Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: oklch(0% 0 0 / 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

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

.modal {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: var(--space-lg);
  transform: translateY(24px) scale(0.96);
  transition: transform var(--transition-base);
}

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

.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition-fast);
  z-index: 10;
}

.modal-close:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.modal-header {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.modal-cover {
  width: 80px;
  height: 108px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.modal-info h3 {
  font-size: var(--text-lg);
  margin-bottom: 4px;
}

.modal-info .modal-author {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.modal-meta {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* ─── Stats Charts ─── */
.chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.chart-title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--space-xs);
  height: 180px;
  padding-top: var(--space-md);
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.bar-value {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--color-text-muted);
}

.bar {
  width: 100%;
  max-width: 48px;
  background: var(--color-accent);
  border-radius: 4px 4px 0 0;
  transition: height var(--transition-slow);
  min-height: 4px;
  position: relative;
  overflow: hidden;
}

.bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(to bottom, oklch(100% 0 0 / 0.12), transparent);
  border-radius: 4px 4px 0 0;
}

.bar-label {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: center;
}

/* ─── Notebook list ─── */
.notebook-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.notebook-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.notebook-item:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border);
  transform: translateX(4px);
}

.notebook-cover {
  width: 48px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.notebook-info {
  flex: 1;
  min-width: 0;
}

.notebook-title {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notebook-author {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.notebook-stats {
  display: flex;
  gap: var(--space-md);
  flex-shrink: 0;
  text-align: right;
}

.notebook-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.notebook-stat-value {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
}

.notebook-stat-label {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

/* ─── Pagination ─── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

.page-btn {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: 8px 16px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
.page-btn.active { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-text-inverse); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ─── Category tags ─── */
.category-tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--color-accent-glow);
  color: var(--color-accent);
  border: 1px solid oklch(62% 0.13 55 / 0.15);
}

/* ─── About page ─── */
.about-section {
  max-width: var(--content-width);
  margin: 0 auto;
}

.about-lede {
  font-size: var(--text-lg);
  font-style: italic;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-xl);
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state-text {
  font-family: var(--font-sans);
  font-size: var(--text-base);
}

/* ─── Footer ─── */
.footer {
  margin-top: auto;
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--color-border-subtle);
  text-align: center;
}

.footer-text {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ─── Animations ─── */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fade-in-up 600ms var(--ease-out-quart) both;
}

/* Stagger children */
.stagger > * {
  opacity: 0;
  animation: fade-in-up 500ms var(--ease-out-quart) forwards;
}

.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }
.stagger > *:nth-child(7) { animation-delay: 350ms; }
.stagger > *:nth-child(8) { animation-delay: 400ms; }
.stagger > *:nth-child(9) { animation-delay: 440ms; }
.stagger > *:nth-child(10) { animation-delay: 480ms; }
.stagger > *:nth-child(n+11) { animation-delay: 520ms; }

/* ─── Progress bar ─── */
.progress-bar {
  height: 4px;
  background: var(--color-border-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  transition: width var(--transition-slow);
}

/* ─── Reading time overview ─── */
.time-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.time-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.time-card-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-xs);
}

.time-card-value {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.time-card-sub {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ─── Media Queries ─── */
@media (max-width: 640px) {
  .nav-inner {
    height: 48px;
  }

  .nav-links {
    gap: 2px;
  }

  .nav-link {
    padding: 4px 10px;
    font-size: 12px;
  }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-sm);
  }

  .hero {
    padding: var(--space-xl) 0 var(--space-lg);
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .notebook-stats {
    display: none;
  }

  .bar-chart {
    height: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════
   PHASE 2+3 — Dashboard & Visual Upgrades
   ═══════════════════════════════════════════ */

/* ─── Reading Progress Bar ─── */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), oklch(62% 0.18 40));
  z-index: 200;
  transition: width 150ms linear;
  pointer-events: none;
}

/* ─── Back to Top ─── */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  z-index: 150;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 300ms var(--ease-out-quart);
  box-shadow: 0 4px 16px oklch(0% 0 0 / 0.3);
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-inverse);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px oklch(62% 0.13 55 / 0.3);
}

/* ─── Glass Stat Card ─── */
.glass-card {
  background: oklch(18% 0.012 50 / 0.6);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid oklch(100% 0 0 / 0.08);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}
.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top left, oklch(62% 0.13 55 / 0.06), transparent 70%);
  pointer-events: none;
}
.glass-card:hover {
  border-color: oklch(100% 0 0 / 0.15);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px oklch(0% 0 0 / 0.3);
}

[data-theme="light"] .glass-card {
  background: oklch(98% 0.005 55 / 0.6);
  border-color: oklch(0% 0 0 / 0.06);
}

/* ─── Stats Row (glass upgrade) ─── */
.stats-row.glass .stat-card {
  background: oklch(18% 0.012 50 / 0.5);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-color: oklch(100% 0 0 / 0.07);
}
[data-theme="light"] .stats-row.glass .stat-card {
  background: oklch(98% 0.005 55 / 0.5);
  border-color: oklch(0% 0 0 / 0.05);
}

/* ─── Heatmap ─── */
.heatmap-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.heatmap-title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.heatmap-summary {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.heatmap-summary strong {
  color: var(--color-accent);
  font-weight: 600;
}
.heatmap-grid {
  display: flex;
  gap: 3px;
}
.heatmap-week-column {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.heatmap-week-labels {
  display: flex;
  gap: 3px;
  margin-bottom: 4px;
  padding-left: 12px;
}
.heatmap-week-label {
  font-family: var(--font-sans);
  font-size: 9px;
  color: var(--color-text-muted);
  text-align: center;
}
.heatmap-month-labels {
  display: flex;
  gap: 2px;
  padding-left: 12px;
  margin-bottom: 8px;
}
.heatmap-month-label {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}
.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 150ms ease;
  position: relative;
}
.heatmap-cell:hover {
  transform: scale(1.4);
  z-index: 10;
  box-shadow: 0 2px 8px oklch(0% 0 0 / 0.4);
  outline: 1px solid oklch(100% 0 0 / 0.2);
  outline-offset: 1px;
}
.heatmap-cell.level-0 { background: oklch(22% 0.008 45 / 0.4); }
.heatmap-cell.level-1 { background: oklch(48% 0.08 55 / 0.3); }
.heatmap-cell.level-2 { background: oklch(52% 0.09 50 / 0.5); }
.heatmap-cell.level-3 { background: oklch(58% 0.11 50 / 0.7); }
.heatmap-cell.level-4 { background: oklch(62% 0.13 50); }
.heatmap-cell.level-5 { background: oklch(66% 0.14 45); }

[data-theme="light"] .heatmap-cell.level-0 { background: oklch(92% 0.006 50 / 0.5); }
[data-theme="light"] .heatmap-cell.level-1 { background: oklch(78% 0.05 55 / 0.4); }
[data-theme="light"] .heatmap-cell.level-2 { background: oklch(70% 0.07 50 / 0.5); }
[data-theme="light"] .heatmap-cell.level-3 { background: oklch(62% 0.10 50 / 0.65); }
[data-theme="light"] .heatmap-cell.level-4 { background: oklch(58% 0.12 50 / 0.8); }
[data-theme="light"] .heatmap-cell.level-5 { background: oklch(52% 0.13 45); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-sm);
}
.heatmap-legend span {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--color-text-muted);
  margin: 0 4px;
}
.heatmap-legend .heatmap-cell { cursor: default; }
.heatmap-legend .heatmap-cell:hover { transform: none; outline: none; }

.heatmap-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--color-text);
  white-space: nowrap;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 4px 16px oklch(0% 0 0 / 0.4);
}
.heatmap-cell:hover .heatmap-tooltip { display: block; }

/* ─── Monthly Trend Cards ─── */
.trend-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
}
.trend-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}
.trend-card:hover {
  border-color: var(--color-border);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px oklch(0% 0 0 / 0.2);
}
.trend-card-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-xs);
}
.trend-card-value {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}
.trend-card-sub {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}
.trend-sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
}
.trend-bar {
  flex: 1;
  background: var(--color-accent);
  border-radius: 1px 1px 0 0;
  min-height: 2px;
  transition: height 500ms var(--ease-out-quart);
  position: relative;
}
.trend-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 30%;
  background: oklch(100% 0 0 / 0.1);
  border-radius: 1px 1px 0 0;
}
.trend-bar.low { opacity: 0.4; }
.trend-bar.peak { background: oklch(68% 0.16 45); }

/* ─── Book Progress Card ─── */
.reading-now-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md);
}
.reading-now-card {
  display: flex;
  gap: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  transition: all var(--transition-base);
  overflow: hidden;
  position: relative;
}
.reading-now-card:hover {
  border-color: var(--color-border);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px oklch(0% 0 0 / 0.2);
}
.reading-now-cover {
  width: 56px;
  height: 76px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: 0 2px 8px oklch(0% 0 0 / 0.3);
}
.reading-now-info {
  flex: 1;
  min-width: 0;
}
.reading-now-title {
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reading-now-author {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}
.reading-now-progress {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.reading-now-pct {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-accent);
  min-width: 36px;
}
.reading-now-bar {
  flex: 1;
  height: 4px;
  background: var(--color-border-subtle);
  border-radius: 2px;
  overflow: hidden;
}
.reading-now-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  transition: width 800ms var(--ease-out-quart);
}

/* ─── Highlight Quote Card ─── */
.highlight-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-md);
  transition: all var(--transition-base);
  position: relative;
}
.highlight-card:hover {
  border-color: var(--color-border);
  border-left-color: oklch(72% 0.14 55);
  transform: translateX(4px);
  box-shadow: 0 4px 16px oklch(0% 0 0 / 0.2);
}
.highlight-text {
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--color-text);
  line-height: 1.6;
  margin-bottom: var(--space-xs);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.highlight-source {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.highlight-source .book-icon {
  font-size: 12px;
}
.highlights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-sm);
}

/* ─── Year Progress Ring ─── */
.year-progress-section {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
  justify-content: center;
}
.year-progress-ring {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.year-progress-ring svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}
.year-progress-bg {
  fill: none;
  stroke: var(--color-border-subtle);
  stroke-width: 6;
}
.year-progress-fill {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s var(--ease-out-quart);
}
.year-progress-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.year-progress-pct {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
}
.year-progress-label {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.year-progress-info {
  flex: 1;
  min-width: 200px;
}

/* ─── Weekday Distribution ─── */
.weekday-bars {
  display: flex;
  align-items: flex-end;
  gap: var(--space-xs);
  height: 80px;
  justify-content: center;
}
.weekday-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  max-width: 48px;
}
.weekday-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  transition: height 500ms var(--ease-out-quart);
  min-height: 4px;
}
.weekday-bar.high { background: oklch(62% 0.13 50); }
.weekday-bar.mid  { background: oklch(58% 0.08 50 / 0.7); }
.weekday-bar.low  { background: oklch(50% 0.05 50 / 0.4); }
.weekday-label {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--color-text-muted);
}

/* ─── Scroll Reveal ─── */
.scroll-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 600ms var(--ease-out-quart), transform 600ms var(--ease-out-quart);
}
.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Section Divider ─── */
.section-divider {
  width: 40px;
  height: 3px;
  background: var(--color-accent);
  border-radius: 2px;
  margin-bottom: var(--space-lg);
  opacity: 0.6;
}

/* ─── Enhanced Hero ─── */
.hero-subtitle strong {
  color: var(--color-accent);
  font-weight: 600;
}
.hero-quote {
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--color-text-muted);
  opacity: 0.7;
  margin-top: var(--space-sm);
  border-left: 2px solid var(--color-accent);
  padding-left: var(--space-sm);
}

/* ─── Nav scroll shadow ─── */
.nav.scrolled {
  box-shadow: 0 1px 20px oklch(0% 0 0 / 0.3);
}
[data-theme="light"] .nav.scrolled {
  box-shadow: 0 1px 20px oklch(0% 0 0 / 0.06);
}

/* ─── Responsive: Dashboard ─── */
@media (max-width: 640px) {
  .heatmap-cell {
    width: 9px;
    height: 9px;
  }
  .heatmap-grid { gap: 2px; }
  .heatmap-week-column { gap: 2px; }
  .trend-cards {
    grid-template-columns: 1fr;
  }
  .reading-now-grid {
    grid-template-columns: 1fr;
  }
  .highlights-grid {
    grid-template-columns: 1fr;
  }
  .year-progress-section {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .back-to-top {
    bottom: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
  }
}
