@font-face {
  font-family: 'Matthews Notebook';
  src: url('/MatthewsNotebook-Regular.woff?v=1') format('woff'),
       url('/MatthewsNotebook-Regular.ttf?v=1') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-gradient: linear-gradient(135deg, #000000 0%, #06111a 100%);
  --glass-bg: rgba(0, 0, 0, 0.75);
  --glass-border: rgba(13, 160, 226, 0.2);
  --text-primary: #FFFDD0;
  --text-secondary: rgba(255, 253, 208, 0.6);
  --accent-glow: #0da0e2;
  --accent-blue: #0da0e2;
  --accent-green: #0da0e2; /* Replacing green with blue for uniformity */
  --accent-red: #B31B1B;
  --card-shadow: 0 8px 32px 0 rgba(13, 160, 226, 0.15);
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

html {
  background-color: #0b0f19;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
}

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

/* Auth Page */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
}

.auth-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  padding: 2.5rem;
  border-radius: 20px;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--card-shadow);
  text-align: center;
}

.auth-logo {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(to right, var(--accent-red), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.input-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.input-group input {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(31, 41, 55, 0.5);
  color: white;
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: all 0.3s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-glow);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

.auth-btn {
  width: 100%;
  padding: 0.9rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent-glow) 0%, var(--accent-blue) 100%);
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
  transition: all 0.3s ease;
}

.auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

