/* ============================================
   NŪR — Cosmic Wisdom for Two
   Design System & Full Styles
   ============================================ */

/* --- Custom Properties --- */
:root {
  /* Cosmic Dark Palette */
  --bg-void: #06060e;
  --bg-deep: #0a0a18;
  --bg-surface: #111128;
  --bg-card: rgba(18, 18, 48, 0.65);
  --bg-card-hover: rgba(28, 28, 68, 0.75);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.07);

  /* Accent Colors */
  --accent-primary: #b388ff;
  --accent-primary-dim: rgba(179, 136, 255, 0.15);
  --accent-rose: #ff8fbc;
  --accent-rose-dim: rgba(255, 143, 188, 0.15);
  --accent-gold: #ffd07a;
  --accent-gold-dim: rgba(255, 208, 122, 0.15);
  --accent-teal: #64ffda;
  --accent-teal-dim: rgba(100, 255, 218, 0.1);

  /* Gradients */
  --grad-primary: linear-gradient(135deg, #b388ff 0%, #ff8fbc 50%, #ffd07a 100%);
  --grad-subtle: linear-gradient(135deg, rgba(179, 136, 255, 0.2), rgba(255, 143, 188, 0.2));
  --grad-card: linear-gradient(160deg, rgba(30, 20, 60, 0.8), rgba(15, 10, 35, 0.9));

  /* Text */
  --text-primary: #eee8ff;
  --text-secondary: rgba(220, 210, 255, 0.65);
  --text-muted: rgba(180, 170, 210, 0.45);
  --text-accent: #d4b8ff;

  /* Borders */
  --border-subtle: rgba(179, 136, 255, 0.12);
  --border-glow: rgba(179, 136, 255, 0.3);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(179, 136, 255, 0.15);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 100px;

  /* Timing */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-void);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.7;
}

/* --- Starfield Canvas --- */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* --- Navigation --- */
#main-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 2rem;
  background: rgba(6, 6, 14, 0.75);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-icon {
  font-size: 1.3rem;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: twinkle 3s ease-in-out infinite;
}

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

.brand-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-primary);
}

.nav-links {
  display: flex;
  gap: 0.25rem;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  position: relative;
}

.nav-btn:hover {
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}

.nav-btn.active {
  color: var(--accent-primary);
  background: var(--accent-primary-dim);
}

.nav-model-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-teal);
  box-shadow: 0 0 6px var(--accent-teal);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.error {
  background: #ff5555;
  box-shadow: 0 0 6px #ff5555;
}

.status-dot.loading {
  background: var(--accent-gold);
  box-shadow: 0 0 6px var(--accent-gold);
  animation: pulse-dot 0.8s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* --- Hero --- */
#hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 8rem 2rem 4rem;
  text-align: center;
}

.hero-content {
  max-width: 680px;
}

.hero-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-primary);
  background: var(--accent-primary-dim);
  border: 1px solid rgba(179, 136, 255, 0.2);
  padding: 0.4rem 1.2rem;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-lg);
  animation: fadeInUp 0.8s var(--ease-out);
}

#hero h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--space-lg);
  animation: fadeInUp 0.8s var(--ease-out) 0.1s both;
}

#hero h1 em {
  font-style: italic;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto var(--space-xl);
  animation: fadeInUp 0.8s var(--ease-out) 0.2s both;
}

/* CTA Button */
.cta-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 2.2rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #0a0a18;
  background: var(--grad-primary);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s var(--ease-out);
  animation: fadeInUp 0.8s var(--ease-out) 0.3s both;
}

.cta-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 32px rgba(179, 136, 255, 0.4);
}

.cta-btn:active {
  transform: translateY(0) scale(0.98);
}

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

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

/* Chart cards in hero */
.hero-charts {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-xl);
  animation: fadeInUp 0.8s var(--ease-out) 0.4s both;
  width: 100%;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  backdrop-filter: blur(16px);
  transition: transform 0.3s var(--ease-spring), border-color 0.3s;
  flex: 1;
  max-width: 320px;
}

