@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap');

:root {
  /* Colors */
  --bg-dark: #080710;
  --bg-card: rgba(25, 22, 60, 0.45);
  --bg-card-hover: rgba(35, 30, 80, 0.65);
  --border-color: rgba(139, 92, 246, 0.2);
  --border-hover: rgba(139, 92, 246, 0.45);
  
  --primary: #8b5cf6;       /* Violet */
  --primary-hover: #a78bfa;
  --secondary: #06b6d4;     /* Cyan */
  --accent: #ec4899;        /* Pink */
  
  --text-main: #f3f4f6;     /* White/Gray */
  --text-muted: #9ca3af;    /* Gray */
  --text-glow: 0 0 8px rgba(139, 92, 246, 0.6);
  
  /* Fonts */
  --font-ui: 'Outfit', sans-serif;
  --font-reader: 'Playfair Display', serif;
  
  /* Spacing & Borders */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Reader Specific */
  --reader-bg: #fdfaf2;
  --reader-text: #2c2520;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) rgba(255, 255, 255, 0.05);
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

*::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Glassmorphism utility */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: border var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.glass-hover:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: 0 8px 32px 0 rgba(139, 92, 246, 0.15);
  transform: translateY(-2px);
}

/* Header & Nav */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5%;
  background: rgba(8, 7, 16, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.logo span {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
}

nav {
  display: flex;
  gap: 32px;
}

nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color var(--transition-fast), text-shadow var(--transition-fast);
  cursor: pointer;
  position: relative;
  padding: 4px 0;
}

nav a:hover, nav a.active {
  color: var(--text-main);
  text-shadow: var(--text-glow);
}

nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width var(--transition-normal);
}

nav a:hover::after, nav a.active::after {
  width: 100%;
}

.auth-btn-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Buttons */
.btn {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
  background: linear-gradient(135deg, #9333ea 0%, #6d28d9 100%);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.btn-accent {
  background: linear-gradient(135deg, var(--secondary) 0%, #0891b2 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.4);
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.6);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* User profile button in header */
.profile-header-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 50px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.profile-header-btn:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.08);
}

.avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 0.75rem;
}

/* Main layouts */
main {
  margin-top: 70px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view-section {
  display: none;
  padding: 40px 5%;
  flex: 1;
  animation: fadeIn 0.4s ease-out;
}

.view-section.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 1. HOME VIEW */
.home-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 40px;
  align-items: center;
  min-height: calc(80vh - 70px);
  margin-bottom: 60px;
}

.hero-text h1 {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fff 40%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-text h1 mark {
  background: none;
  color: transparent;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(139, 92, 246, 0.3);
}

.hero-text p {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 35px;
  max-width: 600px;
}

.search-bar-hero {
  display: flex;
  max-width: 500px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.search-bar-hero input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-right: none;
  padding: 16px 20px;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: #fff;
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.search-bar-hero input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

.search-bar-hero button {
  background: var(--primary);
  border: none;
  padding: 0 24px;
  color: white;
  cursor: pointer;
  font-weight: 600;
  transition: background var(--transition-fast);
}

.search-bar-hero button:hover {
  background: var(--primary-hover);
}

/* Feature Grid Cards */
.hero-showcase {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-showcase .book-stack {
  position: relative;
  width: 280px;
  height: 400px;
}

.stack-card {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  background-size: cover;
  background-position: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1), filter var(--transition-normal);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stack-card:nth-child(1) {
  transform: rotate(-8deg) translateX(-20px);
  z-index: 1;
  filter: brightness(0.6);
}

.stack-card:nth-child(2) {
  transform: rotate(4deg) translateX(15px);
  z-index: 2;
  filter: brightness(0.8);
}

.stack-card:nth-child(3) {
  transform: rotate(-1deg);
  z-index: 3;
}

.hero-showcase:hover .stack-card:nth-child(1) {
  transform: rotate(-18deg) translateX(-80px) translateY(-10px);
  filter: brightness(0.85);
}

.hero-showcase:hover .stack-card:nth-child(2) {
  transform: rotate(12deg) translateX(80px) translateY(-10px);
  filter: brightness(0.95);
}

.hero-showcase:hover .stack-card:nth-child(3) {
  transform: translateY(-20px) scale(1.05);
  box-shadow: 0 30px 60px rgba(139, 92, 246, 0.4);
}

/* Stats Counter Section */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 80px;
}

.stat-item {
  padding: 30px;
  text-align: center;
}

.stat-item h3 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 5px;
  color: var(--secondary);
  text-shadow: 0 0 15px rgba(6, 182, 212, 0.3);
}

.stat-item p {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Home Section Titles */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
}

.section-header h2 {
  font-size: 2rem;
  font-weight: 700;
  position: relative;
  padding-bottom: 8px;
}

.section-header h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 50px;
  height: 3px;
  background: var(--primary);
}

/* Featured Books Catalog */
.featured-books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 30px;
  margin-bottom: 60px;
}

