@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap');

:root {
  --bg-start: #020817;
  --bg-end: #020817;
  --flame-deep: #1f0a0a;
  --flame-outer: #7f1d1d;
  --flame-mid: #fb923c;
  --flame-inner: #fff7ed;
  --flame-size: 56px;
  --spirit-size: 86%;
}

/* Base layout */

body {
  margin: 0;
  height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #020203;
  background: radial-gradient(circle at top, var(--bg-start), var(--bg-end));
  background-attachment: fixed;
  transition: background 1.2s ease, filter 1.2s ease;
  user-select: none;
}

/* ============================================================================
   QUANTUM FIELD STABILIZER
   ============================================================================ */

#field-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
}

#field-container canvas {
  pointer-events: auto;
}

/* Settings gear button (top-right, inside ember-interface) */
.settings-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 166, 0, 0.3);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.settings-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  color: #ffaa00;
  border-color: rgba(255, 166, 0, 0.6);
}

/* Field Controls Panel */
#field-controls {
  position: fixed;
  top: 72px;
  right: 20px;
  width: 260px;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 166, 0, 0.3);
  border-radius: 8px;
  padding: 16px;
  color: #fff;
  backdrop-filter: blur(10px);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 11px;
  z-index: 100;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#field-controls.visible {
  opacity: 1;
  transform: translateX(0);
}

#field-controls::-webkit-scrollbar {
  width: 5px;
}

#field-controls::-webkit-scrollbar-track {
  background: #111;
}

#field-controls::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 2px;
}

#field-controls .section-title {
  color: #fff;
  font-size: 12px;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
  margin-bottom: 8px;
  margin-top: 12px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#field-controls .section-title:first-child {
  margin-top: 0;
}

#field-controls .control-group {
  margin-bottom: 8px;
}

#field-controls .control-group label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  color: #ccc;
}

#field-controls .control-group span {
  color: #ffaa00;
}

#field-controls input[type="range"] {
  width: 100%;
  height: 4px;
  background: #333;
  outline: none;
  -webkit-appearance: none;
  border-radius: 2px;
}

#field-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: #ffaa00;
  border-radius: 50%;
  cursor: pointer;
}

#field-controls input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #ffaa00;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

#field-controls .checkbox-group {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  cursor: pointer;
}

#field-controls .checkbox-group input {
  margin-right: 8px;
  cursor: pointer;
  accent-color: #ffaa00;
}

/* Responsive: hide controls on smaller screens */
@media (max-width: 700px) {
  #field-controls {
    width: 200px;
    padding: 12px;
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  #field-controls {
    display: none;
  }
}

/* ============================================================================
   UI LAYER - Subtitle display area
   ============================================================================ */

#ui-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 200px;
}

/* ============================================================================
   SUBTITLE AREA (Word-by-Word Display)
   ============================================================================ */

#subtitle-area {
  width: 90%;
  max-width: 900px;
  text-align: center;
  margin-bottom: 20px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.subtitle-text {
  font-size: 28px;
  line-height: 1.6;
  font-weight: 400;
  color: #ffffff;
  text-shadow: 0 2px 20px rgba(0,0,0,0.9), 0 0 40px rgba(0,0,0,0.5);
  opacity: 0.95;
  transition: all 0.3s ease;
  letter-spacing: 0.02em;
}

.subtitle-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(12px);
  animation-name: wordAppear;
  animation-duration: 0.4s;
  animation-fill-mode: forwards;
  animation-timing-function: ease-out;
  margin-right: 8px;
}

.subtitle-word.active {
  color: #FFC857;
  text-shadow: 0 0 20px rgba(255, 200, 87, 0.9), 0 0 40px rgba(255, 200, 87, 0.5);
}

@keyframes wordAppear {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Aligned transcript (token-synced display) */
#alignedTranscript {
  margin-top: 12px;
  max-width: 800px;
  font-size: 18px;
  color: #cbd5e1;
  line-height: 1.6;
  text-align: center;
  word-wrap: break-word;
  display: none;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

/* Mood backgrounds */

body.mood-calm {
  background: radial-gradient(circle at top, #020817, #020817);
  filter: saturate(1);
}

body.mood-reflective {
  background: radial-gradient(circle at top, #020817, #111827);
  filter: saturate(0.9);
}

body.mood-alert {
  background: radial-gradient(circle at top, #160b0b, #020817);
  filter: saturate(1.1);
}

.ember-wrapper {
  position: relative;
  text-align: center;
  z-index: 1;
}

/* Hide main interface until welcome dismissed */

#ember-interface {
  display: none;
}

/* BACKGROUND FLOATING EMBERS */

#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

#particles::before,
#particles::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.9), transparent);
  opacity: 0.8;
  animation: bgSparks 18s linear infinite;
}

#particles::before {
  left: 15%;
  bottom: -40px;
  box-shadow:
    0 40px 0 rgba(249, 115, 22, 0.18),
    18px 110px 0 rgba(248, 250, 252, 0.12),
    -22px 190px 0 rgba(249, 115, 22, 0.16),
    30px 270px 0 rgba(248, 250, 252, 0.08),
    -10px 350px 0 rgba(249, 115, 22, 0.14);
}

#particles::after {
  left: 80%;
  bottom: -40px;
  animation-duration: 22s;
  box-shadow:
    0 60px 0 rgba(248, 250, 252, 0.12),
    -24px 140px 0 rgba(249, 115, 22, 0.18),
    26px 220px 0 rgba(248, 250, 252, 0.1),
    -12px 300px 0 rgba(248, 250, 252, 0.14),
    8px 380px 0 rgba(248, 250, 252, 0.08);
}