.chart-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
}

.chart-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-primary);
  margin-bottom: var(--space-md);
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-sm);
}

.chart-big-three {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  text-align: center;
}

.big-three-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bt-icon {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  color: var(--accent-gold);
  line-height: 1;
}

.bt-sign {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.2rem;
}

.bt-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-planets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
}

.planet-chip {
  font-size: 0.7rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

.chart-source {
  text-align: center;
  margin-top: var(--space-sm);
}

.source-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-style: italic;
}

.chart-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--accent-rose);
  opacity: 0.8;
  gap: 0.2rem;
}

.link-line {
  width: 1px;
  height: 20px;
  background: var(--grad-subtle);
}

.link-icon {
  font-size: 1.5rem;
}

/* --- Content Sections --- */
.content-section {
  display: none;
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

.content-section.active-section {
  display: block;
  animation: fadeIn 0.5s var(--ease-out);
}

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

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

.section-header {
  margin-bottom: var(--space-xl);
}

.section-header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-icon {
  font-size: 1.2rem;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

/* --- Topic Pills --- */
.topic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.pill {
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.pill:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-glow);
  transform: translateY(-1px);
}

.pill.active {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  border-color: rgba(179, 136, 255, 0.3);
}

/* --- Reading Card --- */
.reading-card {
  background: var(--grad-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  min-height: 200px;
  backdrop-filter: blur(12px);
  transition: border-color 0.4s;
}

.reading-card:hover {
  border-color: var(--border-glow);
}

/* Placeholder */
.reading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 160px;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
  opacity: 0.3;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Reading content */
.reading-content {
  animation: fadeIn 0.5s var(--ease-out);
}

.reading-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  line-height: 1.9;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.reading-text p {
  margin-bottom: var(--space-md);
}

.reading-text strong, .reading-text b {
  color: var(--accent-gold);
  font-weight: 600;
}

.reading-text em, .reading-text i {
  color: var(--accent-rose);
}

.reading-text h3, .reading-text h4 {
  font-family: 'Outfit', sans-serif;
  color: var(--accent-primary);
  margin: var(--space-lg) 0 var(--space-sm);
  font-size: 1rem;
  font-weight: 600;
}

.reading-text ul, .reading-text ol {
  margin: var(--space-sm) 0 var(--space-md) var(--space-lg);
}

.reading-text li {
  margin-bottom: var(--space-xs);
}

.reading-text blockquote {
  border-left: 3px solid var(--accent-primary);
  padding-left: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--text-accent);
  font-style: italic;
}

.reading-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
}

/* Loading */
.reading-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}

.loader {
  position: relative;
  width: 48px;
  height: 48px;
}

.loader-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  animation: spin 1.5s linear infinite;
}

.loader-ring:nth-child(1) {
  border-top-color: var(--accent-primary);
  animation-delay: 0s;
}

.loader-ring:nth-child(2) {
  border-right-color: var(--accent-rose);
  animation-delay: 0.2s;
  inset: 4px;
}

.loader-ring:nth-child(3) {
  border-bottom-color: var(--accent-gold);
  animation-delay: 0.4s;
  inset: 8px;
}

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

.loading-text {
  margin-top: var(--space-md);
  font-size: 0.85rem;
  color: var(--text-muted);
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* Error */
.reading-error {
  text-align: center;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.error-icon {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
}

.error-text {
  color: var(--accent-rose);
  font-size: 0.9rem;
  margin-bottom: var(--space-md);
  max-width: 400px;
}

.retry-btn {
  padding: 0.5rem 1.5rem;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-full);
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.retry-btn:hover {
  background: rgba(179, 136, 255, 0.25);
  transform: translateY(-1px);
}

/* --- Library Grid --- */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.library-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all 0.35s var(--ease-spring);
}

.library-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.lib-icon {
  font-size: 1.6rem;
  display: block;
  margin-bottom: var(--space-sm);
}

.library-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.library-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Custom question */
.custom-question {
  margin-bottom: var(--space-xl);
}

.custom-question h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  margin-bottom: var(--space-md);
  color: var(--text-accent);
}

