:root {
  --purple-deep: #1a0a2e;
  --black-midnight: #0d0d0d;
  --white-ghostly: #e8e8e8;
  --red-blood: #8b0000;
  --amber-candle: #ffbf00;
  --purple-muted: #2d1b4e;
  --violet-dark: #1e0f2e;
}

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

body {
  font-family: 'Crimson Pro', serif;
  background: linear-gradient(180deg, var(--black-midnight) 0%, var(--purple-deep) 50%, var(--violet-dark) 100%);
  min-height: 100vh;
  color: var(--white-ghostly);
  overflow-x: hidden;
}

.app-container {
  min-height: 100vh;
  position: relative;
}

/* Fog effect */
.fog-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.fog-particle {
  position: absolute;
  bottom: -50px;
  width: 300px;
  height: 100px;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.08) 0%, transparent 70%);
  animation: fog-drift 20s linear infinite;
  filter: blur(30px);
}

@keyframes fog-drift {
  0% { transform: translateX(-100%); opacity: 0; }
  10% { opacity: 0.5; }
  90% { opacity: 0.5; }
  100% { transform: translateX(100vw); opacity: 0; }
}

/* Candle */
.candle {
  position: fixed;
  z-index: 2;
  pointer-events: none;
}

.candle-body {
  width: 20px;
  height: 60px;
  background: linear-gradient(to bottom, #f5e6d3, #d4c4a8);
  border-radius: 2px;
}

.flame {
  width: 14px;
  height: 35px;
  background: radial-gradient(ellipse at bottom, var(--amber-candle) 0%, #ff6b00 40%, transparent 70%);
  position: absolute;
  bottom: 55px;
  left: 3px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: flicker 0.5s ease-in-out infinite alternate;
  filter: blur(1px);
  box-shadow: 0 0 30px 15px rgba(255, 191, 0, 0.3), 0 0 60px 30px rgba(255, 107, 0, 0.2);
}

@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-2deg); opacity: 1; }
  50% { transform: scale(0.95, 1.05) rotate(2deg); opacity: 0.9; }
}

/* Raven */
.raven-perch {
  position: fixed;
  top: 80px;
  right: 10%;
  z-index: 10;
  animation: raven-bob 4s ease-in-out infinite;
}

.raven-svg {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
}

.raven-eye {
  fill: var(--red-blood);
  animation: eye-glow 3s ease-in-out infinite;
}

@keyframes eye-glow {
  0%, 100% { fill: var(--red-blood); filter: none; }
  50% { fill: #ff0000; filter: drop-shadow(0 0 8px #ff0000); }
}

@keyframes raven-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(1deg); }
}

/* Header */
.header {
  padding: 2rem 1rem;
  text-align: center;
  position: relative;
  z-index: 5;
  background: linear-gradient(to bottom, rgba(13,13,13,0.9), transparent);
}

.title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-shadow: 0 0 30px rgba(139, 0, 0, 0.5), 2px 2px 4px rgba(0,0,0,0.8);
  animation: title-glow 5s ease-in-out infinite;
}

@keyframes title-glow {
  0%, 100% { text-shadow: 0 0 30px rgba(139, 0, 0, 0.5), 2px 2px 4px rgba(0,0,0,0.8); }
  50% { text-shadow: 0 0 50px rgba(139, 0, 0, 0.7), 2px 2px 4px rgba(0,0,0,0.8); }
}

.subtitle {
  font-style: italic;
  font-size: 1.1rem;
  color: rgba(232, 232, 232, 0.7);
  margin-top: 0.5rem;
}

.disclaimer {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.3rem 0.8rem;
  background: rgba(139, 0, 0, 0.3);
  border: 1px solid var(--red-blood);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--amber-candle);
}

/* Main content */
.main-content {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 5;
  min-height: 60vh;
}

.main-content.mobile {
  flex-direction: column;
}

/* Poem panel */
.poem-panel {
  flex: 0 0 40%;
  transition: all 0.5s ease;
}

.poem-panel.collapsed {
  flex: 0 0 40px;
}

.mobile .poem-panel {
  flex: none;
}

.toggle-poem {
  background: rgba(45, 27, 78, 0.8);
  border: 1px solid var(--purple-muted);
  color: var(--white-ghostly);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-family: 'Crimson Pro', serif;
  width: 100%;
  text-align: left;
  transition: all 0.3s;
}

