/* ============================================
   Agent Daemon - Mobile-First Design System
   Version: 20250208-001
   Cache-busting: Force reload on changes
   ============================================ */

/* CSS Variables */
:root {
  /* Colors */
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252545;
  --bg-elevated: #2d2d55;
  --bg-hover: #363666;

  --text-primary: #ffffff;
  --text-secondary: #a0a0c0;
  --text-muted: #6a6a8a;

  --accent-primary: #e94560;
  --accent-secondary: #0f3460;
  --accent-gradient: linear-gradient(135deg, #e94560 0%, #ff6b6b 100%);

  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Layout */
  --header-height: 56px;
  --mobile-nav-height: 64px;
  --sidebar-width: 280px;
  --panel-width: 320px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Utility Classes */
.mobile-only {
  display: flex;
}

.desktop-only {
  display: none;
}

.hidden {
  display: none !important;
}

/* ============================================
   HEADER
   ============================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
  gap: var(--space-sm);
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  min-width: 0;
}

.header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Connection Status */
.connection-status {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.connected { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.disconnected { background: var(--error); }
.status-dot.connecting { background: var(--warning); animation: pulse 1.5s infinite; }

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

/* TTS Badge */
.tts-badge {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.tts-badge:hover {
  background: var(--bg-elevated);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.tts-badge .material-symbols-rounded {
  font-size: 20px;
}

.tts-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
}

.tts-indicator[data-status="active"] {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.tts-indicator[data-status="standby"] {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.tts-indicator[data-status="loading"],
.tts-indicator[data-status="waking"] {
  background: var(--info);
  box-shadow: 0 0 8px var(--info);
  animation: pulse 1.5s infinite;
}

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

.tts-status-value.loading,
.tts-status-value.waking {
  color: var(--info);
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.waking {
  background: var(--info);
  opacity: 0.8;
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-tertiary);
}

/* ============================================
   MOBILE NAVIGATION
   ============================================ */
.mobile-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--mobile-nav-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--bg-tertiary);
  padding: 0 var(--space-sm);
  flex-shrink: 0;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-xs) var(--space-md);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
  flex: 1;
  min-width: 64px;
}

.nav-tab .material-symbols-rounded {
  font-size: 24px;
}

.nav-tab span:last-child {
  font-size: 0.7rem;
}

.nav-tab.active {
  color: var(--accent-primary);
}

.nav-tab.active::before {
  content: '';
  position: absolute;
  top: -4px;
  width: 32px;
  height: 3px;
  background: var(--accent-primary);
  border-radius: 2px;
}

.nav-badge {
  position: absolute;
  top: 0;
  right: var(--space-sm);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent-primary);
  border-radius: 9px;
  font-size: 0.65rem;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-badge:empty {
  display: none;
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Panels */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

.panel-sidebar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  max-width: 400px;
  background: var(--bg-secondary);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform var(--transition-base);
}

.panel-sidebar.active {
  transform: translateX(0);
}

.panel-sidebar.panel-tts {
  right: 0;
  left: auto;
  transform: translateX(100%);
}

.panel-sidebar.panel-tts.active {
  transform: translateX(0);
}

.panel-main {
  flex: 1;
  width: 100%;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

/* ============================================
   PROJECTS PANEL
   ============================================ */
.project-selector {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.project-selector select {
  flex: 1;
}

.project-actions {
  margin-bottom: var(--space-md);
}

.project-tree {
  font-size: 0.875rem;
}

/* ============================================
   CHAT PANEL
   ============================================ */
.panel-chat {
  background: var(--bg-primary);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Context Map */
.context-map {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  left: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  overflow: hidden;
}

.context-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--bg-tertiary);
}

.context-map-header span {
  font-weight: 500;
  font-size: 0.875rem;
}

.context-map-viewport {
  padding: var(--space-md);
  display: flex;
  justify-content: center;
}

.context-map-viewport canvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.context-map-legend {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.legend-item.user::before { background: #00bcd4; }
.legend-item.agent::before { background: #2196f3; }
.legend-item.system::before { background: #9e9e9e; }
.legend-item.tool::before { background: #4caf50; }

/* Input Area */
.input-area {
  padding: var(--space-md);
  border-top: 1px solid var(--bg-tertiary);
  background: var(--bg-secondary);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-xl);
  padding: var(--space-sm);
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

.input-wrapper textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  resize: none;
  max-height: 120px;
  padding: var(--space-xs) var(--space-sm);
  font-family: inherit;
}

.input-wrapper textarea:focus {
  outline: none;
}

.input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.input-actions {
  display: flex;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* ============================================
   TTS PANEL
   ============================================ */
.panel-tts {
  background: var(--bg-secondary);
}

/* TTS Status Bar */
.tts-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.tts-status-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.8125rem;
}

.tts-status-label {
  color: var(--text-muted);
}

.tts-status-value {
  font-weight: 500;
}

.tts-vram-bar {
  width: 60px;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.tts-vram-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--warning), var(--error));
  border-radius: 3px;
  transition: width var(--transition-base);
}

/* TTS Tabs */
.tts-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  background: var(--bg-tertiary);
  padding: var(--space-xs);
  border-radius: var(--radius-md);
}

.tts-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tts-tab .material-symbols-rounded {
  font-size: 18px;
}

.tts-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* TTS Tab Content */
.tts-tab-content {
  display: none;
}

.tts-tab-content.active {
  display: block;
}

/* Voice Grid */
.tts-voice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.tts-voice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  border: 2px solid transparent;
}

.tts-voice-card:hover {
  background: var(--bg-elevated);
  border-color: var(--accent-primary);
}

.tts-voice-card .voice-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: 50%;
}

.tts-voice-card .voice-icon .material-symbols-rounded {
  font-size: 24px;
  color: var(--accent-primary);
}

.tts-voice-card .voice-name {
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
}

/* Upload Zone */
.tts-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xl);
  background: var(--bg-tertiary);
  border: 2px dashed var(--bg-elevated);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tts-upload-zone:hover,
.tts-upload-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

.tts-upload-zone p {
  font-weight: 500;
}

.tts-upload-zone small {
  color: var(--text-muted);
}

/* TTS Upload Form */
.tts-upload-form {
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-top: var(--space-md);
}

/* Audio Preview */
.audio-preview {
  width: 100%;
  margin: var(--space-md) 0;
  border-radius: var(--radius-sm);
}

/* TTS Progress */
.tts-progress {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  height: 6px;
  overflow: hidden;
  margin: var(--space-md) 0;
}

.tts-progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  transition: width var(--transition-base);
}

/* Upload Status */
.upload-status {
  padding: var(--space-sm);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: var(--space-sm) 0;
}

/* Form Help Text */
.form-help {
  display: block;
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Optional Label */
.optional {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Activity Log */
.tts-activity-log {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  max-height: 120px;
  overflow-y: auto;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
}

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

.btn-primary {
  background: var(--accent-primary);
}

.btn-primary:hover {
  background: #ff3d5a;
  box-shadow: 0 0 16px rgba(233, 69, 96, 0.4);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

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

.btn-danger {
  background: rgba(248, 113, 113, 0.2);
  color: var(--error);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.3);
}

.btn-icon {
  padding: var(--space-sm);
  border-radius: 50%;
  min-width: 40px;
  min-height: 40px;
}

.btn-icon .material-symbols-rounded {
  font-size: 20px;
}

.btn-small {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
}

.btn-full {
  width: 100%;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group small {
  display: block;
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--bg-elevated);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23a0a0c0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 36px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xl);
  color: var(--text-muted);
  text-align: center;
}

.empty-state .material-symbols-rounded {
  font-size: 48px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.875rem;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed;
  bottom: calc(var(--mobile-nav-height) + var(--space-md));
  left: var(--space-md);
  right: var(--space-md);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
  pointer-events: auto;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

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

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--bg-tertiary);
}

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-body {
  padding: var(--space-md);
  overflow-y: auto;
  max-height: 60vh;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-top: 1px solid var(--bg-tertiary);
}

/* ============================================
   TABLET BREAKPOINT (768px+)
   ============================================ */
@media (min-width: 768px) {
  .mobile-only {
    display: none !important;
  }

  .desktop-only {
    display: flex;
  }

  .main-layout {
    position: static;
  }

  .panel-sidebar {
    position: relative;
    transform: none;
    width: var(--sidebar-width);
    border-right: 1px solid var(--bg-tertiary);
  }

  .panel-sidebar.panel-tts {
    transform: none;
    border-left: 1px solid var(--bg-tertiary);
    border-right: none;
  }

  .panel-sidebar:not(.active) {
    display: none;
  }

  .tts-voice-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .toast-container {
    top: calc(var(--header-height) + var(--space-md));
    bottom: auto;
    left: auto;
    right: var(--space-md);
    width: 320px;
  }
}

/* ============================================
   DESKTOP BREAKPOINT (1024px+)
   ============================================ */
@media (min-width: 1024px) {
  :root {
    --sidebar-width: 280px;
  }

  .panel-projects {
    width: 300px;
  }

  .panel-sidebar:not(.active) {
    display: flex;
  }

  .tts-voice-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   LARGE DESKTOP (1440px+)
   ============================================ */
@media (min-width: 1440px) {
  :root {
    --sidebar-width: 320px;
  }

  .tts-voice-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--bg-elevated);
}

/* ============================================
   TOUCH OPTIMIZATIONS
   ============================================ */
@media (hover: none) {
  .btn:hover {
    background: inherit;
  }

  .btn:active {
    background: var(--bg-hover);
    transform: scale(0.98);
  }

  .btn-primary:active {
    background: #ff3d5a;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   CHAT MESSAGES
   ============================================ */
.message {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  max-width: 85%;
  word-wrap: break-word;
}

.message-user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: var(--space-xs);
}

.message-agent {
  align-self: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--space-xs);
}

.message-system {
  align-self: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: var(--space-sm) var(--space-md);
}

.message-error {
  align-self: center;
  background: rgba(244, 67, 54, 0.1);
  color: var(--error);
  border: 1px solid var(--error);
}

.message-content {
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-meta {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: var(--space-xs);
}

.typing-indicator {
  align-self: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
}

.typing-dots {
  animation: typingBounce 1.4s infinite;
}

@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

/* ============================================
   SESSION LIST
   ============================================ */
.session-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s ease;
  border: 1px solid transparent;
}

.session-item:hover {
  background: var(--bg-hover);
}

.session-item.active {
  background: rgba(255, 62, 93, 0.1);
  border-color: var(--accent);
}

.session-item .material-symbols-rounded {
  font-size: 20px;
  color: var(--text-secondary);
}

.session-item.active .material-symbols-rounded {
  color: var(--accent);
}

.session-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   PROJECT TREE ICONS
   ============================================ */
.tree-icon,
.tree-status,
.tree-expand-icon {
  font-size: 18px !important;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   PROJECT TREE IMPROVEMENTS
   ============================================ */
/* Indentation for subdirectories */
.tree-children {
  padding-left: 16px;
}

/* File name truncation with ellipsis */
.tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0; /* Important for flex truncation */
}

/* Tree item header layout */
.tree-item-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  min-width: 0; /* Important for flex children */
}

.tree-item-header:hover {
  background: var(--bg-hover);
}

.tree-item-header.selected {
  background: var(--accent);
  color: white;
}

/* ============================================
   STT WAVEFORM VISUALIZATION
   ============================================ */
.stt-waveform-container {
  align-self: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin: var(--space-sm) 0;
  width: 100%;
  max-width: 400px;
  animation: recordingPulse 2s ease-in-out infinite;
}

@keyframes recordingPulse {
  0%, 100% { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  50% { border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2); }
}

.stt-waveform-canvas {
  width: 100%;
  height: 60px;
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.stt-recording-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  font-size: 0.875rem;
  color: var(--accent);
}

.stt-recording-indicator .material-symbols-rounded {
  animation: micPulse 1.5s ease-in-out infinite;
  color: #ef4444;
}

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

.stt-recording-timer {
  margin-left: auto;
  font-family: monospace;
  font-weight: 600;
}

/* ============================================
   VOICE NOTE ACTIONS
   ============================================ */
.voice-note-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin: var(--space-sm) 0;
  max-width: 400px;
}

