/* ==========================================================================
   WeRead Console — Modern, Flat Editorial Design System v5.0
   Typographic Hierarchy • High Negative Space • Container-free Layout
   ========================================================================== */

/* ===== 0. Design Tokens ===== */
:root {
  /* Stone & Neutral Grays (Warm, Literary Tone) */
  --stone-50:  #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;

  /* Primary Accent — Crisp WeChat Read Blue */
  --primary-blue: #1b4fc6;
  --primary-active-bg: rgba(27, 79, 198, 0.06);
  --primary:       #1c1917; 
  --primary-soft:  #44403c;
  --primary-deep:  #0c0a09;
  --primary-bg:    #f5f5f4;
  --primary-ring:  #a8a29e;

  --menu-hover-color: var(--primary);
  --menu-hover-bg:    rgba(0, 0, 0, 0.02);

  /* Accent — Slate */
  --accent:       #0284c7;
  --accent-bg:    #f0f9ff;

  /* Notebook Badge Colors */
  --badge-highlight-color: #d97706;
  --badge-review-color: #059669;

  --badge-total-bg: color-mix(in srgb, var(--primary-blue) 8%, transparent);
  --badge-total-bg-hover: color-mix(in srgb, var(--primary-blue) 14%, transparent);
  --badge-total-color: var(--primary-blue);
  
  --badge-highlight-bg: color-mix(in srgb, var(--badge-highlight-color) 8%, transparent);
  --badge-highlight-bg-hover: color-mix(in srgb, var(--badge-highlight-color) 14%, transparent);
  
  --badge-review-bg: color-mix(in srgb, var(--badge-review-color) 8%, transparent);
  --badge-review-bg-hover: color-mix(in srgb, var(--badge-review-color) 14%, transparent);

  /* Semantic Colors */
  --success:  #16a34a;
  --danger:   #dc2626;
  --warning:  #d97706;

  /* Surfaces & Canvas (Warm paper feel) */
  --bg-body:     #fafaf9; 
  --bg-sidebar:  #f4f3ee; 
  --bg-card:     transparent; /* Grid panels sit directly on canvas */
  --bg-card-hover: transparent;
  --bg-input:    #ffffff;
  --bg-muted:    #f5f5f4;
  --bg-pill:     #e7e5e4;

  /* Text Hierarchy */
  --text-1: var(--stone-900);
  --text-2: var(--stone-600);
  --text-3: var(--stone-400);
  --text-inv: #ffffff;
  --text-inverted: #ffffff;

  /* Borders */
  --border:       #e2e0d9;
  --border-light: #e7e5e4;
  --border-focus: var(--stone-900);

  /* Typography Pairing */
  --font-sans:    'Plus Jakarta Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Lora', 'Noto Serif SC', Georgia, serif;

  /* Radius — Sharp and premium editorial corners */
  --r-xs:    2px;
  --r-sm:    2px;
  --r-md:    3px;
  --r-lg:    3px;
  --r-xl:    3px;
  --r-2xl:   3px;
  --r-full:  9999px;

  /* Snappy and purely flat transitions (NO translate or scale) */
  --ease:       cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast:   100ms;
  --dur:        180ms;
}

/* ===== 1. Base Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-1);
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.6;
  position: relative;
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--stone-200); }
::-webkit-scrollbar-thumb:hover { background: var(--stone-400); }

/* ===== 2. Layout Layout ===== */
.app-container {
  display: grid;
  grid-template-columns: 220px 1fr;
  width: 100vw;
  height: 100vh;
  padding: 0;
  gap: 0;
  z-index: 1;
}

/* ===== 3. Sidebar (Ivory, Clean Panel) ===== */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 40px 20px;
  height: 100%;
}

/* Sidebar Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 32px;
  cursor: default;
}

.brand-logo-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-1);
}

/* Navigation Menu */
.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.menu-item i {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  stroke-width: 1.8;
}

