/* ============================================
   iMood — Immersive AI Voice Diary
   Monochrome Design System
   ============================================ */

/* CSS Variables - Dark Mode (Default) */
:root {
  --bg: #000000;
  --surface: rgba(20, 20, 20, 0.85);
  --surface-hover: rgba(35, 35, 35, 0.9);
  --primary: #c0c0c0;
  --primary-glow: rgba(192, 192, 192, 0.3);
  --accent: #a0a0a0;
  --accent-glow: rgba(160, 160, 160, 0.3);
  --text: #e8e8e8;
  --text-muted: #888888;
  --text-subtitle: rgba(232, 232, 232, 0.65);
  --border: rgba(255, 255, 255, 0.08);
  --waveform: rgba(192, 192, 192, 0.5);
  --waveform-active: #d0d0d0;
  --status-idle: #666666;
  --status-listening: #4ade80;
  --status-speaking: #c0c0c0;
  --status-thinking: #fbbf24;
  --glass-bg: rgba(15, 15, 15, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Light Mode - Gray-White Background */
[data-theme="light"] {
  --bg: #f5f5f5;
  --surface: rgba(240, 240, 240, 0.9);
  --surface-hover: rgba(230, 230, 230, 0.95);
  --primary: #4a4a4a;
  --primary-glow: rgba(74, 74, 74, 0.2);
  --accent: #6b6b6b;
  --accent-glow: rgba(107, 107, 107, 0.2);
  --text: #1a1a1a;
  --text-muted: #7a7a7a;
  --text-subtitle: rgba(26, 26, 26, 0.6);
  --border: rgba(0, 0, 0, 0.06);
  --waveform: rgba(180, 100, 100, 0.4);
  --waveform-active: #b07070;
  --status-idle: #9a9a9a;
  --status-listening: #4a9a6a;
  --status-speaking: #8a6a6a;
  --status-thinking: #b89a6a;
  --glass-bg: rgba(245, 245, 245, 0.75);
  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  
  /* Light mode specific background gradient - gray-white */
  --bg-gradient: radial-gradient(ellipse at center, rgba(200, 200, 200, 0.1) 0%, rgba(245, 245, 245, 0) 70%);
  
  /* Light mode nebula color - low saturation gray */
  --nebula-color: rgba(180, 180, 180, 0.2);
}

[data-theme="light"] .app-container {
  background: var(--bg-gradient);
}

[data-theme="light"] .bg-canvas {
  opacity: 0.1;
}

/* Enhanced Glass Effect for Light Mode */
[data-theme="light"] .subtitle-glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(220, 218, 215, 0.2);
}

/* Mobile Light Mode Adjustments */
@media (max-width: 768px) {
  [data-theme="light"] .interaction-area {
    background: linear-gradient(to top, rgba(245, 245, 245, 0.98) 0%, rgba(245, 245, 245, 0.9) 40%, rgba(245, 245, 245, 0.7) 70%, transparent 100%);
  }

  [data-theme="light"] .input-wrapper {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.08);
  }

  [data-theme="light"] .input-wrapper input {
    color: rgba(60, 60, 60, 0.9);
  }

  [data-theme="light"] .input-wrapper input::placeholder {
    color: rgba(120, 120, 120, 0.6);
  }
}

[data-theme="light"] .input-area input {
  background: rgba(245, 245, 245, 0.5);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(200, 200, 200, 0.25);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.02),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Light mode persona chip - borderless design */
[data-theme="light"] .persona-chip {
  background: transparent;
  border: none;
  box-shadow: none;
}

[data-theme="light"] .persona-chip:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .persona-chip.active {
  background: rgba(0, 0, 0, 0.08);
}

/* Light mode input wrapper - borderless floating style */
[data-theme="light"] .input-wrapper {
  background: rgba(0, 0, 0, 0.03);
  border: none;
  box-shadow: none;
}