.voice-note-preview {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: var(--space-sm);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  max-height: 80px;
  overflow-y: auto;
}

.voice-note-buttons {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* ============================================
   ACTIVE CALL UI
   ============================================ */
.active-call-ui {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--bg-secondary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 100;
  min-width: 300px;
}

.call-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  color: var(--accent);
}

.call-status .material-symbols-rounded {
  animation: callPulse 1s ease-in-out infinite;
  color: #22c55e;
}

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

.call-transcript {
  width: 100%;
  max-height: 150px;
  overflow-y: auto;
  padding: var(--space-sm);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
}

.call-transcript .transcript-user {
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.call-transcript .transcript-ai {
  color: var(--accent);
  margin-bottom: var(--space-sm);
  padding-left: var(--space-md);
  border-left: 2px solid var(--accent);
}

#endCallBtn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

#endCallBtn:hover {
  background: #dc2626;
  transform: scale(1.05);
}

/* ============================================
   BUTTON STATES FOR VOICE
   ============================================ */
#voiceNoteBtn.recording,
#voiceBtn.recording {
  background: #ef4444;
  color: white;
  animation: buttonPulse 1.5s ease-in-out infinite;
}

#voiceBtn.call-active {
  background: #22c55e;
  color: white;
}

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

/* ============================================
   HIDDEN UTILITY
   ============================================ */
.hidden {
  display: none !important;
}