.menu-item:hover {
  color: var(--menu-hover-color);
  background: var(--menu-hover-bg);
}

.menu-item.active {
  color: var(--primary-blue);
  background: var(--primary-active-bg);
  font-weight: 600;
}

/* User Profile Section */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

/* User Profile Section */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.settings-footer-btn {
  width: 100%;
}

/* ===== 4. Main Content Canvas ===== */
.main-content {
  background: var(--bg-body);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

/* Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 40px 48px 24px;
  border-bottom: 1px solid var(--border);
}

.header-title h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.3px;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

/* Header stat columns (No Cards) */
.header-stats-row {
  display: flex;
  gap: 32px;
}

.header-stat-card {
  padding: 0;
  background: transparent;
  border: none;
  text-align: right;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header-stat-card:hover {
  border-color: transparent;
}

.header-stat-card .stat-label {
  display: block;
  font-size: 9px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  margin-bottom: 1px;
}

.header-stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
}

/* Content Body Context */
.content-body {
  padding: 40px 48px;
  flex: 1;
}

/* Tab Pane System */
.tab-pane {
  display: none;
  animation: fadeIn 0.2s var(--ease) forwards;
}

.tab-pane.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== 5. Layout Panels & Grid Boxes (Container-free) ===== */
.glass-card {
  background: var(--bg-card);
  border: none;
  border-radius: 0;
  padding: 0;
  transition: none;
}

.glass-card:hover {
  border-color: transparent;
}

/* Section Header styling inside grid sections */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.card-header h3 {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 6. Stats Grid (No Cards/Borders) ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 32px;
}

.stat-detail-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  min-height: auto;
  padding: 0;
  border: none;
  background: transparent;
}

.stat-detail-card:hover {
  border: none;
}

/* Remove card icons for minimalist pure text approach */
.stat-detail-card .card-icon {
  display: none;
}

.stat-detail-card .card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-detail-card .card-info h3 {
  font-size: 10px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.stat-detail-card .card-info h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.stat-detail-card .card-info .trend-text {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 4px;
}

.stat-detail-card .card-info .trend-up {
  color: var(--success);
  font-weight: 600;
}

.stat-detail-card .card-info .trend-down {
  color: var(--danger);
  font-weight: 600;
}

/* Clear highlight border effects */
.highlight-glow {
  border: none;
}
.highlight-glow:hover {
  border: none;
}

/* ===== 7. Dashboard Middle Section ===== */
.dashboard-mid-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 48px;
  margin-bottom: 48px;
}

.chart-card {
  display: flex;
  flex-direction: column;
  min-height: 260px;
}

/* Clean Toggles */
.chart-toggles {
  display: flex;
  gap: 12px;
  border: none;
  padding: 0;
}

.toggle-btn {
  padding: 2px 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  outline: none;
}

.toggle-btn:hover {
  color: var(--text-1);
}

.toggle-btn.active {
  background: transparent;
  color: var(--primary-blue);
  border-color: var(--primary-blue);
}

.badge {
  font-size: 9px;
  padding: 2px 6px;
  background: var(--stone-100);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xs);
  color: var(--text-2);
  font-weight: 500;
}

.chart-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 10px;
}

/* Bar Chart Graphic */
.bar-chart-wrapper {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  height: 180px;
  border-bottom: 1px solid var(--border-light);
  padding: 0 4px 4px;
}

.chart-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.chart-bar-fill {
  width: 35%;
  max-width: 8px;
  min-height: 1px;
  background: var(--stone-300);
  border-radius: 1px 1px 0 0;
  transition: background var(--dur) var(--ease);
}

.chart-bar-col:hover .chart-bar-fill {
  background: var(--primary-blue);
}

/* Tooltips — No translation/scale animations, clean layout box */
.chart-bar-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  background: var(--bg-body);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--r-xs);
  font-size: 9px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  color: var(--text-1);
  transition: opacity var(--dur-fast) var(--ease), visibility var(--dur-fast) var(--ease);
  z-index: 10;
  pointer-events: none;
}

