:root {
  --bg-dark: #121212;
  --bg-medium: #1e1e1e;
  --bg-light: #2a2a2a;
  --kimi-blue: #4dabf7;
  --capital-red: #ff6b6b;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-muted: #7a7a7a;
  --bubble-user: #2d3748;
  /* New category colors for glossary */
  --philosophy-purple: #c084fc;
  --economy-amber: #fbbf24;
  --class-green: #4ade80;
  --strategy-orange: #fb923c;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 17px;
}

header {
  background: var(--bg-medium);
  padding: 3rem 2rem;
  text-align: center;
  border-bottom: 1px solid var(--bg-light);
}

h1 {
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.5px;
}

/* Purple "&" in title - parent link is purple, spans override their colors */
header h1 {
  color: #c084fc;
}

header h1 a {
  color: #c084fc;
  text-decoration: none;
}

.kimi { color: var(--kimi-blue); }
.capital { color: var(--capital-red); }

.tagline {
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 300;
}

main {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  width: 100%;
}

/* ==================== LINK CONTRAST FIXES ==================== */
a {
  color: var(--kimi-blue);
  text-decoration: underline;
  text-decoration-color: rgba(77, 171, 247, 0.3);
  transition: color 0.2s;
}

a:hover {
  color: var(--capital-red);
  text-decoration-color: var(--capital-red);
}

/* Light lavender for visited links - high contrast on dark bg */
a:visited {
  color: #e9d5ff;
  text-decoration-color: rgba(233, 213, 255, 0.3);
}

a:visited:hover {
  color: #f3e8ff;
  text-decoration-color: #f3e8ff;
}

/* Blog listing unchanged */
#posts-list a {
  display: block;
  padding: 1.5rem;
  margin-bottom: 1rem;
  background: var(--bg-medium);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: transform 0.2s, border-left 0.2s;
  border-left: 4px solid transparent;
}

#posts-list a:hover {
  transform: translateX(4px);
  border-left: 4px solid var(--kimi-blue);
}

.post-title { font-size: 1.3rem; margin-bottom: 0.5rem; }
.post-date { color: var(--text-secondary); font-size: 0.85rem; }

/* Post page styling */
#chat-container {
  padding: 0;
}

.post-header-title {
  font-size: 2.2rem;
  font-weight: 600;
  margin-bottom: 3rem;
  color: var(--text-primary);
  line-height: 1.3;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--bg-light);
}

/* Add below .post-header-title */
.post-meta {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: -2rem 0 3rem;
  text-align: center;
  font-weight: 300;
}

.post-meta::before,
.post-meta::after {
  content: '—';
  margin: 0 0.5rem;
  color: var(--text-muted);
}

/* User prompt - Softer, labeled */
.user-message {
  margin-bottom: 3rem;
}

.user-message .bubble {
  max-width: 85%;
  margin-left: auto;
  padding: 1.2rem 1.5rem;
  background: var(--bubble-user);
  color: var(--text-primary);
  border-radius: 16px;
  border-bottom-right-radius: 6px;
  font-size: 1rem;
  line-height: 1.6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.user-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* AI response - Magazine-style */
.ai-message {
  margin: 2.5rem 0;
}

.ai-message .bubble {
  max-width: 100%;
  padding: 0;
  background: transparent;
  color: var(--text-primary);
}

/* Section headers - Distinctive */
.ai-message .bubble h2 {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 3rem 0 1.2rem;
  padding-top: 2rem;
  color: var(--kimi-blue);
  position: relative;
}

.ai-message .bubble h2::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--bg-light), transparent);
}

.ai-message .bubble h3 {
  font-size: 1.2rem;
  font-weight: 500;
  margin: 1.8rem 0 0.8rem;
  color: var(--capital-red);
}

/* Paragraph spacing */
.ai-message .bubble p {
  margin-bottom: 1.2rem;
  line-height: 1.8;
}

.ai-message .bubble ul,
.ai-message .bubble ol {
  margin: 0.8rem 0 1.2rem 2rem;
}

.ai-message .bubble li {
  margin-bottom: 0.6rem;
}

/* Post content links - specific overrides for markdown content */
.ai-message .bubble a {
  color: var(--kimi-blue);
  text-decoration: underline;
  text-decoration-color: rgba(77, 171, 247, 0.4);
  border-bottom: none;
}

.ai-message .bubble a:visited {
  color: #d8b4fe;
  text-decoration-color: rgba(216, 180, 254, 0.4);
}

.ai-message .bubble a:hover {
  color: var(--capital-red);
  text-decoration-color: var(--capital-red);
}

/* Code blocks */
.bubble code {
  background: var(--bg-medium);
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.9em;
}

.bubble pre {
  background: var(--bg-medium);
  padding: 1.2rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.2rem 0;
  border: 1px solid var(--bg-light);
}

