/* ============================================
   CSS Variables & Base Styles
   ============================================ */
:root {
  /* Warm, archival color palette */
  --bg-primary: #0d0c0b;
  --bg-secondary: #161412;
  --bg-tertiary: #1e1b18;
  --bg-card: #242120;

  --text-primary: #f5f0e8;
  --text-secondary: #a89f94;
  --text-muted: #6b6156;

  --accent-gold: #d4a853;
  --accent-gold-soft: rgba(212, 168, 83, 0.15);
  --accent-warm: #c47d4e;
  --accent-rose: #c2847a;

  /* Speaker colors */
  --speaker-rosie: #d4a853;
  --speaker-interviewer: #7ab8c4;
  --speaker-guest: #b8a0d4;
  --speaker-other: #8fb88a;

  --border-color: rgba(168, 159, 148, 0.12);
  --border-hover: rgba(168, 159, 148, 0.25);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --font-serif: 'Crimson Pro', Georgia, serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --sidebar-width: 320px;
  --header-height: 72px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

/* ============================================
   App Layout
   ============================================ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 28px 24px;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  width: 48px;
  height: 48px;
  background: var(--accent-gold-soft);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-gold);
  margin-bottom: 16px;
}

.sidebar-header h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-header .subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Conversation List */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.conversation-list::-webkit-scrollbar {
  width: 6px;
}

.conversation-list::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.conversation-item {
  display: block;
  padding: 16px;
  margin-bottom: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  color: inherit;
}

.conversation-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}

.conversation-item.active {
  background: var(--accent-gold-soft);
  border-color: var(--accent-gold);
}

.conversation-item-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-card);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  transition: all var(--transition-fast);
}

.conversation-item.active .conversation-item-number {
  background: var(--accent-gold);
  color: var(--bg-primary);
}

.conversation-item-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.conversation-item-preview {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.conversation-item-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.topic-tag {
  font-size: 0.6875rem;
  padding: 3px 8px;
  background: var(--bg-card);
  border-radius: 20px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.sidebar-footer p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
  position: relative;
}

/* Background Pattern */
.main-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(212, 168, 83, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(196, 125, 78, 0.03) 0%, transparent 50%);
  pointer-events: none;
}

/* ============================================
   Welcome Screen
   ============================================ */
.welcome-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
  z-index: 1;
}

.welcome-content {
  text-align: center;
  max-width: 480px;
  animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-icon {
  color: var(--accent-gold);
  margin-bottom: 32px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.welcome-content h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 500;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.welcome-content p {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 40px;
}

.welcome-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-number {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--accent-gold);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* ============================================
   Conversation View
   ============================================ */
.conversation-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.conversation-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 32px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  min-height: var(--header-height);
}

.back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.back-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.conversation-title h2 {
  font-family: var(--font-serif);
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.conversation-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 8px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Section Headers */
.section-header {
  margin: 48px 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.section-header:first-child {
  margin-top: 0;
}

.section-header h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--accent-gold);
  letter-spacing: -0.01em;
}

.section-header.level-2 h3 {
  font-size: 1.25rem;
  color: var(--text-primary);
}

/* Messages */
.message {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  max-width: 800px;
  animation: messageIn 0.4s ease;
  animation-fill-mode: both;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.message-avatar.rosie {
  background: rgba(212, 168, 83, 0.15);
  color: var(--speaker-rosie);
}

.message-avatar.interviewer {
  background: rgba(122, 184, 196, 0.15);
  color: var(--speaker-interviewer);
}

.message-avatar.guest {
  background: rgba(184, 160, 212, 0.15);
  color: var(--speaker-guest);
}

.message-avatar.a,
.message-avatar.b {
  background: rgba(143, 184, 138, 0.15);
  color: var(--speaker-other);
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-speaker {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message-speaker.rosie { color: var(--speaker-rosie); }
.message-speaker.interviewer { color: var(--speaker-interviewer); }
.message-speaker.guest { color: var(--speaker-guest); }
.message-speaker.a, .message-speaker.b { color: var(--speaker-other); }

.message-text {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.message-text em {
  font-style: italic;
  color: var(--text-secondary);
}

/* Dividers */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: 40px 0;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 280px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .back-btn {
    display: flex;
  }

  .main-content {
    width: 100%;
  }

  .messages-container {
    padding: 24px 20px;
  }

  .conversation-header {
    padding: 16px 20px;
  }
}

@media (max-width: 600px) {
  .welcome-content h2 {
    font-size: 1.5rem;
  }

  .welcome-stats {
    gap: 32px;
  }

  .stat-number {
    font-size: 2rem;
  }

  .message {
    gap: 12px;
  }

  .message-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
  }

  .message-text {
    font-size: 1rem;
  }

  .section-header h3 {
    font-size: 1.25rem;
  }
}

/* ============================================
   Mobile Menu Toggle
   ============================================ */
.mobile-menu-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--accent-gold);
  border: none;
  border-radius: 50%;
  color: var(--bg-primary);
  cursor: pointer;
  z-index: 99;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition-fast);
}

.mobile-menu-btn:hover {
  transform: scale(1.05);
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 900px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  .sidebar,
  .mobile-menu-btn,
  .back-btn {
    display: none !important;
  }

  .main-content {
    width: 100%;
  }

  .message-text {
    font-size: 12pt;
  }
}