/* Dashboard Layout */
.dashboard-layout {
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Left Sidebar */
.sidebar {
  width: 280px;
  background: transparent;
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
}

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

.brand {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-indicator {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-indicator.active {
  color: var(--accent-green);
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

/* Tab Switcher Headers */
.tab-switchers {
  display: flex;
  padding: 0.5rem;
  gap: 0.25rem;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(128, 128, 128, 0.08);
  backdrop-filter: blur(12px);
}

.tab-switchers button {
  flex: 1;
  padding: 0.6rem 0.2rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-switchers button:hover {
  color: var(--text-primary);
  background: rgba(128, 128, 128, 0.15);
}

.tab-switchers button.active {
  color: var(--text-primary);
  background: rgba(128, 128, 128, 0.25);
  border: 1px solid rgba(128, 128, 128, 0.4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  font-weight: 700;
}

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

.new-chat-btn {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px dashed var(--accent-glow);
  background: rgba(139, 92, 246, 0.05);
  color: #a78bfa;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 1.25rem;
}

.new-chat-btn:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: #a78bfa;
  transform: translateY(-1px);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin: 1rem 0 0.5rem 0.25rem;
}

/* File items and conversation logs */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.file-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.file-item.selected {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
  border-left: 3px solid var(--accent-blue);
}

.conv-info {
  display: flex;
  flex-direction: column;
}

.conv-title {
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-id {
  font-size: 0.7rem;
  opacity: 0.6;
}

.workspace-input-container {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.workspace-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid var(--glass-border);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.8rem;
}

.workspace-btn {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: none;
  background: var(--accent-blue);
  color: white;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Chat Canvas Panel */
.main-canvas {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(17, 24, 39, 0.1);
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
}

html.theme-light .chat-panel {
  background-color: #FFFDD0 !important;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.18'/%3E%3C/svg%3E") !important;
}

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

.chat-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(128, 128, 128, 0.08);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.resume-btn {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.resume-btn:hover {
  background: var(--accent-green);
  color: white;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-height: 0;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.chat-messages::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.message-bubble {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  line-height: 1.45;
  font-size: var(--chat-font-size, 0.92rem);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
  word-break: break-word;
  overflow-wrap: break-word;
}

.message-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent-glow) 0%, var(--accent-blue) 100%);
  color: white;
  border-bottom-right-radius: 2px;
}

.message-bubble.assistant {
  align-self: flex-start;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-bottom-left-radius: 2px;
}

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

/* Thoughts and tool blocks */
.thought-block {
  align-self: flex-start;
  border-radius: 8px;
  background: rgba(31, 41, 55, 0.4);
  border-left: 3px solid var(--accent-glow);
  width: 85%;
  overflow: hidden;
}

/* Markdown Table Styling */
.chat-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85rem 0;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.chat-markdown th {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-weight: 600;
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

.chat-markdown td {
  padding: 0.55rem 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-markdown tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.chat-markdown tr:last-child td {
  border-bottom: none;
}

.thought-header {
  padding: 0.5rem 0.85rem;
  background: rgba(255, 255, 255, 0.01);
  font-size: 0.8rem;
  font-weight: 500;
  color: #a78bfa;
}

.thought-content {
  padding: 0.75rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  color: #c084fc;
  max-height: 180px;
  overflow-y: auto;
}

.tool-log {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.1);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  width: 80%;
  white-space: pre-wrap;
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 1.25rem 1.5rem;
  background: rgba(11, 15, 25, 0.95);
  border-top: 1px solid var(--glass-border);
  display: flex;
  gap: 0.75rem;
  align-items: flex-end; /* Pin buttons to bottom when text bar expands */
}

.chat-input {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(31, 41, 55, 0.5);
  color: white;
  font-family: var(--font-sans);
  font-size: var(--chat-font-size, 0.92rem);
  transition: border-color 0.2s ease;
  resize: none;
  height: 42px;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.45;
}

.upload-icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 1.1rem;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.upload-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  border-color: var(--accent-blue);
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-glow);
}

.send-btn {
  height: 42px;
  padding: 0 1.25rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent-glow) 0%, var(--accent-blue) 100%);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Slash Autocomplete Popup */
.slash-popup {
  position: absolute;
  bottom: 5.5rem;
  left: 1.5rem;
  right: 1.5rem;
  background: #111827;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
}

.slash-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.slash-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.slash-name {
  font-family: var(--font-mono);
  color: var(--accent-blue);
  font-weight: 600;
}

.slash-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Right Auxiliary Pane */
.aux-pane {
  width: 320px;
  background: transparent;
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
}

.aux-content {
  flex: 1;
  overflow: hidden;
  padding: 1rem;
}

/* Code Editor Subpanel */
.editor-subpanel {
  height: 280px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.editor-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: #e5e7eb;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  resize: none;
}

.editor-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Raw Logs Terminal Pane */
.terminal-panel {
  display: flex;
  flex-direction: column;
  background: transparent;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  overflow: hidden;
}

.terminal-header {
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.terminal-output {
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: hidden;
  line-height: 1.35;
}

/* Artifacts/Markdown Preview Tab */
.markdown-preview {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 {
  margin: 1rem 0 0.5rem 0;
  color: var(--text-primary);
}

.markdown-preview h1 { font-size: 1.2rem; }
.markdown-preview h2 { font-size: 1.05rem; }

.markdown-preview p {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.markdown-preview code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.78rem;
}

.markdown-preview pre {
  background: #080c14;
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
  max-width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.75rem;
}

/* Mobile Layout */
@media (max-width: 768px) {
  .dashboard-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
  }
  .main-canvas {
    flex: 1;
    height: calc(100vh - 180px);
  }
  .aux-pane {
    display: none; /* Hide aux panel on tablet/mobile to focus on chat */
  }
}

/* Live Activity Panel */
.live-activity-container {
  align-self: flex-start;
  width: 90%;
  background: rgba(31, 41, 55, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  margin-top: 0.5rem;
}

.live-activity-header {
  padding: 0.5rem 0.85rem;
  background: rgba(139, 92, 246, 0.08);
  font-size: 0.8rem;
  font-weight: 600;
  color: #a78bfa;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.1);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-green);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse-animation 1.5s infinite ease-in-out;
}

@keyframes pulse-animation {
  0% {
    transform: scale(0.85);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 12px var(--accent-green);
  }
  100% {
    transform: scale(0.85);
    opacity: 0.5;
  }
}

.live-activity-content {
  padding: 0.75rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  color: #c084fc;
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.4;
}

/* Mobile Navigation Bar & Responsive Visibility */
.mobile-nav-bar {
  display: none; /* Hidden by default on desktop */
}

@media (max-width: 768px) {
  .dashboard-layout {
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
  }

  /* Control visibility of panels on mobile */
  .sidebar.mobile-hidden,
  .main-canvas.mobile-hidden,
  .aux-pane.mobile-hidden {
    display: none !important;
  }

  .sidebar.mobile-visible,
  .main-canvas.mobile-visible,
  .aux-pane.mobile-visible {
    display: flex !important;
    flex: 1 !important;
    width: 100% !important;
    height: calc(100% - 50px) !important;
    min-height: 0 !important;
  }

  /* Mobile Top Navigation Bar */
  .mobile-nav-bar {
    display: flex;
    height: 50px;
    min-height: 50px;
    width: 100%;
    background: rgba(11, 15, 25, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
    position: sticky;
    top: 0;
  }

  .mobile-nav-bar button {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px;
    height: 100%;
  }

  .mobile-nav-bar button:hover {
    color: var(--text-primary);
  }

  .mobile-nav-bar button.active {
    color: var(--accent-glow);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 2px solid var(--accent-glow);
  }

  .nav-icon {
    font-size: 1rem;
  }

  .nav-text {
    font-size: 0.85rem;
    font-weight: 500;
  }

  /* Mobile Message Bubble & Responsive Table Safety */
  .message-bubble {
    max-width: 95% !important;
    padding: 0.75rem 0.85rem !important;
  }

  .chat-markdown table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap !important;
    border-collapse: collapse !important;
  }

  .chat-markdown th,
  .chat-markdown td {
    white-space: nowrap !important;
    padding: 0.45rem 0.65rem !important;
    font-size: 0.8rem !important;
  }
}

/* Chat Markdown Rendering Styles */
.chat-markdown {
  font-size: var(--chat-font-size, 0.92rem);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
}

.chat-markdown img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 8px;
  display: block;
  margin: 0.75rem auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  object-fit: contain;
}

.chat-markdown p {
  margin-bottom: 0.75rem;
}

.chat-markdown p:last-child {
  margin-bottom: 0;
}

.chat-markdown h1, .chat-markdown h2, .chat-markdown h3 {
  margin: 1rem 0 0.5rem 0;
  color: var(--text-primary);
}

.chat-markdown code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.9em;
  word-break: break-all;
}

.chat-markdown pre {
  background: #080c14;
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.75rem;
  border: 1px solid var(--glass-border);
  white-space: pre-wrap !important;
  word-break: break-word !important;
}

.chat-markdown pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.85em;
  white-space: pre-wrap !important;
  word-break: break-word !important;
}

/* Collapsible Status Bars (Thoughts & Tools) */
details.thought-collapse,
details.tool-collapse {
  align-self: flex-start;
  width: 90%;
  background: rgba(31, 41, 55, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 0.25rem;
  transition: all 0.3s ease;
}

details.thought-collapse[open],
details.tool-collapse[open] {
  background: rgba(31, 41, 55, 0.4);
  border-color: rgba(139, 92, 246, 0.3);
}

summary.thought-summary,
summary.tool-summary {
  padding: 0.5rem 0.85rem;
  font-size: 0.85em;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  outline: none;
  list-style: none; /* Hide default arrow in Chrome/Safari */
}

summary.thought-summary::-webkit-details-marker,
summary.tool-summary::-webkit-details-marker {
  display: none; /* Hide default arrow in Chrome/Safari */
}

summary.thought-summary:hover,
summary.tool-summary:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.thought-summary span,
.tool-summary span {
  font-family: var(--font-sans);
}

.thought-content,
.tool-content {
  padding: 0.75rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.8em;
  white-space: pre-wrap;
  color: #c084fc;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--glass-border);
  max-height: 200px;
  overflow-y: auto;
}

.tool-content {
  color: #38bdf8;
}

/* Secure Tables from stretching layout */
.markdown-preview table,
.chat-markdown table {
  max-width: 100%;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}

/* Rate Limit Pill */
@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); border-color: #ef4444; }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); border-color: #ff4b4b; }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); border-color: #ef4444; }
}

@keyframes pulse-amber {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); border-color: #f59e0b; }
  70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); border-color: #fbbf24; }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); border-color: #f59e0b; }
}