@keyframes bgSparks {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  12% {
    opacity: 0.9;
  }
  80% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(-420px);
    opacity: 0;
  }
}

/* WELCOME SCREEN */

#welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top, rgba(120, 53, 220, 0.12), transparent),
    radial-gradient(circle at bottom, rgba(15, 23, 42, 0.96), #020817);
  backdrop-filter: blur(14px);
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#welcome-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.welcome-inner {
  max-width: 640px;
  padding: 3rem 3.5rem;
  border-radius: 32px;
  background: radial-gradient(circle at top left, rgba(148, 163, 253, 0.06), transparent)
    ,rgba(2, 6, 23, 0.96);
  box-shadow:
    0 18px 90px rgba(15, 23, 42, 0.9),
    0 0 40px rgba(79, 70, 229, 0.18);
  border: 1px solid rgba(148, 163, 253, 0.18);
  text-align: left;
  position: relative;
  overflow: hidden;
}

.welcome-inner::before {
  content: "";
  position: absolute;
  inset: -30%;
  background:
    radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.06), transparent),
    radial-gradient(circle at 100% 0, rgba(79, 70, 229, 0.08), transparent);
  opacity: 0.8;
  mix-blend-mode: screen;
  pointer-events: none;
}

.welcome-inner h1 {
  font-size: 2.4rem;
  margin: 0 0 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e5e7eb;
}

.welcome-subtitle {
  font-size: 1rem;
  margin: 0 0 1.4rem;
  color: #9ca3af;
}

.welcome-body {
  font-size: 0.95rem;
  margin: 0 0 0.8rem;
  color: #cbd5f5;
}

/* Username input on welcome screen */
.username-input-wrapper {
  margin-top: 1.5rem;
  text-align: left;
}

.username-label {
  display: block;
  font-size: 0.85rem;
  color: #9ca3af;
  margin-bottom: 0.4rem;
}

.username-input {
  width: 100%;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 253, 0.2);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

.username-input:focus {
  outline: none;
  border-color: rgba(249, 115, 22, 0.5);
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.2);
}

.username-input::placeholder {
  color: #64748b;
}

#enterEmberBtn {
  margin-top: 1.6rem;
  padding: 0.7rem 1.9rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(to right, #4f46e5, #f97316);
  color: #f9fafb;
  font-size: 0.95rem;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow:
    0 10px 40px rgba(15, 23, 42, 0.9),
    0 0 24px rgba(249, 115, 22, 0.6);
  transition: all 0.3s ease;
}

#enterEmberBtn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 16px 50px rgba(15, 23, 42, 0.95),
    0 0 32px rgba(249, 115, 22, 0.9);
}

/* FLAME CLUSTER (removed - replaced by Three.js ember core) */

.flame-cluster {
  display: none;
}

/* Legacy ember container - kept for JS state hooks but visually inactive */
#ember {
  display: none;
}

/* Text + button */

/* Status text for feedback messages */
#status {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #94a3b8;
  text-align: center;
  min-height: 1.5em;
  transition: color 0.3s ease;
}

.status-text {
  position: relative;
  z-index: 4;
}

/* Warning note in welcome screen */
.welcome-note {
  margin-top: 1.2rem;
  padding: 0.8rem 1rem;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 8px;
  font-size: 0.85rem;
  color: #fbbf24;
}

.warning-icon {
  margin-right: 0.4rem;
}

#micBtn {
  background: transparent;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 0.5rem 1.4rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
}

#micBtn:hover:not(:disabled) {
  box-shadow: 0 0 14px rgba(148, 163, 253, 0.35);
}

#micBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

#micBtn.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #fca5a5;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  animation: pulse-red 1.2s ease-in-out infinite;
}

@keyframes pulse-red {
  0%, 100% {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  }
  50% {
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
  }
}

/* Voice controls dropdown */
.voice-controls {
  margin-bottom: 1.2rem;
  text-align: center;
  position: relative;
  z-index: 2;
}