.chart-bar-col:hover .chart-bar-tooltip {
  opacity: 1;
  visibility: visible;
}

.chart-bar-label {
  font-size: 8px;
  color: var(--text-3);
  margin-top: 6px;
}

/* Category Preferences List */
.pref-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.pref-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pref-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.pref-title { font-weight: 600; color: var(--text-1); }
.pref-value { color: var(--text-3); font-size: 10px; }

.pref-bar-bg {
  height: 2px;
  background: var(--stone-100);
  border-radius: var(--r-full);
}

.pref-bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--stone-800);
  transition: width 0.6s var(--ease);
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  gap: 8px;
  padding: 32px 16px;
}

.empty-state i {
  width: 20px;
  height: 20px;
  stroke-width: 1.5;
}

.empty-state p { font-size: 12px; }

/* ===== 8. Rankings + Habits Section (Clean Lines) ===== */
.dashboard-bottom-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 48px;
}

.rank-card, .habits-card { min-height: 220px; }

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}

.rank-item:last-child {
  border-bottom: none;
}

.rank-item:hover .rank-title {
  color: var(--primary-blue);
}

.rank-number {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--stone-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-3);
  flex-shrink: 0;
}

.rank-item:nth-child(1) .rank-number {
  background: var(--primary);
  color: var(--text-inv);
}

.rank-item:nth-child(2) .rank-number {
  background: var(--primary-blue);
  color: var(--text-inv);
}

.rank-item:nth-child(3) .rank-number {
  background: var(--stone-300);
  color: var(--stone-800);
}

.rank-cover {
  width: 24px;
  height: 34px;
  border-radius: var(--r-xs);
  object-fit: cover;
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

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

.rank-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--dur) var(--ease);
}

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

.rank-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}

/* Habits Info (Clean List) */
.habits-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.habit-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-light);
  transition: none;
}

.habit-item:last-child {
  border-bottom: none;
}

.habit-icon {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--stone-700);
  flex-shrink: 0;
}

.habit-icon i { width: 14px; height: 14px; }

.habit-content h4 {
  font-size: 9px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.habit-content p {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
}

/* ===== 9. Bookshelf Tab (Container-free) ===== */
.shelf-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  position: relative;
  flex: 1;
  max-width: 280px;
}

.search-box i {
  position: absolute;
  left: 10px;
  color: var(--text-3);
  width: 13px;
  height: 13px;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 6px 12px 6px 30px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-1);
  font-size: 12px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--dur) var(--ease);
}

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

.search-box input:focus {
  border-color: var(--stone-600);
}

/* Flat Text Filter Tabs */
.filter-tabs {
  display: flex;
  gap: 20px;
  border: none;
  padding: 0;
}

.filter-btn {
  padding: 4px 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  display: flex;
  align-items: center;
  gap: 6px;
  outline: none;
}

.filter-btn:hover {
  color: var(--text-1);
}

.filter-btn.active {
  background: transparent;
  color: var(--primary-blue);
  border-color: var(--primary-blue);
  font-weight: 600;
}

.filter-count {
  font-size: 9px;
  background: var(--stone-100);
  color: var(--stone-600);
  padding: 1px 6px;
  border-radius: var(--r-full);
  font-weight: 600;
}

.filter-btn.active .filter-count {
  background: var(--primary-blue);
  color: #ffffff;
}

/* Books Grid & Cards */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 24px;
}

.book-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.book-card-cover-wrapper {
  position: relative;
  aspect-ratio: 0.71;
  border-radius: var(--r-xs);
  overflow: hidden;
  border: 1px solid var(--border-light);
  margin-bottom: 8px;
  transition: border-color var(--dur) var(--ease);
}

.book-card:hover .book-card-cover-wrapper {
  border-color: var(--text-1);
}

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

.book-card-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--r-xs);
  padding: 2px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.book-card-badge i { width: 10px; height: 10px; }