/* 2. CATALOG VIEW */
.catalog-container {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
  align-items: start;
}

.filter-sidebar {
  padding: 24px;
  position: sticky;
  top: 100px;
}

.filter-group {
  margin-bottom: 24px;
}

.filter-group h4 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.genre-filter-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 6px;
}

.genre-filter-btn:hover, .genre-filter-btn.active {
  color: var(--text-main);
  background: rgba(139, 92, 246, 0.15);
  padding-left: 18px;
  border-left: 3px solid var(--primary);
}

.catalog-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.catalog-search-row {
  display: flex;
  gap: 16px;
}

.catalog-search-row input {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  color: white;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  outline: none;
}

.catalog-search-row input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

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

/* Book Card Component */
.book-card {
  display: flex;
  flex-direction: column;
  height: 380px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: all var(--transition-normal);
}

.book-cover-wrapper {
  position: relative;
  height: 250px;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0,0,0,0.4);
}

.book-card-cover {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.book-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(8, 7, 16, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity var(--transition-normal);
  z-index: 2;
}

.book-card:hover {
  transform: translateY(-8px);
  border-color: var(--border-hover);
  box-shadow: 0 12px 30px rgba(139, 92, 246, 0.25);
}

.book-card:hover .book-card-cover {
  transform: scale(1.1);
}

.book-card:hover .book-overlay {
  opacity: 1;
  transform: translateY(0);
}

.book-overlay p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 14px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

.book-overlay .badge {
  align-self: flex-start;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.2);
  color: var(--secondary);
  border: 1px solid rgba(6, 182, 212, 0.3);
  margin-top: auto;
}

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

.book-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.book-author {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: auto;
}

.book-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 10px;
}

.rating-stars {
  color: #fbbf24;
}

