/* Athenaeum AI Book Intelligence & Study Suite Styling */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,400;1,600&family=Merriweather:ital,wght@0,300;0,400;0,700;1,300&display=swap');

:root {
  --bg-primary: #faf6ee;
  --bg-card: #ffffff;
  --text-main: #2c2523;
  --text-muted: #6b7280;
  --border-color: #ebd9c8;
  --accent-gold: #b45309;
  --accent-blue: #2563eb;
  --accent-indigo: #4f46e5;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.1);
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-body: 'Merriweather', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
}

[data-paper="charcoal"] {
  --bg-primary: #18181b;
  --bg-card: #202024;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border-color: #2e2e34;
  --accent-gold: #fbbf24;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Sticky Top Bar */
.analysis-topbar {
  position: sticky;
  top: 0;
  height: 56px;
  background: rgba(250, 246, 238, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
}

[data-paper="charcoal"] .analysis-topbar {
  background: rgba(24, 24, 27, 0.94);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.topbar-btn.btn-primary {
  background: #1e293b;
  color: white;
  border-color: #1e293b;
}

.topbar-btn.btn-primary:hover {
  background: #0f172a;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
}

.topbar-book-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vocab-badge {
  background: var(--accent-gold);
  color: white;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* Container */
.analysis-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 80px 24px;
}

/* Loader */
.analysis-loader {
  text-align: center;
  padding: 80px 20px;
}

.loader-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Hero Section */
.analysis-hero {
  display: flex;
  gap: 36px;
  align-items: flex-start;
  margin-bottom: 36px;
}

.hero-cover-container {
  position: relative;
  flex-shrink: 0;
  width: 180px;
}

.hero-cover-img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.hero-details {
  flex: 1;
}

.hero-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-genre {
  background: #fef3c7;
  color: #92400e;
}

.badge-difficulty {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-time {
  background: #f3f4f6;
  color: #4b5563;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 6px;
}

.hero-author {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 18px;
  font-weight: 500;
}

.hero-thesis-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-gold);
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}

.thesis-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-gold);
  margin-bottom: 6px;
}

.thesis-text {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  gap: 12px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.action-primary {
  background: #1e293b;
  color: white;
}

.action-primary:hover {
  background: #0f172a;
}

.action-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-main);
}

.action-secondary:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Nav Tabs */
.analysis-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 28px;
  padding-bottom: 2px;
  scrollbar-width: none;
}

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

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
}

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

.nav-tab.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
  font-weight: 700;
}

.tab-pill {
  background: rgba(0, 0, 0, 0.06);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
}

/* Tab Panes */
.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease;
}

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

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

/* Section Cards */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 14px;
}

.card-lead {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.75;
}

.card-body {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.7;
}

/* Timeline / Acts */
.act-timeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 16px;
}

.act-card {
  border-left: 3px solid var(--accent-gold);
  padding-left: 18px;
}

.act-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.act-chapters {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.act-summary {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 8px;
}

.act-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.act-tag {
  background: rgba(0, 0, 0, 0.04);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}

/* Conclusions */
.conclusions-list {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conclusions-list li {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.6;
}

/* Symbolism Grid */
.symbolism-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.symbol-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.015);
}

.symbol-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--accent-gold);
}

.symbol-desc {
  font-size: 13px;
  line-height: 1.55;
}

/* Grammar Metrics */
.grammar-metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.metric-box {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
}

.metric-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.metric-desc {
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.6;
}

.score-badge {
  background: #ede9fe;
  color: #5b21b6;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
}

/* Topics Grid */
.topics-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topic-item {
  border-left: 3px solid var(--accent-blue);
  padding-left: 16px;
}

.topic-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.topic-insight {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.65;
}

/* Concepts Accordion */
.concepts-accordion {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.concept-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
}

.concept-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.concept-desc {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.65;
}

/* Vocabulary Cards Grid */
.vocab-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.vocab-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 18px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.vocab-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.vocab-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.vocab-word {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
}

.vocab-phonetics {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

.vocab-part {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.vocab-def {
  font-size: 13.5px;
  line-height: 1.55;
  margin-bottom: 12px;
}

.vocab-quote {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-style: italic;
  background: rgba(0, 0, 0, 0.02);
  padding: 8px 10px;
  border-left: 2px solid var(--accent-gold);
  border-radius: 4px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.vocab-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.btn-pronounce {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
}

.btn-save-vocab {
  background: none;
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: inherit;
  transition: all 0.15s ease;
}

.btn-save-vocab.saved {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

/* Scholar Q&A */
.scholar-card {
  padding: 28px;
}

.scholar-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.scholar-avatar {
  font-size: 32px;
}

.scholar-chat-box {
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
  padding-right: 6px;
}

.scholar-message {
  padding: 14px 18px;
  border-radius: 12px;
  max-width: 85%;
  font-size: 14px;
  line-height: 1.65;
}

.scholar-message.bot {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border-color);
  align-self: flex-start;
  font-family: var(--font-body);
}

.scholar-message.user {
  background: #1e293b;
  color: white;
  align-self: flex-end;
}

.scholar-suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.suggestion-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: inherit;
  cursor: pointer;
}

.suggestion-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.scholar-input-row {
  display: flex;
  gap: 8px;
}

.scholar-text-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-card);
  color: inherit;
  font-family: var(--font-sans);
}

.scholar-submit-btn {
  background: #1e293b;
  color: white;
  border: none;
  padding: 0 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

/* Vocabulary Drawer */
.vocab-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.vocab-drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.vocab-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: 360px;
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
}

.vocab-drawer.open {
  transform: translateX(0);
}

.vocab-drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.vocab-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-vocab-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.01);
}

/* Flashcard Modal */
.flashcard-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.flashcard-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 460px;
  max-width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.flashcard-flip-container {
  height: 240px;
  perspective: 1000px;
  cursor: pointer;
  margin-bottom: 20px;
}

.flashcard-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  transform-style: preserve-3d;
}

.flashcard-flip-container.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: var(--bg-primary);
  box-shadow: var(--shadow-sm);
}

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

.fc-word {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}

.fc-phonetics {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.fc-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 16px;
}

.fc-part {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 8px;
}

.fc-def {
  font-size: 14.5px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.fc-quote {
  font-family: var(--font-body);
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
}

.flashcard-controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.fc-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: inherit;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.fc-btn-star {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .analysis-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
  }

  .hero-cover-container {
    width: 140px;
  }

  .hero-cover-img {
    height: 200px;
  }

  .hero-badges {
    justify-content: center;
  }

  .hero-title {
    font-size: 24px;
  }

  .hero-thesis-box {
    text-align: left;
  }

  .hero-actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .grammar-metric-row {
    grid-template-columns: 1fr;
  }

  .vocab-cards-grid {
    grid-template-columns: 1fr;
  }

  .topbar-btn .btn-text {
    display: none;
  }
}
