:root {
  --cream: #FDF6E3;
  --cream-dark: #F5EACC;
  --brown: #8B4513;
  --brown-light: #A0522D;
  --green: #4A7C59;
  --green-light: #5C9A6E;
  --gold: #C9A227;
  --gold-light: #D4B63C;
  --text-dark: #3D2914;
  --text-muted: #6B5B4F;
  --shadow-soft: 0 4px 20px rgba(139, 69, 19, 0.1);
  --shadow-card: 0 8px 32px rgba(139, 69, 19, 0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Source Sans 3', sans-serif;
  background: linear-gradient(135deg, var(--cream) 0%, var(--cream-dark) 100%);
  min-height: 100vh;
  color: var(--text-dark);
}

h1, h2, h3, h4 {
  font-family: 'Crimson Pro', serif;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header-container {
  background: linear-gradient(to right, var(--brown), var(--brown-light));
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-soft);
}

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

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.book-icon {
  position: relative;
  width: 32px;
  height: 24px;
}

.book-page {
  position: absolute;
  width: 20px;
  height: 24px;
  background: var(--cream);
  border-radius: 0 4px 4px 0;
  transform-origin: left center;
}

.page-1 { animation: pageTurn 3s ease-in-out infinite; }
.page-2 { animation: pageTurn 3s ease-in-out 0.1s infinite; }
.page-3 { animation: pageTurn 3s ease-in-out 0.2s infinite; }

@keyframes pageTurn {
  0%, 100% { transform: rotateY(0deg); }
  50% { transform: rotateY(-30deg); }
}

.logo-text {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--cream);
  letter-spacing: -0.5px;
}

.logo-emoji {
  font-size: 1.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.notification-btn {
  position: relative;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  padding: 0.5rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  transition: background 0.2s;
}

.notification-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--gold);
  color: var(--text-dark);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}

.user-menu {
  position: relative;
}

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  color: var(--cream);
  font-weight: 500;
  transition: background 0.2s;
}

.avatar-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  min-width: 160px;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  transition: background 0.2s;
}

.dropdown-menu button:hover {
  background: var(--cream);
}

/* Hero Section */
.hero-section {
  position: relative;
  padding: 4rem 2rem;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(180deg, transparent 0%, rgba(74, 124, 89, 0.05) 100%);
}

.floating-books {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.floating-book {
  position: absolute;
  font-size: 2rem;
  opacity: 0.3;
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(10deg); }
}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  color: var(--brown);
  margin-bottom: 1rem;
  position: relative;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.cta-button {
  position: relative;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
  color: white;
  border: none;
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(74, 124, 89, 0.3);
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 124, 89, 0.4);
}

.cta-button.small {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
}

.cta-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shine 3s infinite;
}

@keyframes shine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

/* Main Layout */
.main-layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  gap: 2rem;
  flex: 1;
}

.main-content {
  flex: 1;
}

/* Section Title */
.section-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--brown);
  margin-bottom: 1.5rem;
}

/* Books Grid */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

/* Book Card */
.book-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.book-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(139, 69, 19, 0.15);
}

.book-card-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.book-cover {
  width: 70px;
  height: 100px;
  background: linear-gradient(135deg, var(--cream) 0%, var(--cream-dark) 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
}

.book-emoji {
  font-size: 2.5rem;
}

.book-info {
  flex: 1;
}

.book-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--brown);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

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

.book-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.chapter-badge {
  background: var(--cream);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--brown);
}

.active-pulse {
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 500;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.progress-ring {
  flex-shrink: 0;
}

.progress-ring-bg {
  stroke: var(--cream);
}

.progress-ring-fill {
  stroke: var(--green);
  transition: stroke-dashoffset 0.5s ease;
}

.progress-text {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  fill: var(--green);
}

.book-card-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--cream);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.readers-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.book-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.action-btn.primary {
  background: var(--gold);
  color: var(--text-dark);
}

.action-btn.primary:hover {
  background: var(--gold-light);
}

.action-btn.secondary {
  background: var(--cream);
  color: var(--brown);
}

.action-btn.secondary:hover {
  background: var(--cream-dark);
}

/* Progress Slider */
.progress-slider-container {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--cream);
  border-radius: 12px;
  animation: slideDown 0.3s ease;
}

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

.progress-slider-container label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--brown);
}

.progress-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  background: white;
  border-radius: 4px;
  outline: none;
  margin-bottom: 1rem;
}

.progress-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--green);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
}

.progress-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.finish-chapter-btn {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.finish-chapter-btn:hover {
  transform: scale(1.02);
}

/* Discussion Zone */
.discussion-zone {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.discussion-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(to right, var(--brown), var(--brown-light));
  color: white;
}

.back-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.back-btn:hover {
  background: rgba(255,255,255,0.25);
}

.discussion-book-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.book-emoji-small {
  font-size: 1.5rem;
}

.safety-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(90deg, rgba(74, 124, 89, 0.1), rgba(74, 124, 89, 0.05));
  border-left: 4px solid var(--green);
  font-size: 0.9rem;
  color: var(--green);
  font-weight: 500;
}

.safety-icon {
  font-size: 1.25rem;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  animation: fadeIn 0.3s ease;
}

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