.voice-controls label {
  display: inline-block;
  margin-right: 0.6rem;
  color: #cbd5f5;
  font-size: 0.9rem;
}

#voiceSelect {
  background: rgba(51, 65, 85, 0.6);
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

#voiceSelect:hover {
  box-shadow: 0 0 10px rgba(148, 163, 253, 0.25);
  border-color: #64748b;
}

#voiceSelect:focus {
  outline: none;
  box-shadow: 0 0 12px rgba(148, 163, 253, 0.4);
  border-color: #94a3b8;
}

/* #reply is not used in new layout - subtitles display in #current-subtitle */
#reply {
  display: none;
}

/* Old aligned transcript styles removed - see #alignedTranscript above */

.token {
  display: inline;
  position: relative;
  padding: 0.1em 0.05em;
  border-radius: 4px;
  transition: all 0.05s ease;
  color: #cbd5e1;
}

.token.active-token {
  color: #fef08a;
  background: rgba(251, 191, 36, 0.15);
  font-weight: 600;
  box-shadow: 
    0 0 12px rgba(251, 191, 36, 0.4),
    inset 0 0 8px rgba(251, 191, 36, 0.1);
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.3);
}

/* Reduced motion: simplify token highlighting */
@media (prefers-reduced-motion: reduce) {
  .token {
    transition: none;
  }
}

/* ============================================================================
   STATUS PILL (Listening indicator)
   ============================================================================ */

.status-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  padding: 10px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.status-pill.listening {
  border-color: #FF5E3A;
  color: #fff;
  background: linear-gradient(90deg, rgba(255, 94, 58, 0.2), rgba(255, 42, 109, 0.2));
  box-shadow: 0 0 30px rgba(255, 77, 77, 0.4);
  transform: scale(1.05);
}

.mic-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 10px currentColor;
}

/* Reply particle burst - kept for visual feedback */
.reply-burst-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  height: 400px;
  z-index: 5;
  pointer-events: none;
}

.reply-burst-particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 25%, #fff9f0, #ffb86b 45%, #ff6b6b 100%);
  box-shadow: 0 8px 30px rgba(79,70,229,0.12), 0 0 28px rgba(249,115,22,0.12);
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0.98;
  animation: burstOut 700ms cubic-bezier(.2,.8,.2,1) forwards;
}

@keyframes burstOut {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.98; }
  60% { opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(var(--s, 0.9)); opacity: 0; }
}

/* Reduced motion: simplify animations but keep staggered appearance */
@media (prefers-reduced-motion: reduce) {
  .reply-burst-particle { animation: none !important; opacity: 0.0 !important; }
  /* Keep word appearance animation but use simple fade instead of movement */
  .subtitle-word { 
    transform: none !important; 
    animation-name: wordAppearSimple !important;
  }
}

@keyframes wordAppearSimple {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* Toast notification for error messages */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: rgba(239, 68, 68, 0.95);
  color: #fff;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.3),
    0 0 8px rgba(239, 68, 68, 0.4);
  margin-bottom: 0.75rem;
  min-width: 280px;
  max-width: 400px;
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.toast-message {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.4;
  font-weight: 500;
}

.toast-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.fade-out {
  animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* UI overlay - not used in new layout */
.ui-overlay {
  display: none;
}

/* ============================================================================
   BOTTOM CONTROLS - Left side grouping
   ============================================================================ */

.controls-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  pointer-events: none;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

/* Left control group - mic button and mode toggle */
.controls-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  pointer-events: auto;
}

.controls-bottom .voice-controls {
  pointer-events: auto;
}

.controls-bottom #micBtn {
  pointer-events: auto;
}

/* ============================================================================
   DUAL-MODE TOGGLE (Sanctuary / Lab)
   ============================================================================ */

.mode-toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(100, 116, 139, 0.3);
  border-radius: 24px;
  color: #e2e8f0;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
}

.mode-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(148, 163, 184, 0.5);
  transform: scale(1.02);
}

.mode-btn:active {
  transform: scale(0.98);
}

.mode-btn .mode-icon {
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.mode-btn .mode-label {
  font-weight: 500;
}

/* Sanctuary mode styling */
.mode-btn[data-mode="sanctuary"] {
  border-color: rgba(251, 146, 60, 0.3);
  box-shadow: 0 0 20px rgba(251, 146, 60, 0.1);
}

.mode-btn[data-mode="sanctuary"]:hover {
  border-color: rgba(251, 146, 60, 0.5);
  box-shadow: 0 0 30px rgba(251, 146, 60, 0.2);
}

/* Lab mode styling */
.mode-btn[data-mode="lab"] {
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

.mode-btn[data-mode="lab"]:hover {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
}

.mode-btn[data-mode="lab"] .mode-icon {
  animation: labPulse 2s ease-in-out infinite;
}

@keyframes labPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.mode-hint {
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.7);
  padding-left: 8px;
  transition: opacity 0.3s ease;
}

/* ============================================================================
   SOURCE INSPECTOR MODAL
   ============================================================================ */

.source-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: modalFadeIn 0.2s ease;
}