.toggle-poem:hover {
  background: rgba(139, 0, 0, 0.3);
}

.poem-content {
  max-height: 70vh;
  overflow-y: auto;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.parchment {
  background: linear-gradient(135deg, #2a1f1a 0%, #1a1510 50%, #2a1f1a 100%);
  border: 3px solid #3d2b1f;
  border-radius: 4px;
  padding: 1.5rem;
  position: relative;
  box-shadow: inset 0 0 50px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.5);
}

.parchment::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.3;
}

.poem-line {
  font-family: 'Crimson Pro', serif;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #c9b896;
  padding: 0.3rem 0.5rem;
  margin: 0.2rem 0;
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 2px;
}

.poem-line:hover {
  background: rgba(139, 0, 0, 0.2);
  color: var(--white-ghostly);
}

.poem-line.highlighted {
  background: rgba(255, 191, 0, 0.2);
  box-shadow: 0 0 20px rgba(255, 191, 0, 0.3);
  color: var(--amber-candle);
}

.stanza-break {
  height: 1rem;
}

.tooltip-word {
  border-bottom: 1px dotted var(--amber-candle);
  cursor: help;
}

.word-tooltip {
  position: fixed;
  background: rgba(13, 13, 13, 0.95);
  border: 1px solid var(--red-blood);
  padding: 0.5rem 0.8rem;
  border-radius: 4px;
  font-size: 0.8rem;
  max-width: 250px;
  z-index: 100;
  pointer-events: none;
  animation: tooltipFade 0.2s ease;
}

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

/* Chat panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(13, 13, 13, 0.7);
  border: 2px solid var(--purple-muted);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(26, 10, 46, 0.5), inset 0 0 30px rgba(0, 0, 0, 0.3);
}

.mood-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(26, 10, 46, 0.5);
  border-bottom: 1px solid var(--purple-muted);
  align-items: center;
  font-size: 0.85rem;
}

.mood-btn {
  background: transparent;
  border: 1px solid var(--purple-muted);
  color: var(--white-ghostly);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'Crimson Pro', serif;
  transition: all 0.3s;
}

.mood-btn:hover, .mood-btn.active {
  background: var(--red-blood);
  border-color: var(--red-blood);
}

.quote-btn {
  background: transparent;
  border: 1px solid var(--amber-candle);
  color: var(--amber-candle);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'Crimson Pro', serif;
  margin-left: auto;
  transition: all 0.3s;
}

.quote-btn:hover {
  background: rgba(255, 191, 0, 0.2);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 300px;
}

.welcome-message {
  text-align: center;
  color: rgba(232, 232, 232, 0.6);
  font-style: italic;
  padding: 2rem;
}

.welcome-message .hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--amber-candle);
}

.message {
  display: flex;
  gap: 0.75rem;
  animation: messageSlide 0.4s ease;
  max-width: 90%;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.raven {
  align-self: flex-start;
}

.raven-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.message-content {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--purple-muted), var(--purple-deep));
  border: 1px solid rgba(139, 0, 0, 0.3);
}

.message.raven .message-content {
  background: linear-gradient(135deg, rgba(13, 13, 13, 0.9), rgba(26, 10, 46, 0.9));
  border: 1px solid var(--purple-muted);
  box-shadow: 0 0 15px rgba(139, 0, 0, 0.2);
}

.raven-message {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cryptic-text {
  transition: opacity 0.3s ease;
  line-height: 1.8;
  letter-spacing: 0.02em;
}

.cryptic-text.faded {
  opacity: 0.5;
}

.plain-text {
  background: rgba(255, 191, 0, 0.1);
  border-left: 3px solid var(--amber-candle);
  padding: 0.75rem;
  border-radius: 0 8px 8px 0;
  font-family: 'Crimson Pro', serif;
  font-size: 0.95rem;
  color: rgba(232, 232, 232, 0.9);
  animation: slideIn 0.3s ease;
}

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

.translation-label {
  color: var(--amber-candle);
  font-weight: 600;
  font-size: 0.85rem;
}

.translate-btn {
  align-self: flex-start;
  background: transparent;
  border: 1px dashed rgba(255, 191, 0, 0.4);
  color: var(--amber-candle);
  padding: 0.35rem 0.75rem;
  border-radius: 15px;
  cursor: pointer;
  font-family: 'Crimson Pro', serif;
  font-size: 0.75rem;
  transition: all 0.3s ease;
  opacity: 0.7;
}

.translate-btn:hover {
  opacity: 1;
  background: rgba(255, 191, 0, 0.15);
  border-style: solid;
  box-shadow: 0 0 10px rgba(255, 191, 0, 0.2);
}

.typing-indicator {
  font-style: italic;
  color: rgba(232, 232, 232, 0.7);
}

.dots {
  animation: dotPulse 1.5s infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.input-form {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(26, 10, 46, 0.5);
  border-top: 1px solid var(--purple-muted);
}

.chat-input {
  flex: 1;
  background: rgba(13, 13, 13, 0.8);
  border: 1px solid var(--purple-muted);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--white-ghostly);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.chat-input::placeholder {
  color: rgba(232, 232, 232, 0.4);
  font-style: italic;
}

.chat-input:focus {
  outline: none;
  border-color: var(--red-blood);
  box-shadow: 0 0 15px rgba(139, 0, 0, 0.3);
}

.send-btn {
  background: var(--red-blood);
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.3s;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(139, 0, 0, 0.5);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Word cloud */
.word-cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 5;
}