.message-avatar {
  width: 40px;
  height: 40px;
  background: var(--cream);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.message-content {
  flex: 1;
  background: var(--cream);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.message-user {
  font-weight: 600;
  color: var(--brown);
}

.message-chapter {
  background: var(--green);
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

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

.message-text {
  color: var(--text-dark);
  line-height: 1.5;
}

.message-reactions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.reaction-btn {
  background: white;
  border: 1px solid var(--cream-dark);
  border-radius: 15px;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.reaction-btn:hover {
  transform: scale(1.2);
  border-color: var(--gold);
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
}

.typing-dots span {
  animation: blink 1.4s infinite;
}

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

@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

.fog-of-war {
  padding: 1rem 1.5rem;
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.1), rgba(201, 162, 39, 0.05));
  border-left: 4px solid var(--gold);
  color: var(--gold);
  font-weight: 500;
  font-size: 0.9rem;
}

.message-input-container {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: white;
  border-top: 1px solid var(--cream);
}

.message-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--cream);
  border-radius: 25px;
  outline: none;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.message-input:focus {
  border-color: var(--green);
}

.yap-btn {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.yap-btn:hover {
  transform: scale(1.05);
}

/* Discovery Section */
.discovery-section {
  padding-top: 2rem;
}

.back-to-dashboard {
  background: var(--cream);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 1.5rem;
  transition: background 0.2s;
}

.back-to-dashboard:hover {
  background: var(--cream-dark);
}

.search-container {
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  max-width: 400px;
  padding: 1rem 1.5rem;
  border: 2px solid var(--cream);
  border-radius: 30px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(74, 124, 89, 0.1);
}

.trending-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--brown);
  margin-bottom: 1rem;
}

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

.discovery-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.discovery-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

.discovery-cover {
  width: 60px;
  height: 80px;
  background: linear-gradient(135deg, var(--cream) 0%, var(--cream-dark) 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.discovery-info h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--brown);
  margin-bottom: 0.25rem;
}

.discovery-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.reader-count {
  font-size: 0.8rem;
  color: var(--green);
  font-weight: 500;
}

.join-btn {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.join-btn:hover {
  transform: scale(1.02);
}

.discover-cta {
  display: block;
  width: fit-content;
  margin: 2rem auto 0;
  background: var(--cream);
  border: 2px solid var(--brown);
  color: var(--brown);
  padding: 0.75rem 1.5rem;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.discover-cta:hover {
  background: var(--brown);
  color: white;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  padding: 1rem;
  height: fit-content;
  position: sticky;
  top: 100px;
}

.sidebar-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sidebar-tab {
  flex: 1;
  padding: 0.5rem;
  background: var(--cream);
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.sidebar-tab.active {
  background: var(--brown);
  color: white;
}

.buddies-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.buddy-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--cream);
  border-radius: 10px;
  transition: background 0.2s;
}

.buddy-item:hover {
  background: var(--cream-dark);
}

.buddy-avatar {
  font-size: 1.5rem;
}

.buddy-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.buddy-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--brown);
}

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

.sync-badge {
  font-size: 0.7rem;
  color: var(--green);
  font-weight: 500;
}

.chat-quick-btn {
  background: var(--gold);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
}

.chat-quick-btn:hover {
  transform: scale(1.1);
}

.leaderboard h3 {
  font-size: 1rem;
  color: var(--brown);
  margin-bottom: 0.75rem;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--cream);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.rank {
  font-weight: 700;
  color: var(--gold);
  min-width: 28px;
}

.entry-avatar {
  font-size: 1.25rem;
}

.entry-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.entry-info span:first-child {
  font-weight: 500;
  font-size: 0.85rem;
}

.entry-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.pages-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 10px;
  animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brown);
  color: white;
  padding: 1rem 2rem;
  border-radius: 30px;
  box-shadow: var(--shadow-card);
  z-index: 1000;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Footer */
.footer {
  background: linear-gradient(to right, var(--brown), var(--brown-light));
  padding: 2rem;
  margin-top: auto;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1rem;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: white;
}

.footer-tagline {
  color: var(--gold);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.footer-pun {
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
  margin-bottom: 1rem;
  min-height: 1.5em;
  transition: opacity 0.3s;
}

.footer-attribution {
  color: var(--cream);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-attribution:hover {
  color: var(--gold);
}

/* Responsive */
@media (max-width: 1024px) {
  .main-layout {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    position: static;
  }
  
  .books-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .header-container {
    padding: 0.75rem 1rem;
  }
  
  .user-name {
    display: none;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-subtitle {
    font-size: 1rem;
  }
  
  .main-layout {
    padding: 1rem;
  }
  
  .book-card-header {
    flex-wrap: wrap;
  }
  
  .book-card-footer {
    flex-direction: column;
    align-items: stretch;
  }
  
  .book-actions {
    justify-content: stretch;
  }
  
  .action-btn {
    flex: 1;
  }
  
  .discussion-zone {
    max-height: calc(100vh - 150px);
  }
  
  .footer-links {
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .floating-books {
    display: none;
  }
  
  .discovery-grid {
    grid-template-columns: 1fr;
  }
}