.source-modal[aria-hidden="false"] {
  display: flex;
}

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

.source-modal-content {
  max-width: 600px;
  max-height: 70vh;
  width: 90%;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(100, 116, 139, 0.3);
  border-radius: 16px;
  overflow: hidden;
  animation: modalSlideIn 0.3s ease;
}

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

.source-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(30, 41, 59, 0.5);
  border-bottom: 1px solid rgba(100, 116, 139, 0.2);
}

.source-modal-header h3 {
  margin: 0;
  color: #e2e8f0;
  font-size: 1.1rem;
}

.source-modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.source-modal-close:hover {
  background: rgba(100, 116, 139, 0.2);
  color: #e2e8f0;
}

.source-modal-body {
  padding: 20px;
  max-height: calc(70vh - 80px);
  overflow-y: auto;
  color: #cbd5e1;
  line-height: 1.6;
}

.source-chunk {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
  border-left: 3px solid rgba(59, 130, 246, 0.5);
}

.source-chunk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.source-chunk-filename {
  color: #60a5fa;
  font-weight: 500;
}

.source-chunk-score {
  color: #94a3b8;
  font-size: 0.75rem;
}

.source-chunk-text {
  font-size: 0.9rem;
  color: #e2e8f0;
  white-space: pre-wrap;
}

.source-chunk-text::first-letter {
  text-transform: capitalize;
}

/* Source indicator button (appears next to Lab mode replies) */
.source-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  margin-left: 8px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 12px;
  color: #60a5fa;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.source-indicator:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
}

/* Empty state for no sources */
.source-empty {
  text-align: center;
  color: #94a3b8;
  padding: 20px;
  font-style: italic;
}

/* ============================================================================
   TEXT INPUT BOX (Bottom Center)
   ============================================================================ */

.text-input-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  width: 90%;
  max-width: 600px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.text-input-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(100, 116, 139, 0.3);
  border-radius: 28px;
  padding: 4px 4px 4px 20px;
  backdrop-filter: blur(12px);
  box-shadow: 
    0 4px 24px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.text-input-wrapper:focus-within {
  border-color: rgba(249, 115, 22, 0.5);
  box-shadow: 
    0 4px 32px rgba(0, 0, 0, 0.5),
    0 0 24px rgba(249, 115, 22, 0.15),
    0 0 0 1px rgba(249, 115, 22, 0.1) inset;
  transform: scale(1.01);
}

.text-input-wrapper:hover:not(:focus-within) {
  border-color: rgba(100, 116, 139, 0.5);
  background: rgba(15, 23, 42, 0.9);
}

.text-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-size: 1rem;
  font-family: inherit;
  padding: 12px 12px 12px 0;
  outline: none;
  min-width: 0;
  caret-color: #f97316;
}

.text-input::placeholder {
  color: #64748b;
  transition: color 0.2s ease;
}

.text-input:focus::placeholder {
  color: #475569;
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: white;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.5);
  background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
}

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

.send-btn:disabled {
  background: rgba(71, 85, 105, 0.5);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.5;
}

.send-btn:disabled .send-icon {
  opacity: 0.5;
}

.send-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.send-btn:hover:not(:disabled) .send-icon {
  transform: translateX(2px);
}

.text-input-hint {
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.6);
  text-align: center;
  transition: opacity 0.3s ease;
}

.text-input-wrapper:focus-within + .text-input-hint {
  opacity: 0.4;
}

/* Sending state animation */
.text-input-wrapper.sending {
  pointer-events: none;
}

.text-input-wrapper.sending .text-input {
  color: #94a3b8;
}

.text-input-wrapper.sending .send-btn {
  animation: sendPulse 1s ease-in-out infinite;
}

@keyframes sendPulse {
  0%, 100% { 
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
  }
  50% { 
    box-shadow: 0 2px 16px rgba(249, 115, 22, 0.6);
  }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .text-input-container {
    bottom: 90px;
    width: 94%;
    max-width: none;
    padding: 0 12px;
  }
  
  .text-input-wrapper {
    padding: 3px 3px 3px 16px;
  }
  
  .text-input {
    font-size: 0.95rem;
    padding: 10px 10px 10px 0;
  }
  
  .send-btn {
    width: 40px;
    height: 40px;
  }
  
  .send-icon {
    width: 18px;
    height: 18px;
  }
  
  .text-input-hint {
    font-size: 0.7rem;
  }
}

/* Hide text input when recording */
.text-input-container.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}