.cloud-word {
  color: var(--purple-muted);
  font-family: 'Playfair Display', serif;
  font-style: italic;
  transition: all 0.3s;
  cursor: default;
}

.cloud-word:hover {
  color: var(--amber-candle);
  text-shadow: 0 0 10px rgba(255, 191, 0, 0.5);
}

/* Special animation */
.special-animation {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: flashIn 0.3s ease;
}

@keyframes flashIn {
  0% { background: rgba(139, 0, 0, 0.8); }
  100% { background: rgba(0, 0, 0, 0.8); }
}

.nevermore-burst {
  font-family: 'Playfair Display', serif;
  font-size: clamp(3rem, 10vw, 8rem);
  font-weight: 900;
  color: var(--red-blood);
  text-shadow: 0 0 50px var(--red-blood), 0 0 100px var(--red-blood);
  animation: burst 2s ease-out;
}

@keyframes burst {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

.feather {
  position: absolute;
  font-size: 2rem;
  animation: featherFall 3s ease-in infinite;
}

@keyframes featherFall {
  0% { transform: translateY(-100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

/* Footer */
.footer {
  background: linear-gradient(to bottom, transparent, rgba(58, 42, 30, 0.3));
  padding: 2rem 1rem;
  text-align: center;
  position: relative;
  z-index: 5;
  border-top: 1px solid rgba(61, 43, 31, 0.5);
}

.footer p {
  color: rgba(232, 232, 232, 0.5);
  font-size: 0.85rem;
  margin: 0.3rem 0;
}

.credit {
  font-style: italic;
  color: var(--amber-candle) !important;
  opacity: 0.7;
}

.remix-link {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.5rem 1.5rem;
  background: var(--red-blood);
  color: var(--white-ghostly);
  text-decoration: none;
  border-radius: 20px;
  font-family: 'Crimson Pro', serif;
  transition: all 0.3s;
  position: relative;
}

.remix-link::before {
  content: '';
  position: absolute;
  inset: -5px;
  background: radial-gradient(ellipse at center, rgba(139, 0, 0, 0.5) 0%, transparent 70%);
  border-radius: 25px;
  z-index: -1;
  animation: inkSpread 2s ease-in-out infinite;
}

@keyframes inkSpread {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.remix-link:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(139, 0, 0, 0.5);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--black-midnight);
}

::-webkit-scrollbar-thumb {
  background: var(--purple-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--red-blood);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .raven-perch {
    top: 20px;
    right: 5%;
  }
  
  .raven-svg {
    width: 50px;
    height: 50px;
  }
  
  .header {
    padding: 1rem;
  }
  
  .candle {
    display: none;
  }
  
  .poem-content {
    max-height: 40vh;
  }
  
  .mood-selector {
    font-size: 0.75rem;
  }
  
  .mood-selector span {
    width: 100%;
    text-align: center;
  }
}