:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, monospace;
  
  --bg-dark: #0b0f17;
  --bg-sidebar: #111827;
  --bg-card: #1f2937;
  --bg-card-hover: #283548;
  --bg-input: #111827;
  --bg-bubble-user: #2563eb;
  --bg-bubble-ai: #1e293b;
  
  --border-color: #374151;
  --border-focus: #3b82f6;
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

/* APP SHELL */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 290px;
  min-width: 290px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
  user-select: none;
  z-index: 10;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #60a5fa 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-secondary);
  display: block;
}

.connection-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  background: rgba(31, 41, 55, 0.8);
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  flex-shrink: 0;
}

.btn-new-chat {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.btn-new-chat:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* NAV TABS */
.nav-tabs {
  display: flex;
  background: #0f172a;
  padding: 4px;
  border-radius: 8px;
  gap: 2px;
}

.nav-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  background: var(--bg-card);
  color: #60a5fa;
  box-shadow: var(--shadow-sm);
}

/* SIDEBAR CONTROLS */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
}

.select-field {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.select-field:focus {
  border-color: var(--border-focus);
}

.badge-count {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
}

/* CONVERSATIONS LIST */
.conversations-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12.5px;
  transition: all 0.12s;
  border: 1px solid transparent;
}

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

.conversation-item.active {
  background: var(--bg-card);
  color: #93c5fd;
  border-color: var(--border-color);
  font-weight: 500;
}

.conversation-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.btn-del-conv {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
  transition: opacity 0.15s;
}

.conversation-item:hover .btn-del-conv {
  opacity: 1;
}

.btn-del-conv:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.15);
}

.empty-list {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 24px 0;
}

.sidebar-footer {
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}

.footer-link:hover {
  color: var(--accent-blue);
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  background-color: var(--bg-dark);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* VIEW PANELS */
.view-panel {
  display: none;
  height: 100%;
  width: 100%;
  overflow-y: auto;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
}

/* CHAT VIEW */
#view-chat {
  overflow: hidden;
}

.chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(8px);
}