.rate-limit-pill {
  display: flex;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 0.3rem 0.7rem;
  align-items: center;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}
.rate-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.rate-icon {
  font-size: 0.8rem;
  opacity: 0.8;
}
.rate-text {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  display: flex;
  align-items: baseline;
  gap: 0.1rem;
}
.rate-val {
  color: var(--text-primary);
  font-weight: 600;
}
.rate-max {
  color: var(--text-secondary);
  font-size: 0.7rem;
}
.rate-label {
  color: var(--accent-blue);
  font-weight: 600;
  font-size: 0.7rem;
  margin-left: 0.15rem;
}

/* Model Switcher */
.model-switcher {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #06111a !important;
  border: 1.5px solid rgba(13, 160, 226, 0.6) !important;
  padding: 0.3rem 0.75rem !important;
  border-radius: 8px !important;
  transition: all 0.2s ease !important;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.model-switcher:hover {
  border-color: #0da0e2 !important;
  background: #0b1c2d !important;
  box-shadow: 0 0 12px rgba(13, 160, 226, 0.35);
}

.model-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.model-select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background: transparent !important;
  border: none !important;
  color: #FFFDD0 !important; /* Norrington Cream */
  font-family: var(--font-sans);
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  cursor: pointer;
  outline: none !important;
  padding-right: 1.5rem !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%230da0e2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right center !important;
  background-size: 12px !important;
}

.model-select option {
  background: #06111a !important; /* Norrington Dark Navy */
  color: #FFFDD0 !important; /* Norrington Cream */
  font-weight: 500 !important;
  padding: 0.5rem 0.75rem !important;
}

/* Code Collapse Details */
.code-collapse {
  background: rgba(139, 92, 246, 0.04);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  align-self: flex-start;
  width: 95%;
  transition: all 0.2s ease;
}

.code-collapse:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.25);
}

.code-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-secondary);
  outline: none;
  font-weight: 500;
  user-select: none;
  list-style: none; /* Hide default triangle in Chrome/Safari */
}

.code-summary::-webkit-details-marker {
  display: none; /* Hide default triangle in WebKit */
}