[data-theme="light"] .input-wrapper:focus-within {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .input-wrapper input {
  color: rgba(60, 60, 60, 0.8);
}

[data-theme="light"] .input-wrapper input::placeholder {
  color: rgba(120, 120, 120, 0.6);
}

[data-theme="light"] .input-btn {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(80, 80, 80, 0.8);
}

[data-theme="light"] .input-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .input-btn.active {
  background: rgba(0, 0, 0, 0.1);
  color: rgba(50, 50, 50, 0.9);
}

[data-theme="light"] .header-btn {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(220, 218, 215, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .nebula-glow {
  background: radial-gradient(circle, rgba(200, 160, 160, 0.12) 0%, transparent 70%);
  opacity: 0.35;
}

[data-theme="light"] .nebula-canvas,
[data-theme="light"] .rabbit-canvas {
  opacity: 0.8;
}

[data-theme="light"] .interaction-area {
  background: linear-gradient(to top, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.75) 50%, rgba(255, 255, 255, 0.3) 80%, transparent 100%);
}

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

html, body {
  height: 100%;
  font-family: 'Times New Roman', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Background Canvas */
.bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.25;
}

/* Rain Shader Container */
.rain-shader-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.rain-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* App Container */
.app-container {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height for mobile */
  display: flex;
  flex-direction: column;
  /* 背景呼吸感：径向渐变 + 噪点纹理 */
  background:
    radial-gradient(ellipse at center, rgba(10, 10, 10, 1) 0%, rgba(0, 0, 0, 1) 70%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.01'/%3E%3C/svg%3E");
  background-blend-mode: overlay;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  z-index: 10;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
}

.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.05em;
  border-radius: 10px;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.header-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--primary);
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

/* Theme Toggle Button */
#themeToggle {
  position: relative;
}

#themeToggle .sun-icon {
  display: none;
}

#themeToggle .moon-icon {
  display: block;
}

[data-theme="light"] #themeToggle .sun-icon {
  display: block;
}

[data-theme="light"] #themeToggle .moon-icon {
  display: none;
}

/* Persona Bar */
.persona-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  z-index: 10;
}

/* Voice Waveform Capsule - Seamless with background */
.voice-waveform-capsule {
  width: auto;
  min-width: 80px;
  max-width: 120px;
  height: 28px;
  padding: 0 0.75rem;
  border-radius: 100px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: all 0.3s ease;
  overflow: hidden;
}

.voice-waveform-capsule.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.voice-waveform-canvas {
  width: 100%;
  height: 100%;
}

.persona-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 100px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.persona-chip:hover {
  background: rgba(255, 255, 255, 0.05);
}

.persona-chip.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.persona-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-idle);
  transition: all 0.3s ease;
}

.persona-status-dot.connected {
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

.persona-status-dot.listening {
  background: var(--status-listening);
  box-shadow: 0 0 10px var(--status-listening);
  animation: pulse 1.5s ease-in-out infinite;
}

.persona-status-dot.speaking {
  background: var(--status-speaking);
  box-shadow: 0 0 15px var(--status-speaking);
  animation: pulse 0.8s ease-in-out infinite;
}

.persona-status-dot.thinking {
  background: var(--status-thinking);
  box-shadow: 0 0 10px var(--status-thinking);
  animation: pulse 1s ease-in-out infinite;
}

/* Main Stage */
.main-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  padding: 1rem;
  min-height: 0;
  overflow: visible;
}

/* AI Status */
.ai-status-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-idle);
  transition: all 0.3s ease;
}

.status-dot.connected {
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
}

.status-dot.listening {
  background: var(--status-listening);
  box-shadow: 0 0 10px var(--status-listening);
  animation: pulse 1.5s ease-in-out infinite;
}

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

.status-dot.thinking {
  background: var(--status-thinking);
  box-shadow: 0 0 10px var(--status-thinking);
  animation: pulse 1s ease-in-out infinite;
}

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

.ai-status-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Nebula Container */
.nebula-container {
  position: relative;
  width: 360px;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -2rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.nebula-canvas,
.rabbit-canvas,
.cat-canvas,
.heart-canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  color: rgb(2, 26, 26);
}

.nebula-glow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 200, 200, 0.15) 0%, transparent 70%);
  opacity: 0.4;
  animation: nebula-breathe 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes nebula-breathe {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.05); }
}