/* ============================================================================
   GOOGLE AUTH STYLES
   ============================================================================ */

#googleAuthSection {
  margin-bottom: 1.5rem;
  text-align: center;
}

.google-signin-btn {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.auth-hint {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.5rem;
}

.auth-user-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 107, 53, 0.12);
  border: 1px solid rgba(255, 107, 53, 0.25);
  border-radius: 12px;
  margin-bottom: 0.5rem;
}

.auth-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 107, 53, 0.4);
}

.auth-user-name {
  font-size: 1rem;
  font-weight: 500;
  color: #ff9a5c;
}


/* ============================================================================
   STUDY ARTIFACTS OVERLAY
   Premium glassmorphism overlay with artifact carousel
   ============================================================================ */

/* --- Backdrop: dim + blur the entire app --- */

.artifacts-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(2, 4, 12, 0.72);
  backdrop-filter: blur(18px) saturate(0.6);
  -webkit-backdrop-filter: blur(18px) saturate(0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.artifacts-backdrop[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

/* --- Overlay panel --- */

.artifacts-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px) scale(0.97);
  transition:
    opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.artifacts-overlay[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* --- Close button --- */

.artifacts-close {
  position: absolute;
  top: 24px;
  right: 32px;
  z-index: 110;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 200, 100, 0.12);
  border-radius: 12px;
  color: rgba(255, 210, 140, 0.7);
  font-size: 1.6rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.25s ease;
}

.artifacts-close:hover {
  background: rgba(255, 180, 80, 0.1);
  border-color: rgba(255, 180, 80, 0.35);
  color: #ffd699;
  transform: scale(1.08);
  box-shadow: 0 0 20px rgba(255, 165, 50, 0.15);
}

/* --- Header introduction --- */

.artifacts-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 40px;
  max-width: 900px;
  width: 100%;
}

.artifacts-ember-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 60%,
      rgba(255, 180, 60, 0.95) 0%,
      rgba(255, 120, 30, 0.8) 40%,
      rgba(200, 60, 10, 0.5) 70%,
      transparent 100%);
  box-shadow:
    0 0 16px rgba(255, 150, 40, 0.6),
    0 0 40px rgba(255, 100, 20, 0.25);
  animation: emberIconPulse 3s ease-in-out infinite;
}

@keyframes emberIconPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(255, 150, 40, 0.6), 0 0 40px rgba(255, 100, 20, 0.25); transform: scale(1); }
  50% { box-shadow: 0 0 22px rgba(255, 150, 40, 0.8), 0 0 50px rgba(255, 100, 20, 0.35); transform: scale(1.06); }
}

.artifacts-header-text {
  font-size: 1.05rem;
  font-weight: 400;
  color: #ffd699;
  line-height: 1.5;
  letter-spacing: 0.01em;
  text-shadow: 0 0 30px rgba(255, 180, 80, 0.12);
}

/* --- Source file selector --- */

.artifacts-source-selector {
  width: 100%;
  max-width: 900px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 18px;
  backdrop-filter: blur(8px);
}

.source-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.source-selector-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffd699;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.source-selector-header > div {
  display: flex;
  gap: 8px;
}

.source-sync-btn,
.source-selector-toggle {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(255, 150, 40, 0.3);
  border-radius: 6px;
  background: rgba(255, 150, 40, 0.1);
  color: #ffb347;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.source-sync-btn:hover,
.source-selector-toggle:hover {
  background: rgba(255, 150, 40, 0.2);
  border-color: rgba(255, 150, 40, 0.5);
}

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

.source-selector-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 150, 40, 0.3) transparent;
}

.source-selector-loading,
.source-selector-empty {
  font-size: 0.8rem;
  color: #888;
  padding: 6px 0;
}

.source-selector-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.source-selector-item:hover {
  background: rgba(255, 150, 40, 0.08);
  border-color: rgba(255, 150, 40, 0.2);
}

.source-selector-item input[type="checkbox"] {
  accent-color: #ff9a35;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.source-selector-item label {
  font-size: 0.78rem;
  color: #ccc;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* --- Carousel wrapper with fade masks --- */

.artifacts-carousel-wrap {
  position: relative;
  width: 100%;
  max-width: 1100px;
  overflow: hidden;
}

/* Left / right fade masks */
.artifacts-carousel-wrap::before,
.artifacts-carousel-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 60px;
  z-index: 2;
  pointer-events: none;
}

.artifacts-carousel-wrap::before {
  left: 0;
  background: linear-gradient(to right, rgba(2, 4, 12, 0.9), transparent);
}

.artifacts-carousel-wrap::after {
  right: 0;
  background: linear-gradient(to left, rgba(2, 4, 12, 0.9), transparent);
}

/* --- Carousel container --- */