.code-collapse[open] .code-summary {
  border-bottom: 1px solid var(--glass-border);
  background: rgba(139, 92, 246, 0.05);
  color: var(--text-primary);
}

.code-collapse .chat-markdown {
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.2);
}

/* Light Theme Overrides */
html.theme-light {
  background-color: #FFFDD0;
}

html.theme-light .sidebar {
  background: transparent;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

html.theme-light .aux-pane {
  background: transparent;
  border-left: 1px solid rgba(0, 0, 0, 0.1);
}

html.theme-light .chat-input-wrapper {
  background: rgba(255, 253, 208, 0.95);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

html.theme-light .message-bubble.assistant {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

html.theme-light .message-bubble.user {
  background: rgba(13, 160, 226, 0.1);
  border-color: rgba(13, 160, 226, 0.2);
  color: var(--text-primary);
}

html.theme-light .workspace-btn {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

html.theme-light .workspace-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

html.theme-light .file-item:hover,
html.theme-light .slash-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

html.theme-light .workspace-input,
html.theme-light .chat-input {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-primary);
  border-color: rgba(0, 0, 0, 0.2);
}

html.theme-light .chat-input::placeholder {
  color: rgba(0, 0, 0, 0.4);
}

html.theme-light .thought-collapse,
html.theme-light .tool-collapse {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

html.theme-light .thought-content,
html.theme-light .tool-content {
  background: rgba(255, 255, 255, 0.5);
  border-top-color: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

html.theme-light .chat-markdown pre {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

html.theme-light .chat-markdown code {
  background: rgba(0, 0, 0, 0.06);
  color: var(--accent-red);
}

html.theme-light .tab-switchers button:hover,
html.theme-light .tab-switchers button.active {
  background: rgba(0, 0, 0, 0.05);
}

html.theme-light .slash-popup {
  background: rgba(255, 253, 208, 0.95);
  border-color: rgba(0, 0, 0, 0.1);
}

html.theme-light .message-header {
  color: rgba(0, 0, 0, 0.6);
}



html.theme-light .terminal-panel,
html.theme-light .markdown-preview,
html.theme-light .editor-textarea {
  background: transparent;
  color: var(--text-primary);
}

html.theme-light .terminal-output pre {
  color: var(--text-primary);
}

html.theme-light .model-switcher {
  background: #06111a !important;
  border: 1.5px solid #0da0e2 !important;
  box-shadow: 0 2px 8px rgba(6, 17, 26, 0.3) !important;
}

html.theme-light .model-switcher:hover {
  border-color: #0da0e2 !important;
  background: #0b1c2d !important;
  box-shadow: 0 0 12px rgba(13, 160, 226, 0.35) !important;
}

html.theme-light .model-select {
  color: #FFFDD0 !important; /* Norrington Cream for maximum contrast on dark navy pill */
  font-weight: 600 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%230da0e2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

html.theme-light .model-select option {
  background: #06111a !important;
  color: #FFFDD0 !important;
  font-weight: 500 !important;
}

html.theme-light select option {
  background: #06111a !important;
  color: #FFFDD0 !important;
}

/* Update .sidebar to be transparent */
.sidebar {
  width: 280px;
  background: transparent !important;
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-x: hidden;
}

/* Update .aux-pane to be transparent */
.aux-pane {
  width: 320px;
  background: transparent !important;
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Update .terminal-panel to be transparent */
.terminal-panel {
  display: flex;
  flex-direction: column;
  background: transparent !important;
}

/* Override light theme backgrounds to be transparent for all panes */
html.theme-light .sidebar {
  background: transparent;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

html.theme-light .aux-pane {
  background: transparent;
  border-left: 1px solid rgba(0, 0, 0, 0.1);
}

html.theme-light .terminal-panel,
html.theme-light .markdown-preview,
html.theme-light .editor-textarea {
  background: transparent;
  color: var(--text-primary);
}

/* Add the Parchment Texture to the Light Mode Chat Panel */
html.theme-light .chat-panel {
  background-color: #FFFDD0 !important;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.18'/%3E%3C/svg%3E") !important;
}

/* Global High Contrast Dropdown Menus Everywhere in maIry */
select, .model-select {
  background-color: #071524 !important;
  color: #FFFFFF !important;
  border: 1px solid #0da0e2 !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  outline: none !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6) !important;
}

select:focus, .model-select:focus {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6) !important;
}

select option, .model-select option, option {
  background-color: #06111a !important;
  color: #FFFFFF !important;
  font-family: var(--font-sans);
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  padding: 0.6rem 0.8rem !important;
}

select option:hover,
select option:focus,
select option:checked,
.model-select option:hover,
.model-select option:focus,
.model-select option:checked {
  background-color: #0da0e2 !important;
  color: #FFFFFF !important;
  font-weight: 700 !important;
}