/* AI Response Bubble */
.ai-bubble {
  position: relative;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  max-width: 600px;
  width: 85%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.ai-bubble.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.ai-bubble-content {
  background: rgba(15, 15, 15, 0.6);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-radius: 16px;
  padding: 0.875rem 1.125rem;
  color: rgba(200, 200, 200, 0.9);
  font-size: 0.9375rem;
  line-height: 1.6;
  font-family: 'Times New Roman', Georgia, serif;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.03);
  max-height: 100px;
  overflow: hidden;
  position: relative;
  transition: max-height 0.3s ease;
}

.ai-bubble-content.expanded {
  max-height: 200px;
  overflow-y: auto;
}

/* English and Chinese text containers */
.ai-bubble-en {
  margin-bottom: 0.5rem;
}

.ai-bubble-cn {
  color: rgba(180, 180, 180, 0.8);
  font-size: 0.875rem;
}

/* Light mode text colors */
[data-theme="light"] .ai-bubble-cn {
  color: rgba(100, 100, 100, 0.8);
}

/* Arrow pointing up from bubble to heart (bubble is below heart) */
.ai-bubble-content::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid rgba(15, 15, 15, 0.6);
}

/* Expand button for long text */
.ai-bubble-expand-btn {
  position: absolute;
  bottom: 4px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(200, 200, 200, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s ease;
  font-size: 12px;
}

.ai-bubble:hover .ai-bubble-expand-btn,
.ai-bubble-expand-btn.visible {
  opacity: 1;
}

.ai-bubble-expand-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Fade overlay for collapsed state */
.ai-bubble-content.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(to top, rgba(15, 15, 15, 0.6), transparent);
  pointer-events: none;
}

/* Light mode AI bubble */
[data-theme="light"] .ai-bubble-content {
  background: rgba(245, 245, 245, 0.65);
  color: rgba(60, 60, 60, 0.9);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .ai-bubble-content::before {
  border-bottom-color: rgba(245, 245, 245, 0.65);
}

[data-theme="light"] .ai-bubble-content.collapsed::after {
  background: linear-gradient(to top, rgba(245, 245, 245, 0.65), transparent);
}

[data-theme="light"] .ai-bubble-expand-btn {
  background: rgba(0, 0, 0, 0.08);
  color: rgba(80, 80, 80, 0.7);
}

[data-theme="light"] .ai-bubble-expand-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

/* Interaction Area - Bottom 25% only */
.interaction-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 25vh;
  min-height: 200px;
  max-height: 280px;
  padding: 1rem 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  z-index: 10;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.7) 50%, rgba(0, 0, 0, 0.3) 80%, transparent 100%);
}

/* Waveform - Hidden, replaced by voice waveform capsule */
.waveform-container {
  display: none;
}

/* Liquid Glass Subtitle Container */
.subtitle-glass {
  display: none;
}

/* Pause Button */
.pause-btn {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(192, 192, 192, 0.15);
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.pause-btn:hover {
  background: rgba(192, 192, 192, 0.25);
  transform: translateY(-50%) scale(1.05);
}

/* Expand Button */
.expand-btn {
  position: absolute;
  right: 0.75rem;
  bottom: 0.5rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.expand-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

/* Subtitles */
.subtitles-container {
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow: hidden;
}

.subtitle-text {
  font-family: 'Times New Roman', Georgia, serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  font-weight: 400;
  max-height: 3em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.subtitle-translation {
  font-family: 'Times New Roman', Georgia, serif;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text-subtitle);
  font-style: italic;
  max-height: 2em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* Expanded state - show full text */
.subtitle-glass.expanded .subtitle-text {
  max-height: none;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.subtitle-glass.expanded .subtitle-translation {
  max-height: none;
  -webkit-line-clamp: unset;
  overflow: visible;
}

/* Parentheses are now added via JavaScript for better control */

/* Input Area */
.input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 500px;
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.03);
  border: none;
  transition: all 0.3s ease;
}

.input-wrapper:focus-within {
  background: rgba(255, 255, 255, 0.06);
}

.input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: rgba(200, 200, 200, 0.8);
  font-size: 0.875rem;
  font-family: inherit;
}

.input-wrapper input::placeholder {
  color: rgba(150, 150, 150, 0.6);
}

.input-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(180, 180, 180, 0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.input-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.05);
}

.input-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(220, 220, 220, 0.9);
}

.input-btn.active:hover {
  transform: scale(1.08);
}