.book-card-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(0, 0, 0, 0.05);
}

.book-card-progress-bar {
  height: 100%;
  background: var(--primary-blue);
}

.book-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.book-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 34px;
}

.book-card-author {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  font-size: 10px;
}

.book-card-category {
  color: var(--text-2);
  background: var(--stone-100);
  padding: 1px 4px;
  border-radius: var(--r-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.book-card-percentage {
  color: var(--primary-blue);
  font-weight: 600;
}

/* ===== 10. Notebooks Tab (Container-free) ===== */
.notes-header { margin-bottom: 20px; }

.notes-intro-text {
  font-size: 12px;
  color: var(--text-2);
}

.notes-intro-text strong {
  color: var(--primary);
}

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

.notebook-card {
  display: flex;
  gap: 16px;
  cursor: pointer;
  padding: 0;
  border: none;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 16px;
  background: transparent;
  transition: border-color var(--dur) var(--ease);
}

.notebook-card:hover {
  border-color: var(--stone-400);
}

.notebook-card:hover .notebook-title {
  color: var(--primary-blue);
}

.notebook-cover-wrapper {
  width: 48px;
  height: 68px;
  border-radius: var(--r-xs);
  overflow: hidden;
  border: 1px solid var(--border-light);
  flex-shrink: 0;
  transition: border-color var(--dur) var(--ease);
}

.notebook-card:hover .notebook-cover-wrapper {
  border-color: var(--text-1);
}

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

.notebook-details {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
}

.notebook-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  transition: color var(--dur) var(--ease);
}

.notebook-author {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.notebook-meta-stats {
  display: flex;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

.notebook-meta-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--stone-100);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--dur) var(--ease);
  border: 1px solid transparent;
}

.notebook-meta-badge i { 
  width: 12px; 
  height: 12px; 
}

.notebook-meta-badge.total {
  background: var(--badge-total-bg);
  color: var(--badge-total-color);
  font-weight: 600;
}

.notebook-meta-badge.highlight {
  background: var(--badge-highlight-bg);
  color: var(--badge-highlight-color);
}

.notebook-meta-badge.review {
  background: var(--badge-review-bg);
  color: var(--badge-review-color);
}

.notebook-card:hover .notebook-meta-badge.total {
  background: var(--badge-total-bg-hover);
}

.notebook-card:hover .notebook-meta-badge.highlight {
  background: var(--badge-highlight-bg-hover);
}

.notebook-card:hover .notebook-meta-badge.review {
  background: var(--badge-review-bg-hover);
}

/* ===== 11. Recommendations (Container-free) ===== */
.recommend-header {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.recommend-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
}

.recommend-header p {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

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

.recommend-item-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 10px;
  padding: 0;
  border: none;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 20px;
  cursor: pointer;
  background: transparent;
  transition: border-color var(--dur) var(--ease);
}

.recommend-item-card:hover {
  border-color: var(--stone-400);
}

.recommend-item-card:hover .recommend-title {
  color: var(--primary-blue);
}

.recommend-body-top {
  display: flex;
  gap: 12px;
}

.recommend-cover {
  width: 44px;
  height: 62px;
  border-radius: var(--r-xs);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
  transition: border-color var(--dur) var(--ease);
}

.recommend-item-card:hover .recommend-cover {
  border-color: var(--text-1);
}

.recommend-meta-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.recommend-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--dur) var(--ease);
}

.recommend-author {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recommend-rating {
  font-size: 10px;
  color: var(--primary-blue);
  font-weight: 600;
  margin-top: 2px;
}

.recommend-intro {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  flex: 1;
}

/* ===== 12. Modals (Flat, No Scales/Translations) ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}

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

.modal-container {
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-body);
  padding: 24px;
  box-shadow: none; /* Strip crazy box shadows */
  animation: modalIn var(--dur) var(--ease) forwards;
}

.modal-large { max-width: 600px; }