.chat-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar-sm {
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.chat-title-box h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.chat-title-box p {
  font-size: 12px;
  color: var(--text-secondary);
}

.model-badge {
  font-size: 11px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* MESSAGES CONTAINER */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

/* WELCOME CARD */
.welcome-card {
  margin: auto;
  text-align: center;
  max-width: 600px;
  padding: 40px 24px;
  background: rgba(31, 41, 55, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.welcome-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.welcome-card p {
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.quick-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  transform: translateX(2px);
}

/* MESSAGE BUBBLES */
.message-row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.message-row.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.message-row.user .message-avatar {
  background: #1d4ed8;
  border-color: #3b82f6;
}

.message-content-wrapper {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: var(--bg-bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-row.assistant .message-bubble {
  background: var(--bg-bubble-ai);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.message-bubble p {
  margin-bottom: 8px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}

.message-bubble pre {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
  position: relative;
}

.message-bubble pre code {
  background: transparent;
  padding: 0;
}

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.message-bubble pre:hover .copy-code-btn {
  opacity: 1;
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* LISTS & BULLETS */
.message-bubble ul,
.message-bubble ol {
  padding-left: 28px;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-bubble li {
  line-height: 1.6;
  padding-left: 4px;
}

.message-bubble ul li {
  list-style-type: disc;
}

.message-bubble ol li {
  list-style-type: decimal;
}

/* TABLES */
.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13px;
  background: rgba(15, 23, 42, 0.7);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.message-bubble thead {
  background: #1e293b;
}

.message-bubble th {
  color: #93c5fd;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.message-bubble td {
  padding: 9px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.message-bubble tr:last-child td {
  border-bottom: none;
}

.message-bubble tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}

/* IMAGES */
.message-bubble img {
  max-width: 100%;
  max-height: 480px;
  object-fit: cover;
  border-radius: 10px;
  margin: 12px 0;
  border: 1px solid var(--border-color);
  display: block;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s;
}

.message-bubble img:hover {
  transform: scale(1.005);
}

/* LINKS */
.message-bubble a {
  color: #60a5fa;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}

.message-bubble a:hover {
  color: #93c5fd;
}

/* BLOCKQUOTES */
.message-bubble blockquote {
  border-left: 3px solid #3b82f6;
  padding-left: 12px;
  margin: 10px 0;
  color: var(--text-secondary);
  font-style: italic;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 0 6px 6px 0;
  padding-top: 4px;
  padding-bottom: 4px;
}

/* METADATA ACCORDIONS (Fuentes y Conocimiento aprendido) */
.bubble-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.meta-box {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
}

.meta-box summary {
  cursor: pointer;
  color: var(--accent-cyan);
  font-weight: 500;
  user-select: none;
}

.meta-box.learned summary {
  color: var(--accent-green);
}

.meta-list {
  margin-top: 6px;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 12px;
}

.meta-list li {
  margin-bottom: 3px;
}

/* CHAT INPUT BAR */
.chat-input-bar {
  padding: 14px 24px;
  border-top: 1px solid var(--border-color);
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

.input-toggles {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11.5px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.toggle-chip input[type="checkbox"] {
  display: none;
}

.toggle-chip:has(input:checked) {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-blue);
  color: #93c5fd;
}

.toggle-icon {
  font-size: 13px;
}

.status-indicator {
  font-size: 11.5px;
  color: var(--accent-amber);
  margin-left: auto;
  font-style: italic;
}

.input-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#input-message {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-sans);
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 160px;
  transition: border-color 0.15s;
}

#input-message:focus {
  border-color: var(--border-focus);
}

.btn-send {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-send:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

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

/* GENERAL PANEL HEADERS */
.panel-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(17, 24, 39, 0.4);
}

.panel-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.panel-header p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

/* GEMAS GRID VIEW */
#view-gemas {
  padding: 0;
}

.cards-grid {
  padding: 28px 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  overflow-y: auto;
}

.gema-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
  position: relative;
}

.gema-card:hover {
  border-color: #4b5563;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.gema-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gema-icon {
  font-size: 28px;
  width: 46px;
  height: 46px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gema-info h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.gema-badge-builtin {
  font-size: 10px;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.gema-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  flex: 1;
}

.gema-prompt-preview {
  font-size: 11px;
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.gema-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.btn-gema-use {
  flex: 1;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-gema-use:hover {
  background: var(--accent-blue);
  color: #fff;
}

.btn-gema-del {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-gema-del:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

/* KNOWLEDGE VIEW */
.knowledge-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  padding: 28px 32px;
  flex: 1;
  min-height: 0;
}

.knowledge-form-box, .knowledge-search-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.knowledge-form-box h3, .knowledge-search-box h3 {
  font-size: 16px;
  font-weight: 600;
}

.knowledge-form-box label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

.knowledge-form-box input, .knowledge-form-box textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.knowledge-form-box input:focus, .knowledge-form-box textarea:focus {
  border-color: var(--border-focus);
}

.search-bar {
  display: flex;
  gap: 8px;
}

.search-bar input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.search-results-box {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
}

.knowledge-card {
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.knowledge-card strong {
  font-size: 13.5px;
  color: #60a5fa;
}

.knowledge-card small {
  color: var(--text-muted);
  font-size: 11px;
}

.knowledge-card p {
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.4;
  margin-top: 4px;
}

/* PROJECTS WORKBENCH */
.projects-workbench {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  padding: 28px 32px;
  flex: 1;
  min-height: 0;
}

.workbench-form, .workbench-results {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.workbench-form h3, .workbench-results h3 {
  font-size: 16px;
  font-weight: 600;
}

.workbench-form label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

.workbench-form input, .workbench-form textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.workbench-form input:focus, .workbench-form textarea:focus {
  border-color: var(--border-focus);
}

.runs-history-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.run-chip {
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.run-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.run-chip.active {
  border-color: var(--accent-blue);
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
}

.run-detail-view {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.spec-output {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.2s;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 500px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.btn-icon:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.modal-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.modal-card input, .modal-card textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.modal-card input:focus, .modal-card textarea:focus {
  border-color: var(--border-focus);
}

.form-row {
  display: flex;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

/* BUTTONS */
.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.empty-hint {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 30px 10px;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .knowledge-layout, .projects-workbench {
    grid-template-columns: 1fr;
  }
}