.input-btn svg {
  width: 16px;
  height: 16px;
}

.voice-btn, .image-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.voice-btn:hover, .image-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--primary);
}

.voice-btn.recording {
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white;
  border-color: transparent;
  animation: recording-pulse 1s ease-in-out infinite;
}

@keyframes recording-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.voice-btn svg, .image-btn svg {
  width: 22px;
  height: 22px;
}

.diary-end-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.diary-end-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px var(--primary-glow);
}

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

.diary-end-btn svg {
  width: 22px;
  height: 22px;
}

/* Side Panels */
.side-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100%;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  z-index: 100;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.side-panel.open {
  right: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
}

.panel-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.panel-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Calendar Mini */
.calendar-mini {
  margin-bottom: 1.5rem;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.calendar-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.calendar-nav {
  display: flex;
  gap: 0.5rem;
}

.calendar-nav button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.calendar-nav button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day-label {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.calendar-day:hover {
  background: var(--surface-hover);
}

.calendar-day.today {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--bg);
  font-weight: 600;
}

.calendar-day.has-memory {
  position: relative;
}

.calendar-day.has-memory::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
}

.calendar-day.other-month {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Memory List */
.memory-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.memory-item {
  padding: 1rem;
  border-radius: 12px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.memory-item:hover {
  border-color: var(--primary);
}

.memory-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.memory-item-persona {
  font-size: 0.875rem;
  font-weight: 500;
}

.memory-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.memory-item-preview {
  font-size: 0.875rem;
  color: var(--text-subtitle);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.memory-item-actions {
  margin-top: 0.75rem;
}

.memory-pin-btn {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.memory-pin-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 2rem;
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Responsive */
@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem 1rem;
  }

  .logo-text {
    font-size: 1.5rem;
  }

  .header-btn {
    width: 36px;
    height: 36px;
  }

  .main-stage {
    padding: 0.5rem;
    justify-content: center;
  }

  .nebula-container {
    width: 260px;
    height: 260px;
    margin-top: -1.5rem;
    margin-bottom: 0.5rem;
  }

  /* AI Bubble Mobile Optimization */
  .ai-bubble {
    margin-top: 0;
    margin-bottom: 0.75rem;
    width: 92%;
    max-width: none;
    position: relative;
    z-index: 100;
  }

  .ai-bubble-content {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    max-height: 120px;
  }

  .ai-bubble-content.expanded {
    max-height: 250px;
  }

  .ai-bubble-en {
    margin-bottom: 0.375rem;
  }

  .ai-bubble-cn {
    font-size: 0.8125rem;
    line-height: 1.4;
  }

  .ai-bubble-expand-btn {
    opacity: 1;
    width: 22px;
    height: 22px;
  }

  .interaction-area {
    padding: 0.75rem 1rem 1rem;
    height: auto;
    min-height: auto;
    max-height: none;
    gap: 0.5rem;
    position: relative;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.98) 0%, rgba(0, 0, 0, 0.85) 40%, rgba(0, 0, 0, 0.5) 70%, transparent 100%);
  }

  .input-area {
    flex-wrap: nowrap;
    gap: 0.375rem;
    max-width: 100%;
  }

  .input-wrapper {
    order: 0;
    flex: 1;
    padding: 0.375rem 0.625rem;
  }

  .input-wrapper input {
    font-size: 16px; /* Prevent iOS zoom on focus */
  }

  .input-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .input-btn svg {
    width: 18px;
    height: 18px;
  }

  .voice-btn, .image-btn, .diary-end-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .voice-btn svg, .image-btn svg, .diary-end-btn svg {
    width: 20px;
    height: 20px;
  }

  .persona-bar {
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }

  .voice-waveform-capsule {
    width: 80px;
    height: 24px;
  }

  .side-panel {
    width: 100%;
    right: -100%;
  }
}

/* Typing Animation for Subtitles */
.typing-cursor::after {
  content: '|';
  animation: blink 1s step-end infinite;
  color: var(--primary);
}

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

/* Fade In Animation */
.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

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

/* ============================================
   Diary Module Styles
   ============================================ */

/* Diary Overlay - End Dialog */
.diary-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease-out;
}