/* Book Details Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5, 4, 12, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 40px;
  position: relative;
  animation: modalSlideUp 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.close-modal-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.close-modal-btn:hover {
  color: white;
}

.book-details-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 30px;
}

.book-details-layout img {
  width: 100%;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
}

.book-details-info {
  display: flex;
  flex-direction: column;
}

.book-details-info h2 {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.book-details-author {
  color: var(--secondary);
  font-weight: 500;
  margin-bottom: 16px;
}

.book-details-genre {
  font-size: 0.8rem;
  padding: 3px 10px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  align-self: flex-start;
  margin-bottom: 20px;
}

.book-details-description {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 30px;
}

.book-details-actions {
  display: flex;
  gap: 16px;
  margin-top: auto;
}

/* 3. E-READER VIEW (Custom Interface) */
.reader-container {
  display: grid;
  grid-template-rows: 60px 1fr;
  height: calc(100vh - 70px);
  overflow: hidden;
  background-color: var(--reader-bg);
  color: var(--reader-text);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Reader Themes */
.reader-container.theme-light {
  --reader-bg: #f9f9fb;
  --reader-text: #1a1a24;
}

.reader-container.theme-sepia {
  --reader-bg: #f5eedc;
  --reader-text: #433422;
}

.reader-container.theme-dark {
  --reader-bg: #121214;
  --reader-text: #e2e2e5;
}

.reader-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.reader-container.theme-dark .reader-navbar {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.reader-title-info {
  display: flex;
  flex-direction: column;
}

.reader-title-info h3 {
  font-size: 1rem;
  font-weight: 700;
}

.reader-title-info span {
  font-size: 0.75rem;
  opacity: 0.7;
}

.reader-controls {
  display: flex;
  align-items: center;
  gap: 20px;
}

.control-btn-group {
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.05);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.reader-container.theme-dark .control-btn-group {
  background: rgba(255, 255, 255, 0.05);
}

.reader-ctrl-btn {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: inherit;
  transition: background var(--transition-fast);
}

.reader-ctrl-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.reader-container.theme-dark .reader-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.reader-ctrl-btn.active {
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.reader-container.theme-dark .reader-ctrl-btn.active {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.reader-workspace {
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  align-items: center;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.reader-nav-arrow {
  height: 100%;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: inherit;
  opacity: 0.4;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}

.reader-nav-arrow:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.02);
}

.reader-container.theme-dark .reader-nav-arrow:hover {
  background: rgba(255, 255, 255, 0.02);
}

.reader-body-wrapper {
  height: 100%;
  overflow-y: auto;
  padding: 40px 10%;
  display: flex;
  flex-direction: column;
}

.reader-text-container {
  font-family: var(--font-reader);
  font-size: 1.15rem;
  line-height: 1.8;
  max-width: 750px;
  margin: 0 auto;
}

.reader-text-container h1, .reader-text-container h2 {
  font-family: var(--font-ui);
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

.reader-text-container p {
  margin-bottom: 20px;
  text-align: justify;
  text-indent: 2em;
}

.reader-text-container p:first-of-type {
  text-indent: 0;
}

.reader-progress-footer {
  margin-top: auto;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  opacity: 0.6;
}

/* 4. COMMUNITY / BAKBAK ROOM VIEW */
.community-container {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  gap: 24px;
  height: calc(85vh - 70px);
  min-height: 500px;
}

.comm-sidebar {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.comm-title {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--secondary);
}

.comm-channel-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.comm-channel-btn {
  background: none;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.comm-channel-btn::before {
  content: '#';
  color: var(--primary);
  font-weight: 700;
}

.comm-channel-btn:hover, .comm-channel-btn.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.comm-channel-btn.active {
  border-left: 2px solid var(--secondary);
  background: rgba(6, 182, 212, 0.1);
}

.chat-box-container {
  display: grid;
  grid-template-rows: 60px 1fr 60px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
}

.chat-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.chat-header span {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 12px;
}

.chat-messages {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-bubble {
  display: flex;
  gap: 12px;
  max-width: 80%;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble.my-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar-chat {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  color: white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.chat-bubble.my-message .avatar-chat {
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
}

.chat-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.chat-username {
  font-weight: 600;
  color: var(--text-main);
}

.chat-timestamp {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.chat-msg-text {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.4;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.03);
}

.chat-bubble.my-message .chat-msg-text {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-bubble:not(.my-message) .chat-msg-text {
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: flex;
  padding: 10px 20px;
  border-top: 1px solid var(--border-color);
  background: rgba(0,0,0,0.2);
}

.chat-input-row input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  color: white;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  outline: none;
  margin-right: 12px;
}

.chat-input-row input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

/* Reviews Side Panel */
.comm-reviews-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.reviews-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.review-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

.review-book-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--secondary);
}

.review-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 4px 0;
}

.review-text {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.add-review-btn {
  width: 100%;
  margin-top: auto;
}

/* 5. BOOKSHELF VIEW */
.shelf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.shelf-tabs {
  display: flex;
  gap: 12px;
}

.shelf-tab {
  background: none;
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 30px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.shelf-tab:hover, .shelf-tab.active {
  color: var(--text-main);
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.1);
}

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

.shelf-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 16px;
  padding: 16px;
  align-items: center;
}

.shelf-item img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.shelf-item-details {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.shelf-item-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: white;
}

.shelf-item-author {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.shelf-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 4px;
}

.shelf-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  width: 0%;
}

.shelf-progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: auto;
}

.shelf-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

/* User Profile / Dashboard View */
.profile-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 40px;
  align-items: start;
}

.profile-card {
  padding: 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.profile-avatar-large {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 800;
  color: white;
  margin-bottom: 20px;
  box-shadow: 0 10px 25px rgba(139, 92, 246, 0.4);
}

.profile-name {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-email {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.profile-joined {
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  width: 100%;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.profile-stat-box {
  padding: 24px;
  text-align: center;
}

.profile-stat-box h4 {
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 4px;
}

.profile-stat-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Modal Form Styles */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 360px;
  width: 100%;
  margin: 0 auto;
}

.modal-form h2 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.modal-form p {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

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

.form-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-group input, .form-group textarea, .form-group select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: white;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  outline: none;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
}

.modal-form-switch {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.modal-form-switch span {
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
}

.modal-form-switch span:hover {
  text-decoration: underline;
}

/* Review Form Specific */
.rating-input {
  display: flex;
  gap: 8px;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.rating-input span:hover, .rating-input span.active {
  color: #fbbf24;
}

/* Responsive Styles */
@media (max-width: 900px) {
  .home-hero {
    grid-template-columns: 1fr;
    text-align: center;
    min-height: auto;
    padding-top: 40px;
  }
  
  .hero-text p {
    margin: 0 auto 35px auto;
  }
  
  .search-bar-hero {
    margin: 0 auto;
  }
  
  .hero-showcase {
    display: none;
  }
  
  .stats-banner {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .catalog-container {
    grid-template-columns: 1fr;
  }
  
  .filter-sidebar {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
  }
  
  .filter-group {
    margin-bottom: 0;
  }
  
  .genre-filter-btn {
    display: inline-block;
    width: auto;
    margin-bottom: 0;
  }
  
  .community-container {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .comm-sidebar, .comm-reviews-panel {
    display: none;
  }
  
  .profile-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .stats-banner {
    grid-template-columns: 1fr;
  }
  
  header {
    padding: 0 16px;
  }
  
  nav {
    display: none; /* simple responsive improvement: we could add a burger menu or simple bar */
  }
  
  .hero-text h1 {
    font-size: 2.5rem;
  }
}

#view-reader {
  padding: 0;
  flex: 1;
}

.reader-container .btn-secondary {
  color: var(--reader-text);
  border-color: rgba(0, 0, 0, 0.15);
  background: rgba(0, 0, 0, 0.04);
}

.reader-container .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.08);
}

.reader-container.theme-dark .btn-secondary {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
}

.reader-container.theme-dark .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