.artifacts-carousel {
  display: flex;
  gap: 24px;
  padding: 20px 40px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none; /* Firefox */
  -webkit-overflow-scrolling: touch;
}

.artifacts-carousel::-webkit-scrollbar {
  display: none;
}

/* --- Individual artifact card --- */

.artifact-card {
  flex: 0 0 260px;
  scroll-snap-align: center;
  perspective: 800px;
}

.artifact-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 24px;
  min-height: 360px;
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 180, 60, 0.04) 0%, transparent 60%),
    rgba(8, 6, 18, 0.88);
  border: 1px solid rgba(255, 170, 50, 0.18);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow:
    0 0 0 1px rgba(255, 170, 50, 0.05) inset,
    0 8px 40px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(255, 150, 40, 0.06);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/* Ambient inner light */
.artifact-card-inner::before {
  content: "";
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 160%;
  height: 80%;
  background: radial-gradient(ellipse at center, rgba(255, 170, 60, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.artifact-card:hover .artifact-card-inner {
  border-color: rgba(255, 170, 50, 0.35);
  box-shadow:
    0 0 0 1px rgba(255, 170, 50, 0.08) inset,
    0 12px 50px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(255, 150, 40, 0.12);
  transform: translateY(-4px);
}

/* Staggered entrance animation */
.artifacts-overlay[aria-hidden="false"] .artifact-card:nth-child(1) { animation: cardSlideUp 0.5s 0.1s both cubic-bezier(0.16, 1, 0.3, 1); }
.artifacts-overlay[aria-hidden="false"] .artifact-card:nth-child(2) { animation: cardSlideUp 0.5s 0.18s both cubic-bezier(0.16, 1, 0.3, 1); }
.artifacts-overlay[aria-hidden="false"] .artifact-card:nth-child(3) { animation: cardSlideUp 0.5s 0.26s both cubic-bezier(0.16, 1, 0.3, 1); }
.artifacts-overlay[aria-hidden="false"] .artifact-card:nth-child(4) { animation: cardSlideUp 0.5s 0.34s both cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Card icon --- */

.artifact-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 20px;
  color: #ffb740;
  filter: drop-shadow(0 0 10px rgba(255, 180, 50, 0.3));
}

.artifact-icon svg {
  width: 100%;
  height: 100%;
}

/* --- Card label (small caps) --- */

.artifact-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 200, 120, 0.55);
  margin-bottom: 8px;
}

/* --- Card title --- */

.artifact-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  line-height: 1.4;
  margin-bottom: 12px;
  text-shadow: 0 0 20px rgba(255, 200, 100, 0.08);
}

/* --- Card metadata --- */

.artifact-meta {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-bottom: 16px;
  width: 100%;
}

.artifact-meta-text {
  font-size: 0.85rem;
  color: rgba(203, 213, 225, 0.65);
  font-weight: 400;
}

/* --- Audio waveform visualiser (Podcast card) --- */

.artifact-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
  width: 100%;
}

.artifact-waveform span {
  display: block;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(to top, #ff8c20, #ffb740);
  opacity: 0.7;
  animation: waveBar 1.2s ease-in-out infinite;
}

/* Stagger waveform bars */
.artifact-waveform span:nth-child(1)  { height: 14px; animation-delay: 0s; }
.artifact-waveform span:nth-child(2)  { height: 22px; animation-delay: 0.08s; }
.artifact-waveform span:nth-child(3)  { height: 30px; animation-delay: 0.16s; }
.artifact-waveform span:nth-child(4)  { height: 18px; animation-delay: 0.24s; }
.artifact-waveform span:nth-child(5)  { height: 36px; animation-delay: 0.32s; }
.artifact-waveform span:nth-child(6)  { height: 26px; animation-delay: 0.4s; }
.artifact-waveform span:nth-child(7)  { height: 20px; animation-delay: 0.48s; }
.artifact-waveform span:nth-child(8)  { height: 34px; animation-delay: 0.56s; }
.artifact-waveform span:nth-child(9)  { height: 16px; animation-delay: 0.64s; }
.artifact-waveform span:nth-child(10) { height: 28px; animation-delay: 0.72s; }
.artifact-waveform span:nth-child(11) { height: 22px; animation-delay: 0.8s; }
.artifact-waveform span:nth-child(12) { height: 38px; animation-delay: 0.88s; }
.artifact-waveform span:nth-child(13) { height: 14px; animation-delay: 0.96s; }
.artifact-waveform span:nth-child(14) { height: 30px; animation-delay: 1.04s; }
.artifact-waveform span:nth-child(15) { height: 20px; animation-delay: 0.06s; }
.artifact-waveform span:nth-child(16) { height: 26px; animation-delay: 0.14s; }
.artifact-waveform span:nth-child(17) { height: 34px; animation-delay: 0.22s; }
.artifact-waveform span:nth-child(18) { height: 18px; animation-delay: 0.3s; }
.artifact-waveform span:nth-child(19) { height: 24px; animation-delay: 0.38s; }
.artifact-waveform span:nth-child(20) { height: 32px; animation-delay: 0.46s; }

@keyframes waveBar {
  0%, 100% { transform: scaleY(0.4); opacity: 0.4; }
  50%      { transform: scaleY(1);   opacity: 0.85; }
}

/* --- Card action button --- */

.artifact-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.03em;
  color: #fff;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg,
      rgba(255, 140, 30, 0.85) 0%,
      rgba(240, 100, 10, 0.85) 100%);
  box-shadow:
    0 4px 20px rgba(255, 130, 30, 0.3),
    0 0 0 1px rgba(255, 180, 80, 0.15) inset;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.artifact-action::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, transparent 60%);
  pointer-events: none;
}