.diary-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.diary-overlay-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.25s ease-out;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.diary-overlay.visible .diary-overlay-content {
  transform: scale(1);
}

.diary-overlay-icon {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.diary-overlay-icon svg {
  width: 48px;
  height: 48px;
  color: var(--primary);
}

.diary-overlay-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.diary-overlay-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.diary-notebook-select {
  margin-bottom: 1.5rem;
  text-align: left;
}

.diary-notebook-select label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.diary-notebook-select select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.diary-notebook-select select:hover {
  border-color: var(--primary);
}

.diary-notebook-select select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.diary-overlay-actions {
  display: flex;
  gap: 0.75rem;
}

.diary-btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
  border-radius: 12px;
  border: none;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.diary-btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--bg);
}

.diary-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.diary-btn-secondary {
  background: var(--surface-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.diary-btn-secondary:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--primary);
}

.diary-btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.diary-btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Diary Dropdown Panel */
.diary-dropdown {
  position: fixed;
  top: 70px;
  right: 2rem;
  width: 320px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.25s ease-out;
}

.diary-dropdown.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.diary-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.diary-dropdown-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
}

.diary-add-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.diary-add-btn:hover {
  background: var(--surface-hover);
  color: var(--primary);
  border-color: var(--primary);
}

.diary-add-btn svg {
  width: 18px;
  height: 18px;
}

.diary-notebook-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem;
}

.diary-notebook-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.diary-notebook-item:hover {
  background: var(--surface-hover);
}

.diary-notebook-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-hover);
  display: flex;
  align-items: center;
  justify-content: center;
}

.diary-notebook-icon svg {
  width: 20px;
  height: 20px;
}

.diary-notebook-info {
  flex: 1;
  min-width: 0;
}

.diary-notebook-name {
  display: block;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diary-notebook-count {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.diary-notebook-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: var(--primary-glow);
  color: var(--primary);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Diary Detail Panel */
.diary-detail-panel {
  position: fixed;
  top: 0;
  right: -450px;
  width: 450px;
  height: 100%;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  z-index: 180;
  transition: right 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
}

.diary-detail-panel.open {
  right: 0;
}

.diary-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.diary-back-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.diary-back-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.diary-back-btn svg {
  width: 20px;
  height: 20px;
}

.diary-detail-header h2 {
  flex: 1;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diary-detail-actions {
  display: flex;
  gap: 0.5rem;
}

.diary-edit-btn,
.diary-delete-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.diary-edit-btn:hover {
  background: var(--surface-hover);
  color: var(--primary);
  border-color: var(--primary);
}

.diary-delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.diary-edit-btn svg,
.diary-delete-btn svg {
  width: 18px;
  height: 18px;
}

.diary-detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.diary-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Diary Card */
.diary-card {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
}

.diary-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.diary-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
}

.diary-card-emotion-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.diary-card-info {
  flex: 1;
  min-width: 0;
}

.diary-card-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diary-card-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.diary-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.diary-card-edit-btn,
.diary-card-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0;
}

.diary-card:hover .diary-card-delete-btn,
.diary-card:hover .diary-card-edit-btn {
  opacity: 1;
}

.diary-card-edit-btn:hover {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.diary-card-edit-btn svg {
  width: 16px;
  height: 16px;
}

.diary-card-delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.diary-card-delete-btn svg {
  width: 16px;
  height: 16px;
}

.diary-card-expand-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.diary-card.expanded .diary-card-expand-icon {
  transform: rotate(180deg);
}

.diary-card-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-in-out;
}

.diary-card.expanded .diary-card-content {
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.diary-card.expanded .diary-card-content::-webkit-scrollbar {
  width: 6px;
}

.diary-card.expanded .diary-card-content::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

.diary-card.expanded .diary-card-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  transition: background 0.2s ease;
}

.diary-card.expanded .diary-card-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.diary-card-conversation {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
  padding-top: 1rem;
}

.diary-message {
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.diary-message-user {
  background: var(--primary-glow);
  color: var(--text);
  margin-left: 2rem;
  text-align: right;
}

.diary-message-ai {
  background: var(--surface);
  color: var(--text-subtitle);
  margin-right: 2rem;
}

/* Diary Modal */
.diary-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease-out;
}

.diary-modal.visible {
  opacity: 1;
  visibility: visible;
}

.diary-modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 90%;
  max-width: 420px;
  transform: scale(0.9);
  transition: transform 0.25s ease-out;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.diary-modal.visible .diary-modal-content {
  transform: scale(1);
}

.diary-card-content {
  max-width: 600px;
}

.diary-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.diary-modal-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
}