/* Flat opacity-only modal entry */
@keyframes modalIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-header { padding: 0 0 16px; border-bottom: 1px solid var(--border-light); margin-bottom: 16px; }

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
}

.modal-header .subtitle {
  font-size: 12px;
  color: var(--text-3);
  display: block;
  margin-top: 2px;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  z-index: 10;
}

.close-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.close-btn i { width: 12px; height: 12px; }

/* Book Detail Inside Modal */
.book-details-modal-wrapper {
  display: flex;
  gap: 20px;
}

.book-details-cover {
  width: 84px;
  height: 118px;
  border-radius: var(--r-xs);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
}

.book-details-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.book-details-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
}

.book-details-author {
  font-size: 12px;
  color: var(--text-2);
}

.book-details-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.book-details-desc-box {
  margin-top: 20px;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
}

.book-details-desc-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.book-details-desc-text {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
}

.book-details-action-bar {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
}

/* Flat Premium Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--r-xs);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  outline: none;
}

.btn i {
  width: 13px;
  height: 13px;
}

.btn-primary {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: var(--text-inv);
}

.btn-primary:hover {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-1);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Notes Viewer List in Modal */
.notes-list-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 8px;
}

.notes-chapter-group {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 16px;
}

.notes-chapter-group:last-child { border-bottom: none; }

.notes-chapter-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-blue);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.notes-chapter-title i { width: 12px; height: 12px; }

.note-item-box {
  margin-left: 0;
  margin-bottom: 8px;
  padding: 12px 16px;
  background: var(--stone-50);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-xs);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--dur) var(--ease);
}

.note-item-box:hover {
  border-color: var(--stone-300);
}

.note-mark-text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-2);
  font-style: italic;
}

.note-thought-text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--stone-100);
  padding: 8px 12px;
  border-radius: var(--r-xs);
  border: 1px dashed var(--stone-300);
}

.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
}

.note-deep-link {
  color: var(--primary-blue);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.note-deep-link i { width: 10px; height: 10px; }
.note-deep-link:hover { text-decoration: underline; }

/* ===== 13. Synchronizing Page loading overlay ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-body);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity var(--dur) var(--ease);
}

.loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loader-wrapper .brand-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
}

.progress-bar-container {
  width: 140px;
  height: 2px;
  background: var(--stone-200);
  border-radius: var(--r-full);
  overflow: hidden;
  position: relative;
}

.loading-progress-bar {
  position: absolute;
  width: 35%;
  height: 100%;
  background: var(--primary-blue);
  border-radius: var(--r-full);
  animation: progressSlide 1.5s infinite cubic-bezier(0.65, 0.05, 0.36, 1);
}

@keyframes progressSlide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(300%); }
}

.loading-text {
  font-size: 11px;
  color: var(--text-3);
}

/* ===== 14. Top Progress bar (No Translate Animations) ===== */
.top-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary-blue);
  z-index: 10001;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.top-loading-bar.active {
  opacity: 1;
  animation: topBarLoading 1.5s infinite ease-in-out;
}

@keyframes topBarLoading {
  0%   { left: 0; width: 0%; }
  50%  { left: 0; width: 100%; }
  100% { left: 100%; width: 0%; }
}

/* ===== 15. Shimmer Skeletons ===== */
.skeleton {
  background: linear-gradient(90deg, var(--stone-100) 25%, var(--stone-50) 37%, var(--stone-100) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-xs);
  display: inline-block;
}

@keyframes shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.skeleton-text { height: 10px; margin: 3px 0; width: 100%; }
.skeleton-title { height: 14px; margin: 4px 0; width: 70%; }
.skeleton-circle { border-radius: 50% !important; }