.artifact-action:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 30px rgba(255, 130, 30, 0.45),
    0 0 50px rgba(255, 150, 40, 0.15),
    0 0 0 1px rgba(255, 200, 100, 0.2) inset;
}

.artifact-action:active {
  transform: translateY(0) scale(0.97);
  box-shadow:
    0 2px 12px rgba(255, 130, 30, 0.3),
    0 0 0 1px rgba(255, 180, 80, 0.1) inset;
}

.artifact-action-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Artifacts trigger button (bottom controls) --- */

.artifacts-trigger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(30, 25, 45, 0.8);
  border: 1px solid rgba(255, 170, 50, 0.2);
  border-radius: 24px;
  color: #ffc880;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
}

.artifacts-trigger-btn:hover {
  background: rgba(45, 35, 60, 0.9);
  border-color: rgba(255, 170, 50, 0.45);
  box-shadow: 0 0 28px rgba(255, 150, 40, 0.15);
  transform: scale(1.02);
}

.artifacts-trigger-btn svg {
  opacity: 0.8;
  color: #ffb740;
}

/* --- Responsive --- */

@media (max-width: 900px) {
  .artifact-card {
    flex: 0 0 230px;
  }
  .artifact-card-inner {
    padding: 24px 18px 20px;
    min-height: 320px;
  }
}

@media (max-width: 600px) {
  .artifacts-overlay {
    padding: 20px 8px;
  }
  .artifacts-header {
    flex-direction: column;
    text-align: center;
    gap: 10px;
    margin-bottom: 24px;
  }
  .artifact-card {
    flex: 0 0 210px;
  }
  .artifact-card-inner {
    min-height: 300px;
    padding: 20px 14px 16px;
  }
  .artifacts-close {
    top: 12px;
    right: 16px;
  }
  .artifacts-carousel {
    padding: 12px 20px;
    gap: 16px;
  }
}

/* ============================================================================
   ARTIFACT CARD STATES (generating / ready / error)
   ============================================================================ */

/* --- Status badge (top-right corner) --- */

.artifact-status-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 3;
  pointer-events: none;
}

.artifact-card[data-status="generating"] .artifact-status-badge,
.artifact-card[data-status="ready"] .artifact-status-badge,
.artifact-card[data-status="error"] .artifact-status-badge {
  opacity: 1;
  transform: scale(1);
}

/* --- GENERATING state --- */

.artifact-card[data-status="generating"] .artifact-status-badge {
  background: rgba(255, 170, 50, 0.15);
  border: 1px solid rgba(255, 170, 50, 0.3);
  color: #ffb740;
}

.artifact-card[data-status="generating"] .artifact-card-inner {
  border-color: rgba(255, 170, 50, 0.3);
  animation: cardGeneratingPulse 2s ease-in-out infinite;
}

@keyframes cardGeneratingPulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(255, 170, 50, 0.05) inset,
      0 8px 40px rgba(0, 0, 0, 0.5),
      0 0 30px rgba(255, 150, 40, 0.06);
    border-color: rgba(255, 170, 50, 0.2);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 170, 50, 0.1) inset,
      0 8px 40px rgba(0, 0, 0, 0.5),
      0 0 50px rgba(255, 150, 40, 0.14);
    border-color: rgba(255, 170, 50, 0.4);
  }
}

.artifact-card[data-status="generating"] .artifact-icon {
  animation: iconPulseGenerate 1.5s ease-in-out infinite;
}

@keyframes iconPulseGenerate {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* Generating spinner inside button */
.artifact-action .action-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spinnerRotate 0.7s linear infinite;
  flex-shrink: 0;
}

.artifact-card[data-status="generating"] .artifact-action .action-spinner {
  display: block;
}

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

.artifact-card[data-status="generating"] .artifact-action {
  background: rgba(80, 70, 60, 0.5);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  cursor: wait;
  pointer-events: none;
}