.diary-card-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.diary-card-header-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.diary-card-emotion {
  font-size: 1.5rem;
}

.diary-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.diary-modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.diary-modal-body {
  padding: 1.5rem;
}

.diary-form-group {
  margin-bottom: 1.25rem;
}

.diary-form-group:last-child {
  margin-bottom: 0;
}

.diary-form-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.diary-form-group input {
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 0.9375rem;
  transition: all 0.2s ease;
}

.diary-form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.diary-form-group textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 0.9375rem;
  font-family: inherit;
  resize: none;
  transition: all 0.2s ease;
}

.diary-form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.diary-form-group textarea::placeholder {
  color: var(--text-muted);
}

.diary-color-picker {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.diary-color-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.diary-color-btn:hover {
  transform: scale(1.1);
}

.diary-color-btn.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface);
}

.diary-modal-footer {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.5rem;
}

.diary-conversation {
  max-height: 400px;
  overflow-y: auto;
}

/* Light Mode Adjustments */
[data-theme="light"] .diary-overlay {
  background: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .diary-dropdown {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .diary-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Responsive */
@media (max-width: 768px) {
  .diary-dropdown {
    right: 1rem;
    width: calc(100% - 2rem);
    max-width: 320px;
  }
  
  .diary-detail-panel {
    width: 100%;
    right: -100%;
  }
  
  .diary-modal-content {
    max-width: calc(100% - 2rem);
  }
}

/* ============================================
   Music Player Styles - Non-intrusive Design
   ============================================ */

/* Music Button in Header */
#musicBtn {
  position: relative;
}

#musicBtn.playing {
  color: var(--primary);
}

#musicBtn.playing::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--primary);
  border-radius: 50%;
  animation: musicPulse 1s ease-in-out infinite;
}

@keyframes musicPulse {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.5; transform: translateX(-50%) scale(1.5); }
}

/* Music Panel - Dropdown Style */
.music-panel {
  position: fixed;
  top: 70px;
  right: 1rem;
  width: 320px;
  max-height: calc(100vh - 100px);
  background: rgba(15, 15, 15, 0.85);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.98);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.music-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.music-panel-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
  overflow: hidden;
}

.music-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.music-panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.music-panel-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.music-panel-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Music Controls */
.music-controls {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.music-control-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.music-control-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.music-control-btn:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.05);
}

.music-control-btn svg {
  width: 20px;
  height: 20px;
}

.music-play-btn {
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: white;
}

.music-play-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.1);
}

/* Volume Control */
.music-volume-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.music-volume-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.music-volume-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.music-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.music-volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.music-volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

/* Music Info */
.music-info {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.music-current-song {
  margin-bottom: 0.75rem;
}

#musicCurrentTitle {
  display: block;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
}

#musicCurrentArtist {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.music-progress {
  margin-top: 0.5rem;
}

.music-progress-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.music-progress-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

.music-progress-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

.music-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Playlist */
.music-playlist-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.music-playlist-section h4 {
  padding: 0.75rem 1.25rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.music-playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.music-playlist-header h4 {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 0;
  border-bottom: none;
}

.music-upload-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.music-upload-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
}

.music-upload-progress {
  padding: 0.4rem 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
}

.music-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.music-item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.2s ease;
}

.music-item:hover .music-item-delete {
  opacity: 1;
}

.music-item-delete:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

[data-theme="light"] .music-playlist-header {
  border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .music-upload-btn {
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .music-upload-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.15);
}

.music-playlist {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.25rem 0;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.music-playlist::-webkit-scrollbar {
  width: 4px;
}

.music-playlist::-webkit-scrollbar-track {
  background: transparent;
  margin: 4px 0;
}

.music-playlist::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  transition: background 0.3s ease;
}

.music-playlist::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.music-empty-hint {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.music-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  transition: all 0.25s ease;
  border-radius: 10px;
  margin: 0.125rem 0.5rem;
}