/* Blockquotes */
.bubble blockquote {
  border-left: 3px solid var(--kimi-blue);
  padding-left: 1.2rem;
  margin: 1.2rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Footer styling - centered and at bottom */
footer {
  text-align: center;
  padding: 2rem;
  margin-top: auto;
  color: var(--text-secondary);
  border-top: 1px solid var(--bg-light);
  background: var(--bg-medium);
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover {
  color: var(--kimi-blue);
}

/* ==================== GLOSSARY STYLES ==================== */

/* Navigation */
.nav-back {
  text-align: center;
  padding: 1rem;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--bg-light);
}

.nav-back a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.nav-back a:hover { color: var(--kimi-blue); }

/* Glossary uses wider container */
.glossary-page main {
  max-width: 800px;
}

/* Filter Controls */
.controls {
  margin-bottom: 3rem;
  padding: 1.5rem;
  background: var(--bg-medium);
  border-radius: 12px;
  border: 1px solid var(--bg-light);
}

.control-section {
  margin-bottom: 1.5rem;
}

.control-section:last-child { margin-bottom: 0; }

.control-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: block;
  font-weight: 600;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-btn {
  background: var(--bg-light);
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  font-family: inherit;
}

.filter-btn:hover {
  background: var(--bg-dark);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.filter-btn.active {
  background: var(--kimi-blue);
  color: var(--bg-dark);
  font-weight: 600;
}

.filter-btn.philosophy.active { 
  background: var(--philosophy-purple); 
  color: var(--bg-dark);
}
.filter-btn.economy.active { 
  background: var(--economy-amber); 
  color: var(--bg-dark);
}
.filter-btn.class-analysis.active { 
  background: var(--class-green); 
  color: var(--bg-dark);
}
.filter-btn.strategy.active { 
  background: var(--strategy-orange); 
  color: var(--bg-dark);
}

.alpha-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
}

.alpha-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--bg-light);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.alpha-btn:hover {
  background: var(--kimi-blue);
  color: var(--bg-dark);
  transform: scale(1.1);
}

.alpha-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* Stats */
.glossary-stats {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  font-style: italic;
}

/* Term Cards */
.term {
  margin-bottom: 2.5rem;
  padding: 2rem;
  background: var(--bg-medium);
  border-radius: 12px;
  border-left: 4px solid var(--bg-light);
  transition: all 0.3s;
  scroll-margin-top: 2rem;
}

.term:hover {
  border-left-color: var(--kimi-blue);
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.term.philosophy { border-left-color: var(--philosophy-purple); }
.term.economy { border-left-color: var(--economy-amber); }
.term.class-analysis { border-left-color: var(--class-green); }
.term.strategy { border-left-color: var(--strategy-orange); }

.term-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.term-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.5px;
}

.term-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-weight: 600;
  background: var(--bg-light);
}

.tag.philosophy { background: rgba(192, 132, 252, 0.2); color: var(--philosophy-purple); }
.tag.economy { background: rgba(251, 191, 36, 0.2); color: var(--economy-amber); }
.tag.class-analysis { background: rgba(74, 222, 128, 0.2); color: var(--class-green); }
.tag.strategy { background: rgba(251, 146, 60, 0.2); color: var(--strategy-orange); }

.term-content {
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 1rem;
}

.term-content p { margin-bottom: 1rem; }
.term-content p:last-child { margin-bottom: 0; }

/* Cross-references in terms - specific overrides for glossary */
.term-content a {
  color: var(--kimi-blue);
  text-decoration: none;
  border-bottom: 1px dotted var(--kimi-blue);
  transition: all 0.2s;
}

.term-content a:hover {
  color: var(--capital-red);
  border-bottom-color: var(--capital-red);
}

.cross-refs {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bg-light);
}

.cross-refs a {
  color: var(--kimi-blue);
  text-decoration: none;
  border-bottom: 1px dotted var(--kimi-blue);
  transition: all 0.2s;
}

.cross-refs a:hover {
  color: var(--capital-red);
  border-bottom-color: var(--capital-red);
}

.key-readings {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-dark);
  border-radius: 8px;
  border-left: 3px solid var(--capital-red);
}

.key-readings-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--capital-red);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.key-readings-content {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Hide terms when filtered */
.term.hidden { display: none; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  font-style: italic;
  display: none;
}

.empty-state.visible { display: block; }

/* Mobile */
@media (max-width: 600px) {
  body { font-size: 16px; }
  main { padding: 2rem 1rem; }
  .post-header-title { font-size: 1.8rem; }
  .user-message .bubble { max-width: 90%; }
  
  /* Glossary mobile adjustments */
  .term { padding: 1.5rem; }
  .term-title { font-size: 1.3rem; }
  .filter-buttons { gap: 0.4rem; }
  .filter-btn { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
}

/* Example/Metaphor styling */
.term-example {
  margin: 1rem 0;
  padding: 1rem 1.2rem;
  background: rgba(77, 171, 247, 0.08);
  border-left: 3px solid var(--kimi-blue);
  border-radius: 0 8px 8px 0;
}

.term-example-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--kimi-blue);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.term-example-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.7;
}

/* Update cross-refs to handle multiple see-alsos cleanly */
.cross-refs {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bg-light);
}

.cross-refs strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.top-nav {
  text-align: center;
  padding: 1rem;
  background: var(--bg-medium);
  border-bottom: 1px solid var(--bg-light);
}

.top-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  transition: color 0.2s;
  border-bottom: 1px dotted var(--text-muted);
  padding-bottom: 2px;
}

.top-nav a:hover {
  color: var(--kimi-blue);
  border-bottom-color: var(--kimi-blue);
}