.question-input-wrap {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

#custom-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 52px;
  transition: border-color 0.3s;
}

#custom-input::placeholder {
  color: var(--text-muted);
}

#custom-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-dim);
}

.send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--grad-primary);
  color: #0a0a18;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.3s var(--ease-spring);
}

.send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(179, 136, 255, 0.4);
}

.send-btn:active {
  transform: scale(0.95);
}

/* --- Settings --- */
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.setting-group {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.setting-group > label:first-child {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.setting-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

/* Model selector */
.model-selector {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.model-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.model-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-glow);
  color: var(--text-primary);
}

.model-btn.active {
  background: var(--accent-primary-dim);
  border-color: rgba(179, 136, 255, 0.3);
  color: var(--accent-primary);
}

.model-name {
  font-weight: 500;
}

.model-tag {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--accent-teal-dim);
  color: var(--accent-teal);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.3s var(--ease-spring), background 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-primary-dim);
  border-color: rgba(179, 136, 255, 0.3);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
  background: var(--accent-primary);
}

/* Partner Editor */
.partner-editor {
  margin-bottom: var(--space-md);
}

.partner-edit-form {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: var(--space-sm);
}

.form-row label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-row input {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
}

.form-row input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.form-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.cta-btn.small {
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
}

/* History actions */
.history-actions {
  display: flex;
  gap: var(--space-sm);
}

.secondary-btn {
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.secondary-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-glow);
}

.secondary-btn.danger {
  border-color: rgba(255, 85, 85, 0.3);
  color: #ff8888;
}

.secondary-btn.danger:hover {
  background: rgba(255, 85, 85, 0.1);
}

/* History panel */
.history-panel {
  margin-top: var(--space-xl);
}

.history-panel h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  margin-bottom: var(--space-md);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 400px;
  overflow-y: auto;
  padding-right: var(--space-sm);
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.history-item:hover {
  border-color: var(--border-glow);
  background: var(--bg-card-hover);
}

.history-item-topic {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-primary);
  margin-bottom: 0.2rem;
}

.history-item-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-item-date {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  margin-top: 0.3rem;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.7rem 1.2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-md);
  animation: slideUp 0.4s var(--ease-spring);
  font-size: 0.85rem;
}

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

.toast-icon {
  font-size: 1.1rem;
}

.toast-text {
  color: var(--text-primary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.3rem;
  margin-left: var(--space-sm);
}

.toast-close:hover {
  color: var(--text-primary);
}

/* --- Footer --- */
#main-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-2xl);
}

#main-footer p {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.95rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.footer-sub {
  font-family: 'Outfit', sans-serif !important;
  font-size: 0.72rem !important;
  margin-top: var(--space-xs);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(179, 136, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(179, 136, 255, 0.3);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  #main-nav {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
  }

  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.3rem;
  }

  .nav-btn {
    font-size: 0.78rem;
    padding: 0.4rem 0.8rem;
    white-space: nowrap;
  }

  .nav-model-status {
    font-size: 0.68rem;
  }

  #hero {
    padding: 6rem 1.2rem 3rem;
    min-height: 70vh;
  }

  .hero-charts {
    flex-direction: column;
    gap: var(--space-md);
  }

  .chart-link {
    transform: rotate(90deg);
  }

  .content-section {
    padding: 1.5rem 1.2rem 3rem;
  }

  .library-grid {
    grid-template-columns: 1fr 1fr;
  }

  .topic-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-sm);
  }

  .pill {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .reading-card {
    padding: var(--space-lg);
  }

  .settings-panel {
    gap: var(--space-md);
  }
}

@media (max-width: 480px) {
  .library-grid {
    grid-template-columns: 1fr;
  }

  .hero-charts {
    width: 100%;
  }

  .chart-card {
    width: 100%;
    min-width: unset;
  }
}