.music-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.music-item.active {
  background: rgba(192, 192, 192, 0.12);
}

.music-item-icon {
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.music-item.active .music-item-icon {
  color: var(--primary);
}

.music-item-title {
  font-size: 0.875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-item-artist {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Music Waveform - Input Area Top Border */
.music-waveform {
  position: absolute;
  top: -6px;
  left: 0;
  width: 100%;
  height: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 5;
}

/* Light Mode Adjustments */
[data-theme="light"] .music-panel {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .music-panel-header {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .music-playlist-section h4 {
  border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .music-playlist {
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

[data-theme="light"] .music-playlist::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .music-playlist::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .music-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .music-item.active {
  background: rgba(74, 74, 74, 0.08);
}

/* Responsive */
@media (max-width: 768px) {
  .music-panel {
    right: 0.5rem;
    width: calc(100% - 1rem);
    max-width: 320px;
  }
  
  .music-playlist {
    scrollbar-width: none;
  }
  
  .music-playlist::-webkit-scrollbar {
    display: none;
  }
}

/* Music Panel Gradient Overlays for Natural Scroll Feel */
.music-playlist-section::before,
.music-playlist-section::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 24px;
  pointer-events: none;
  z-index: 10;
}

.music-playlist-section::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(15, 15, 15, 0.9), transparent);
}

.music-playlist-section::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(15, 15, 15, 0.95), transparent);
}

[data-theme="light"] .music-playlist-section::before {
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), transparent);
}

[data-theme="light"] .music-playlist-section::after {
  background: linear-gradient(to top, rgba(255, 255, 255, 0.98), transparent);
}

/* ============================================
   Voice Panel & Replay Button
   ============================================ */

/* Voice Select Button (header) */
#voiceSelectBtn svg {
  width: 18px;
  height: 18px;
}

/* Replay Button (subtitle area) */
.replay-btn {
  position: absolute;
  right: 48px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s;
  flex-shrink: 0;
}
.replay-btn:hover {
  background: rgba(255,255,255,0.16);
  transform: translateY(-50%) scale(1.1);
}
.replay-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
[data-theme="light"] .replay-btn {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.1);
}

/* Voice Panel */
.voice-panel {
  position: fixed;
  top: 56px;
  right: 1rem;
  width: 300px;
  max-height: 70vh;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 16px;
  box-shadow: var(--glass-shadow);
  z-index: 120;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.voice-panel.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}
.voice-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.voice-panel-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.voice-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.voice-panel-close:hover { color: var(--text); }

/* Lang tabs */
.voice-lang-tabs {
  display: flex;
  gap: 4px;
  padding: 0.6rem 0.75rem 0;
  flex-shrink: 0;
}
.voice-lang-tab {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.voice-lang-tab.active {
  background: rgba(255,255,255,0.12);
  color: var(--text);
  border-color: rgba(255,255,255,0.2);
}

/* TTS lang toggle */
.voice-tts-lang {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.75rem;
  flex-shrink: 0;
}
.voice-tts-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.voice-tts-toggle {
  display: flex;
  gap: 4px;
}
.voice-tts-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.voice-tts-btn.active {
  background: rgba(255,255,255,0.14);
  color: var(--text);
  border-color: rgba(255,255,255,0.25);
}

/* Voice List */
.voice-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.voice-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}
.voice-item:hover {
  background: rgba(255,255,255,0.07);
}
.voice-item.active {
  background: rgba(255,255,255,0.11);
  border: 1px solid rgba(255,255,255,0.15);
}
.voice-item-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.voice-item-avatar.female {
  background: rgba(255, 180, 200, 0.15);
  color: #f9a8d4;
}
.voice-item-avatar.male {
  background: rgba(130, 190, 255, 0.15);
  color: #93c5fd;
}
.voice-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.voice-item-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}
.voice-item-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.voice-preview-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.voice-preview-btn:hover {
  background: rgba(255,255,255,0.16);
  color: var(--text);
}
.voice-preview-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Light mode adjustments */
[data-theme="light"] .voice-lang-tab,
[data-theme="light"] .voice-tts-btn {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
  color: var(--text-muted);
}
[data-theme="light"] .voice-lang-tab.active,
[data-theme="light"] .voice-tts-btn.active {
  background: rgba(0,0,0,0.1);
  color: var(--text);
  border-color: rgba(0,0,0,0.2);
}
[data-theme="light"] .voice-item:hover {
  background: rgba(0,0,0,0.05);
}
[data-theme="light"] .voice-item.active {
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.12);
}
[data-theme="light"] .voice-item-avatar.female {
  background: rgba(255,100,150,0.1);
  color: #e879a0;
}
[data-theme="light"] .voice-item-avatar.male {
  background: rgba(60,130,220,0.1);
  color: #3b82f6;
}
[data-theme="light"] .voice-preview-btn {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .voice-preview-btn:hover {
  background: rgba(0,0,0,0.1);
}

/* Subtitle glass - ensure replay btn positioned correctly */
.subtitle-glass {
  position: relative;
}

/* Voice Recommend Tag */
.voice-recommend-tag {
  display: inline-block;
  background: rgba(255, 200, 100, 0.2);
  color: #f0c060;
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 500;
}
[data-theme="light"] .voice-recommend-tag {
  background: rgba(200, 150, 50, 0.12);
  color: #b08030;
}

/* Particle background button (slightly highlighted) */
#particleBgBtn {
  cursor: pointer;
  position: relative;
}
#particleBgBtn svg {
  width: 18px;
  height: 18px;
}
#particleBgBtn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: rgba(240, 192, 96, 0.6);
  border-radius: 50%;
}

