/* ==========================================================================
   Design Tokens & Modern Dark Slate Palette
   ========================================================================== */
:root {
  /* Canvas & Surfaces */
  --canvas: #090a0d;
  --surface-base: #111318;
  --surface-subtle: #161922;
  --surface-elevated: #1c202b;
  --surface-active: #242937;

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: #52525b;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;

  --text-primary: #f4f4f6;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-faint: #52525b;

  /* Semantics & Status (Muted & Restrained) */
  --status-verified: #34d399;
  --status-verified-bg: rgba(52, 211, 153, 0.08);
  --status-verified-border: rgba(52, 211, 153, 0.22);

  --status-generated: #94a3b8;
  --status-generated-bg: rgba(148, 163, 184, 0.08);
  --status-generated-border: rgba(148, 163, 184, 0.2);

  --status-warning: #fbbf24;
  --status-warning-bg: rgba(251, 191, 36, 0.08);
  --status-warning-border: rgba(251, 191, 36, 0.22);

  --status-info: #60a5fa;
  --status-info-bg: rgba(96, 165, 250, 0.08);
  --status-info-border: rgba(96, 165, 250, 0.2);

  /* User Bubble */
  --user-bubble-bg: #20242f;
  --user-bubble-border: rgba(255, 255, 255, 0.1);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background-color: var(--canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ==========================================================================
   Layout Hierarchy
   ========================================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background-color: var(--surface-base);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem 1rem;
  gap: 1.25rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-version {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Telemetry Card */
.system-card {
  background-color: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--text-muted);
  flex-shrink: 0;
  transition: background-color 0.3s ease;
}

.pulse-dot.ok {
  background-color: var(--status-verified);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}

.pulse-dot.loading {
  background-color: var(--text-secondary);
  animation: pulseGentle 1.8s ease-in-out infinite;
}

.pulse-dot.error {
  background-color: #f87171;
}

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

.status-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.system-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

.stat-item {
  background-color: var(--surface-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-detail {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}

/* Sidebar Actions */
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background-color: transparent;
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s ease;
  width: 100%;
}

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

.action-btn:active {
  background-color: var(--surface-elevated);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-faint);
}

.meta-divider {
  font-size: 0.6rem;
}

/* ==========================================================================
   Chat Workspace
   ========================================================================== */
.chat-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  min-width: 0;
  background-color: var(--canvas);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2.5rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.empty-state {
  margin: auto;
  max-width: 580px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  animation: fadeIn 0.4s ease-out;
}

.empty-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  background-color: var(--surface-subtle);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.empty-title {
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 440px;
  line-height: 1.55;
  margin-bottom: 2rem;
}

.suggestions-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
}

.prompt-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.1rem;
  background-color: var(--surface-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: left;
  transition: all 0.18s ease;
  width: 100%;
}

.prompt-card:hover {
  background-color: var(--surface-subtle);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.prompt-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.prompt-content {
  display: flex;
  flex-direction: column;
}

.prompt-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.prompt-text {
  font-size: 0.85rem;
  color: var(--text-primary);
}

/* ==========================================================================
   Message Rows & Bubbles
   ========================================================================== */
.msg-row {
  width: 100%;
  max-width: 820px;
  margin-bottom: 2rem;
  animation: subtleFadeSlide 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

/* User Message */
.msg-user {
  display: flex;
  justify-content: flex-end;
}

.msg-user .bubble {
  background-color: var(--user-bubble-bg);
  border: 1px solid var(--user-bubble-border);
  color: var(--text-primary);
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-sm) var(--radius-xl);
  max-width: 82%;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}

/* Assistant Message */
.msg-assistant {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Badges */
.badge-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  user-select: none;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.pill-verified {
  background-color: var(--status-verified-bg);
  color: var(--status-verified);
  border: 1px solid var(--status-verified-border);
}

.pill-generated {
  background-color: var(--status-generated-bg);
  color: var(--text-secondary);
  border: 1px solid var(--status-generated-border);
}

.match-similarity {
  opacity: 0.85;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* Callout Banners */
.banner-box {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.45;
}

.banner-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.banner-warning {
  background-color: var(--status-warning-bg);
  border: 1px solid var(--status-warning-border);
  color: var(--status-warning);
}

.banner-info {
  background-color: var(--status-info-bg);
  border: 1px solid var(--status-info-border);
  color: var(--status-info);
}

/* ==========================================================================
   Code Cards & Syntax Highlighting
   ========================================================================== */
.code-card {
  background-color: #12141a;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.code-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.95rem;
  background-color: var(--surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.file-icon {
  color: var(--text-muted);
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.code-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  background-color: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

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

.code-btn.copied {
  color: var(--status-verified);
  border-color: var(--status-verified-border);
}

.code-card pre {
  margin: 0;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  background-color: #0e1015;
}

.code-card code {
  font-family: var(--font-mono) !important;
  font-size: 0.85rem !important;
  line-height: 1.65 !important;
}

/* ==========================================================================
   Project Structure & File Tabs
   ========================================================================== */
.project-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.project-tree-box {
  background-color: var(--surface-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre;
  overflow-x: auto;
}

.tree-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.project-browser {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-tab-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.25rem 0;
}

.file-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  background-color: var(--surface-base);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  transition: all 0.15s ease;
}

.file-tab-btn:hover {
  background-color: var(--surface-subtle);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.file-tab-btn.active {
  background-color: var(--surface-elevated);
  border-color: var(--border-strong);
  color: var(--text-primary);
  font-weight: 500;
}

.zip-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 0.83rem;
  font-weight: 500;
  width: fit-content;
  transition: all 0.18s ease;
  margin-top: 0.25rem;
}

.zip-download-btn:hover {
  background-color: var(--surface-active);
  border-color: #71717a;
  transform: translateY(-1px);
}

/* ==========================================================================
   Calm Understated Thinking State
   ========================================================================== */
.thinking-box {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-lg);
  background-color: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  width: fit-content;
  animation: subtleFadeSlide 0.2s ease-out;
}

.thinking-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--text-muted);
  animation: calmPulse 1.4s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes calmPulse {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.3;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
    background-color: var(--text-secondary);
  }
}

.thinking-label {
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Composer Section
   ========================================================================== */
.composer-container {
  padding: 0.75rem 1.5rem 1.5rem;
  display: flex;
  justify-content: center;
  background: linear-gradient(to top, var(--canvas) 85%, transparent 100%);
}

.composer-surface {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background-color: var(--surface-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.85rem 0.65rem 1.15rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.composer-input-row:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus);
}

textarea#input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.5;
  resize: none;
  max-height: 180px;
  min-height: 24px;
  padding: 0.25rem 0;
}

textarea#input::placeholder {
  color: var(--text-faint);
}

.send-action-btn {
  background-color: var(--text-primary);
  color: var(--canvas);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.send-action-btn:hover {
  background-color: #ffffff;
  transform: scale(1.04);
}

.send-action-btn:active {
  transform: scale(0.96);
}

.send-action-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  transform: none;
}

.composer-hints {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  font-size: 0.72rem;
  color: var(--text-faint);
  padding: 0 0.25rem;
}

.hint-dot {
  font-size: 0.5rem;
}

kbd {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  background-color: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--text-muted);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .messages-container {
    padding: 1.5rem 1rem;
  }
  .composer-container {
    padding: 0.5rem 1rem 1rem;
  }
}