/* ===== 16. Toasts (Flat Opacity-only entrance) ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10000;
}

.toast {
  padding: 10px 16px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-1);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  animation: toastIn var(--dur) var(--ease) forwards;
  min-width: 200px;
  max-width: 320px;
}

@keyframes toastIn {
  to { opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; }
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }

.toast.success i { color: var(--success); width: 13px; height: 13px; flex-shrink: 0; }
.toast.error i { color: var(--danger); width: 13px; height: 13px; flex-shrink: 0; }

/* ===== 17. Responsive Rules ===== */
@media (max-width: 1050px) {
  .dashboard-mid-grid,
  .dashboard-bottom-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

@media (max-width: 960px) {
  .stats-grid { 
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
  }

  .sidebar { display: none; }

  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 24px 24px 16px;
  }

  .header-stats-row { width: 100%; overflow-x: auto; gap: 20px; }

  .content-body { padding: 24px 24px; }

  .stats-grid { grid-template-columns: 1fr; gap: 20px; }

  .dashboard-mid-grid,
  .dashboard-bottom-grid { grid-template-columns: 1fr; gap: 32px; }

  .shelf-controls { flex-direction: column; align-items: stretch; gap: 12px; }
  .search-box { max-width: 100%; }
}

/* ===== 18. Settings Modal, Inputs, Toggles & Themes Grid ===== */
.modal-medium {
  max-width: 460px;
}
.settings-body-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 10px;
}
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-section h3 {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.section-hint {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.4;
}
.api-key-input-wrapper {
  display: flex;
  position: relative;
  align-items: center;
  width: 100%;
}
.api-key-input-wrapper input {
  width: 100%;
  padding: 8px 36px 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-1);
  font-size: 12px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--dur) var(--ease);
}
.api-key-input-wrapper input:focus {
  border-color: var(--stone-600);
}
.toggle-pwd-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color var(--dur) var(--ease);
  outline: none;
}
.toggle-pwd-btn:hover {
  color: var(--text-1);
}
.toggle-pwd-btn i {
  width: 14px;
  height: 14px;
}

/* Appearance Toggles */
.appearance-toggles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mode-select-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  outline: none;
}
.mode-select-btn:hover {
  border-color: var(--stone-500);
  color: var(--text-1);
}
.mode-select-btn.active {
  background: var(--primary-active-bg);
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  font-weight: 600;
}
.mode-select-btn i {
  width: 14px;
  height: 14px;
}

/* Language Toggles */
.language-toggles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
.lang-select-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  outline: none;
}
.lang-select-btn:hover {
  border-color: var(--stone-500);
  color: var(--text-1);
}
.lang-select-btn.active {
  background: var(--primary-active-bg);
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  font-weight: 600;
}

/* API Key Help Helper */
.api-key-help-container {
  margin-top: 8px;
}
.help-toggle-btn {
  background: transparent;
  border: none;
  color: var(--primary-blue);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 0;
  outline: none;
}
.help-toggle-btn i {
  width: 12px;
  height: 12px;
  stroke-width: 2.2;
}
.help-toggle-btn:hover {
  text-decoration: underline;
}
.help-content-box {
  display: none;
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xs);
  padding: 12px 14px;
  margin-top: 8px;
  animation: fadeIn 0.2s var(--ease) forwards;
}
.help-content-box.active {
  display: block;
}
.help-intro {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 8px;
}
.help-link-wrapper {
  margin-bottom: 12px;
}
.help-action-link {
  color: var(--primary-blue);
  text-decoration: none;
  font-weight: 600;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.help-action-link:hover {
  text-decoration: underline;
}
.help-action-link i {
  width: 12px;
  height: 12px;
  stroke-width: 2.2;
}
.help-instruction-img {
  width: 100%;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  display: block;
}

/* API Key Missing Input Alert */
.input-alert {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2) !important;
}

/* Theme Option Grid */
.theme-select-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.theme-option-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  text-align: left;
  outline: none;
}
.theme-option-btn:hover {
  border-color: var(--stone-500);
  color: var(--text-1);
}
.theme-option-btn.active {
  background: var(--primary-active-bg);
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  font-weight: 600;
}
.theme-preview-color {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.theme-option-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