/* --- READY state --- */

.artifact-card[data-status="ready"] .artifact-status-badge {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
  color: #4ade80;
}

.artifact-card[data-status="ready"] .artifact-card-inner {
  border-color: rgba(74, 222, 128, 0.25);
  box-shadow:
    0 0 0 1px rgba(74, 222, 128, 0.05) inset,
    0 8px 40px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(74, 222, 128, 0.08);
}

.artifact-card[data-status="ready"] .artifact-icon {
  color: #4ade80;
  filter: drop-shadow(0 0 10px rgba(74, 222, 128, 0.3));
}

.artifact-card[data-status="ready"] .artifact-action {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.7) 0%, rgba(34, 197, 94, 0.7) 100%);
  box-shadow: 0 4px 20px rgba(74, 222, 128, 0.3);
}

.artifact-card[data-status="ready"] .artifact-action:hover {
  box-shadow: 0 8px 30px rgba(74, 222, 128, 0.45), 0 0 50px rgba(74, 222, 128, 0.15);
}

/* --- ERROR state --- */

.artifact-card[data-status="error"] .artifact-status-badge {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.artifact-card[data-status="error"] .artifact-card-inner {
  border-color: rgba(239, 68, 68, 0.25);
}

.artifact-card[data-status="error"] .artifact-icon {
  color: #f87171;
  opacity: 0.6;
  filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.3));
}

.artifact-card[data-status="error"] .artifact-action {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.6) 0%, rgba(185, 28, 28, 0.6) 100%);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.2);
}

/* --- Notification badge on trigger button --- */

.artifacts-trigger-btn {
  position: relative;
}

.artifacts-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  color: #000;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(74, 222, 128, 0.4);
  pointer-events: none;
}

.artifacts-badge.visible {
  opacity: 1;
  transform: scale(1);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .artifact-card { animation: none !important; }
  .artifact-card-inner { animation: none !important; }
  .artifact-waveform span { animation: none !important; transform: scaleY(0.6); opacity: 0.5; }
  .artifacts-overlay { transition: opacity 0.2s ease; transform: none !important; }
  .artifacts-backdrop { transition: opacity 0.2s ease; }
  .action-spinner { animation: spinnerRotate 1.5s linear infinite !important; }
  .artifact-icon { animation: none !important; }
}


/* ================================================================
   MOOD CHECK-IN OVERLAY
   ================================================================ */

.mood-slider-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.mood-slider-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.mood-slider-overlay {
  position: fixed;
  inset: 0;
  z-index: 9001;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.mood-slider-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.mood-slider-overlay canvas#moodVisualizer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.8;
}

.mood-slider-container {
  position: relative;
  z-index: 10;
  width: 90%;
  max-width: 440px;
  padding: 40px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: moodSliderFadeIn 0.6s ease 0.3s both;
}

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

.mood-slider-prompt {
  font-size: 16px;
  font-weight: 400;
  color: #c0c8d8;
  line-height: 1.6;
  letter-spacing: 0.2px;
}

.mood-value-display {
  font-variant-numeric: tabular-nums;
  font-size: 56px;
  font-weight: 200;
  letter-spacing: -2px;
  color: #f0f2f5;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
  transition: color 0.3s ease;
}

.mood-slider-wrapper {
  position: relative;
  width: 100%;
  padding: 10px 0;
}

.mood-slider-wrapper input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  cursor: pointer;
}

.mood-slider-wrapper input[type=range]:focus {
  outline: none;
}

.mood-slider-wrapper input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.mood-slider-wrapper input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 24px;
  width: 24px;
  border-radius: 50%;
  background: #ffffff;
  margin-top: -10px;
  box-shadow: 0 0 15px var(--mood-accent-glow, rgba(64, 224, 208, 0.5));
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
}

.mood-slider-wrapper input[type=range]:active::-webkit-slider-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 25px var(--mood-accent-glow, rgba(64, 224, 208, 0.5));
}

.mood-slider-wrapper input[type=range]::-moz-range-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.mood-slider-wrapper input[type=range]::-moz-range-thumb {
  height: 24px;
  width: 24px;
  border: none;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 15px var(--mood-accent-glow, rgba(64, 224, 208, 0.5));
  transition: transform 0.2s, box-shadow 0.3s;
}

.mood-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #8b9bb4;
  font-weight: 500;
  letter-spacing: 0.5px;
  margin-top: 6px;
}

.mood-submit-btn {
  padding: 14px 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #f0f2f5;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.15s ease;
}

.mood-submit-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.mood-submit-btn:active {
  transform: scale(0.97);
}

.mood-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .mood-slider-container { animation: none; opacity: 1; }
  .mood-slider-backdrop { transition: opacity 0.2s ease; }
  .mood-slider-overlay { transition: opacity 0.2s ease; }
}