/* Samantha Original Voice - Special Highlight */
.voice-samantha-tag {
  display: inline-block;
  background: rgba(167, 139, 250, 0.25);
  color: #a78bfa;
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
  font-weight: 600;
}
[data-theme="light"] .voice-samantha-tag {
  background: rgba(120, 90, 220, 0.12);
  color: #7c3aed;
}
.voice-item.samantha-default {
  border: 1px solid rgba(167, 139, 250, 0.3);
  background: rgba(167, 139, 250, 0.08);
}
.voice-item.samantha-default:hover {
  background: rgba(167, 139, 250, 0.14);
}
[data-theme="light"] .voice-item.samantha-default {
  border-color: rgba(120, 90, 220, 0.2);
  background: rgba(120, 90, 220, 0.06);
}

/* ─── LLM Model Panel (independent) ─── */
.model-panel {
  position: fixed;
  top: 50%;
  right: -320px;
  transform: translateY(-50%);
  width: 280px;
  max-height: 70vh;
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: all 0.3s ease;
  overflow: hidden;
}
.model-panel.active {
  right: 20px;
  opacity: 1;
}
[data-theme="light"] .model-panel {
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.06);
}
.model-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.model-panel-header h3 {
  font-size: 0.95rem;
  margin: 0;
}
.model-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s;
}
.model-panel-close:hover { color: var(--text); background: rgba(255,255,255,0.08); }
.model-provider-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 16px 6px;
}
.model-provider-tab {
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 0.72rem;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: all 0.2s;
}
.model-provider-tab.active {
  background: rgba(167,139,250,0.15);
  color: #a78bfa;
  border-color: rgba(167,139,250,0.3);
}
[data-theme="light"] .model-provider-tab.active {
  background: rgba(120,90,220,0.1);
  color: #7c3aed;
  border-color: rgba(120,90,220,0.2);
}
.model-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
}
.llm-model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.llm-model-item:hover {
  background: rgba(255,255,255,0.08);
}
.llm-model-item.active {
  background: rgba(167,139,250,0.12);
  border-color: rgba(167,139,250,0.25);
}
[data-theme="light"] .llm-model-item.active {
  background: rgba(120,90,220,0.08);
  border-color: rgba(120,90,220,0.15);
}
.llm-model-info {
  display: flex;
  flex-direction: column;
}
.llm-model-name {
  font-weight: 600;
  color: var(--text);
}
.llm-model-desc {
  font-size: 0.65rem;
  color: var(--text-secondary);
}
.llm-model-badge {
  font-size: 0.58rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(52,211,153,0.15);
  color: #34d399;
}
[data-theme="light"] .llm-model-badge {
  background: rgba(16,185,129,0.1);
  color: #059669;
}
