/* ==========================================================================
   ATLAS BY VYLEX TECHNOLOGIES — DESIGN SYSTEM
   Premium AI workspace aesthetic. https://vylex.co.za
   ========================================================================== */

/* --------------------------------------------------------------------------
   THEME DEFINITIONS & DESIGN TOKENS
   -------------------------------------------------------------------------- */

:root, [data-theme="vylex"] {
  --bg-app: #051B38;
  --bg-sidebar: #031227;
  --bg-card: #0A2E5C;
  --bg-card-hover: #0E3D7A;
  --bg-composer: #0A2E5C;
  --bg-canvas: #031227;
  --bg-code: #020B18;
  
  --accent-primary: #FBA919;
  --accent-secondary: #FBBF24;
  --accent-solid: #FBA919;
  --accent-hover: #D97706;

  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-active: #FBA919;

  --message-user-bg: #0A2E5C;
  --message-user-border: rgba(251, 169, 25, 0.12);
  --message-ai-bg: #051B38;
  --message-ai-border: rgba(255, 255, 255, 0.05);

  --font-display: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --pill-active-bg: rgba(251, 169, 25, 0.16);
  --pill-active-text: #FBA919;
}

[data-theme="obsidian"] {
  --bg-app: #141311;
  --bg-sidebar: #1a1815;
  --bg-card: #23201c;
  --bg-card-hover: #2d2924;
  --bg-composer: #1e1b18;
  --bg-canvas: #161412;
  --bg-code: #0e0d0c;

  --accent-primary: #c86446;
  --accent-secondary: #e07a5f;
  --accent-solid: #c86446;
  --accent-hover: #b45309;

  --text-main: #f5efe6;
  --text-secondary: #ded6c9;
  --text-muted: #a89f91;
  --text-subtle: #787063;

  --border-subtle: rgba(245, 239, 230, 0.09);
  --border-medium: rgba(245, 239, 230, 0.16);
  --border-active: #c86446;

  --message-user-bg: #272420;
  --message-user-border: rgba(245, 239, 230, 0.12);
  --message-ai-bg: #1e1b18;
  --message-ai-border: rgba(245, 239, 230, 0.08);

  --font-display: 'Lora', Georgia, serif;
  --font-body: 'Lora', Georgia, serif;
  --pill-active-bg: rgba(200, 100, 70, 0.18);
  --pill-active-text: #e07a5f;
}

[data-theme="carbon"] {
  --bg-app: #0f0f0f;
  --bg-sidebar: #171717;
  --bg-card: #212121;
  --bg-card-hover: #2c2c2c;
  --bg-composer: #1f1f1f;
  --bg-canvas: #141414;
  --bg-code: #0a0a0a;

  --accent-primary: #10a37f;
  --accent-secondary: #22c55e;
  --accent-solid: #10a37f;
  --accent-hover: #0d8b6c;

  --text-main: #f3f4f6;
  --text-secondary: #e5e7eb;
  --text-muted: #9ca3af;
  --text-subtle: #6b7280;

  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-active: #10a37f;

  --message-user-bg: #262626;
  --message-user-border: rgba(255, 255, 255, 0.12);
  --message-ai-bg: #1a1a1a;
  --message-ai-border: rgba(255, 255, 255, 0.07);

  --font-display: 'Outfit', sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --pill-active-bg: rgba(16, 163, 127, 0.18);
  --pill-active-text: #10a37f;
}

/* --------------------------------------------------------------------------
   GLOBAL RESET
   -------------------------------------------------------------------------- */

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* --------------------------------------------------------------------------
   APP LAYOUT
   -------------------------------------------------------------------------- */

.app-layout {
  display: flex;
  height: 100dvh;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   LEFT SIDEBAR
   -------------------------------------------------------------------------- */

.sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: margin-left 0.2s ease, transform 0.2s ease;
  user-select: none;
}

.sidebar.collapsed {
  margin-left: -260px;
}

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

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

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent-solid);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.brand-info h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.brand-sub {
  display: none;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

/* New Session Button */
.sidebar-actions {
  padding: 8px 10px;
}

.new-chat-btn {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.new-chat-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-medium);
}

.shortcut-badge {
  margin-left: auto;
  font-size: 0.65rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-subtle);
  font-family: 'JetBrains Mono', monospace;
}

/* History Search Box */
.history-search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px 8px 10px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-muted);
}

.history-search-box input {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 0.78rem;
  width: 100%;
  outline: none;
  font-family: inherit;
}

/* History Scroll Tree */
.history-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.history-group-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  padding: 3px 6px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.history-item.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
  font-weight: 600;
}

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

.history-item-actions {
  display: none;
  align-items: center;
}

.history-item:hover .history-item-actions {
  display: flex;
}

.item-action-btn {
  background: none;
  border: none;
  color: var(--text-subtle);
  padding: 2px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
}

.item-action-btn:hover {
  color: #ef4444;
}

.empty-history-state {
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.75rem;
  padding: 16px 0;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.sidebar-tool-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.connection-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  font-family: 'JetBrains Mono', monospace;
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #eab308;
  flex-shrink: 0;
}

.status-indicator-dot.connected {
  background-color: #10b981;
}

/* --------------------------------------------------------------------------
   TOP NAVBAR (Single-Line Fixed Header)
   -------------------------------------------------------------------------- */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  background: transparent;
  min-width: 0;
}

.top-navbar {
  height: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-sidebar);
  z-index: 20;
  gap: 10px;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 1;
}

.model-dropdown-capsule {
  position: relative;
  min-width: 0;
  flex-shrink: 1;
}

.model-pill-trigger {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 0 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
  min-width: 0;
}

.model-pill-trigger:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-medium);
}

.model-spark-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pill-active-text);
  flex-shrink: 0;
}

.model-pill-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.model-current-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.model-pill-badge {
  font-size: 0.62rem;
  font-weight: 700;
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.chevron-icon {
  color: var(--text-subtle);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.model-dropdown-capsule.open .chevron-icon {
  transform: rotate(180deg);
}

.model-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 320px;
  max-width: calc(100vw - 24px);
  max-height: min(420px, calc(100dvh - 70px));
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
  overflow: hidden;
}

.model-dropdown-capsule.open .model-dropdown-menu {
  display: flex;
}

.dropdown-header {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  padding: 4px 6px;
  flex-shrink: 0;
}

.model-options-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  max-height: 100%;
}

.model-option-card {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  border: 1px solid transparent;
}

.model-option-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
}

.model-option-card.selected {
  background: var(--pill-active-bg);
  border-color: var(--border-active);
}

.model-option-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.model-option-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
}

.model-option-tag {
  font-size: 0.62rem;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.model-option-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.theme-switcher-group {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
  height: 32px;
}

.theme-btn {
  height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: inherit;
  white-space: nowrap;
}

.theme-btn:hover { color: var(--text-main); }
.theme-btn.active { background: rgba(255, 255, 255, 0.1); color: var(--text-main); }

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

.dot-vylex { background: #FBA919; }
.dot-obsidian { background: #e07a5f; }
.dot-carbon { background: #10a37f; }

.session-metric-badge {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 0 8px;
  border-radius: 6px;
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
}

.canvas-toggle-btn {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.canvas-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.canvas-toggle-btn.active {
  background: var(--pill-active-bg);
  border-color: var(--border-active);
  color: var(--pill-active-text);
}

.export-dropdown-wrapper { position: relative; }
.export-menu-popup {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
}

.export-dropdown-wrapper.open .export-menu-popup { display: flex; }

.export-opt-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s ease;
}

.export-opt-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-main); }
.export-opt-btn.danger:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* --------------------------------------------------------------------------
   MESSAGES FEED & HERO WELCOME
   -------------------------------------------------------------------------- */

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 150px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scroll-behavior: auto; /* Prevent smooth-scroll fight and jitter during rapid token streaming */
}

/* Floating Scroll-to-Bottom FAB */
.scroll-bottom-fab {
  position: absolute;
  bottom: 125px;
  right: 28px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 20px;
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(0);
  opacity: 1;
}

.scroll-bottom-fab:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}

.scroll-bottom-fab svg {
  color: var(--accent-primary);
}

.welcome-screen {
  width: 100%;
  max-width: 740px;
  margin: 12px auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hero-tech-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.tech-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

.welcome-heading {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--text-main);
}

.welcome-subtitle {
  font-size: clamp(0.85rem, 1.6vw, 0.95rem);
  color: var(--text-muted);
  max-width: 580px;
  line-height: 1.55;
  margin-bottom: 20px;
}

.welcome-subtitle strong { color: var(--text-secondary); }

/* Minimal Welcome Screen Branding & Suggestions */
.welcome-brand-logo {
  margin-top: 30px;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  filter: drop-shadow(0 0 12px rgba(251, 169, 25, 0.15));
}

[data-theme="obsidian"] .welcome-brand-logo {
  filter: drop-shadow(0 0 12px rgba(200, 100, 70, 0.15));
}

[data-theme="carbon"] .welcome-brand-logo {
  filter: drop-shadow(0 0 12px rgba(16, 163, 127, 0.15));
}

.welcome-suggestions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.suggestion-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.suggestion-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.prompt-card.suggestion-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.prompt-card.suggestion-pill:hover {
  background: var(--pill-active-bg);
  color: var(--accent-primary);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   CHAT MESSAGES THREAD & ANIMATED REASONING
   -------------------------------------------------------------------------- */

.message-row {
  width: 100%;
  max-width: 780px;
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  content-visibility: auto;
  contain-intrinsic-size: 150px;
}

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

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.message-row.user .avatar { background: rgba(255, 255, 255, 0.1); color: #fff; }
.message-row.assistant .avatar { background: var(--accent-solid); color: #fff; }

.message-content-wrapper {
  max-width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
}

.message-row.user .message-content-wrapper { align-items: flex-end; }

.message-bubble {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
  position: relative;
  font-family: var(--font-body);
}

.message-row.user .message-bubble {
  background: var(--message-user-bg);
  border: 1px solid var(--message-user-border);
  color: var(--text-main);
}

.message-row.assistant .message-bubble {
  background: var(--message-ai-bg);
  border: 1px solid var(--message-ai-border);
  color: var(--text-main);
  width: 100%;
}

/* ANIMATED COGITATING THOUGHT STATUS */
.active-thought-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--pill-active-bg);
  border: 1px solid var(--border-active);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--pill-active-text);
  margin-bottom: 8px;
  animation: subtlePulse 2s infinite ease-in-out;
}

@keyframes subtlePulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; border-color: var(--accent-secondary); }
}

.active-thought-word {
  font-weight: 700;
  display: inline-block;
  transition: all 0.25s ease;
}

.active-thought-spark {
  display: inline-flex;
  align-items: center;
  color: var(--accent-secondary);
  animation: spinSlow 4s linear infinite;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Reasoning Process Accordion */
.reasoning-accordion {
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
}

.reasoning-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s ease;
}

.reasoning-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.reasoning-left-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reasoning-content {
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.2);
  font-family: 'JetBrains Mono', monospace;
  white-space: pre-wrap;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--text-subtle);
  padding: 0 2px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
}

.message-actions-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.msg-action-btn {
  background: none;
  border: none;
  color: var(--text-subtle);
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  transition: all 0.12s ease;
  font-family: sans-serif;
}

.msg-action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

/* Markdown & Rich Text Formatting */
.message-bubble h1, .message-bubble h2, .message-bubble h3, .message-bubble h4, .message-bubble h5, .message-bubble h6 {
  font-family: var(--font-display);
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-top: 18px;
  margin-bottom: 8px;
  line-height: 1.35;
}

.message-bubble h1:first-child, .message-bubble h2:first-child, .message-bubble h3:first-child {
  margin-top: 2px;
}

.message-bubble h1 { font-size: 1.35rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 6px; }
.message-bubble h2 { font-size: 1.15rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 4px; }
.message-bubble h3 { font-size: 1.02rem; }
.message-bubble h4 { font-size: 0.92rem; }
.message-bubble h5, .message-bubble h6 { font-size: 0.85rem; }

.message-bubble p {
  margin-bottom: 10px;
  line-height: 1.65;
}

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

.message-bubble ul, .message-bubble ol {
  padding-left: 22px;
  margin-bottom: 12px;
  line-height: 1.6;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble li::marker {
  color: var(--accent-primary);
}

.message-bubble a {
  color: var(--accent-secondary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
  font-weight: 500;
}

.message-bubble a:hover {
  color: var(--accent-primary);
}

.message-bubble strong {
  font-weight: 700;
  color: var(--text-main);
}

.message-bubble em {
  font-style: italic;
  color: var(--text-secondary);
}

.message-bubble hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-medium), transparent);
  margin: 16px 0;
}

/* Blockquotes */
.message-bubble blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent-primary);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 6px 6px 0;
  color: var(--text-secondary);
  font-style: italic;
}

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

/* GitHub Style Callout / Alert Cards */
.callout-card {
  margin: 14px 0;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.88rem;
  line-height: 1.55;
}

.callout-card.callout-note {
  border-left: 3.5px solid #3b82f6;
  background: rgba(59, 130, 246, 0.06);
}

.callout-card.callout-tip {
  border-left: 3.5px solid #10b981;
  background: rgba(16, 185, 129, 0.06);
}

.callout-card.callout-important {
  border-left: 3.5px solid #8b5cf6;
  background: rgba(139, 92, 246, 0.06);
}

.callout-card.callout-warning {
  border-left: 3.5px solid #f59e0b;
  background: rgba(245, 158, 11, 0.07);
}

.callout-card.callout-caution {
  border-left: 3.5px solid #ef4444;
  background: rgba(239, 68, 68, 0.07);
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.callout-card.callout-note .callout-header { color: #60a5fa; }
.callout-card.callout-tip .callout-header { color: #34d399; }
.callout-card.callout-important .callout-header { color: #a78bfa; }
.callout-card.callout-warning .callout-header { color: #fbbf24; }
.callout-card.callout-caution .callout-header { color: #f87171; }

.callout-body {
  color: var(--text-secondary);
}

.callout-body p:last-child {
  margin-bottom: 0;
}

/* Rich Tables */
.table-container {
  width: 100%;
  max-width: 100%;
  margin: 14px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.rich-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-main);
}

.rich-table th {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-weight: 700;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border-medium);
  font-family: var(--font-display);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.rich-table td {
  padding: 8px 13px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.rich-table tbody tr:last-child td {
  border-bottom: none;
}

.rich-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.rich-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.045);
}

.rich-table code {
  font-size: 0.8em;
  padding: 1px 4px;
}

/* Task list checkboxes */
.task-list-item {
  list-style-type: none;
  margin-left: -14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.task-list-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--border-medium);
  background: rgba(0, 0, 0, 0.3);
  cursor: default;
  position: relative;
  top: 2px;
  flex-shrink: 0;
}

.task-list-checkbox:checked {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
}

.task-list-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 3.5px;
  height: 7px;
  border: solid white;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

/* Keyboard keys & highlights */
.message-bubble kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-medium);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  color: var(--text-main);
  white-space: nowrap;
}

.message-bubble mark {
  background: rgba(251, 169, 25, 0.22);
  color: var(--accent-secondary);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Details & Summary */
.message-bubble details {
  margin: 10px 0;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.15);
}

.message-bubble summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
  user-select: none;
}

.message-bubble details[open] summary {
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 4px;
}

/* Streaming Caret Cursor */
.streaming-caret {
  display: inline-block;
  width: 7px;
  height: 14px;
  background-color: var(--accent-primary);
  margin-left: 3px;
  vertical-align: middle;
  border-radius: 1.5px;
  animation: smoothCaretBlink 0.8s infinite cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px var(--accent-primary);
}

@keyframes smoothCaretBlink {
  0%, 100% { opacity: 1; transform: scaleY(1); }
  50% { opacity: 0.15; transform: scaleY(0.85); }
}

/* Code Blocks */
.message-bubble pre {
  margin: 12px 0;
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  max-width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.code-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

.code-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.code-action-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.code-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.code-action-btn.canvas-open-btn {
  background: var(--pill-active-bg);
  border-color: var(--border-active);
  color: var(--pill-active-text);
}

.message-bubble code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  padding: 2px 5px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  color: #38bdf8;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.message-bubble pre code {
  padding: 12px 14px;
  display: block;
  overflow-x: auto;
  background: transparent;
  color: inherit;
  border: none;
  font-size: 0.85rem;
  line-height: 1.55;
  tab-size: 2;
}

/* --------------------------------------------------------------------------
   FLOATING COMPOSER & ANIMATED REASONING INDICATOR
   -------------------------------------------------------------------------- */

.composer-outer-wrapper {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 16px 12px 16px;
  background: linear-gradient(to top, var(--bg-app) 80%, transparent 100%);
  pointer-events: none;
  z-index: 25;
}

.composer-form {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: auto;
  width: 100%;
}

.composer-floating-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.composer-floating-tools::-webkit-scrollbar { display: none; }

.tool-pill-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.tool-pill-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.tool-pill-chip.active-web {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
}

.web-search-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #64748b;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.tool-pill-chip.active-web .web-search-dot {
  background-color: #3b82f6;
  box-shadow: 0 0 6px #3b82f6;
}

.think-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--pill-active-text);
  background: var(--pill-active-bg);
  border: 1px solid var(--border-active);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.pulsing-wave { display: flex; gap: 3px; }

.pulsing-wave span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: pulseDot 1.4s infinite ease-in-out both;
}

.pulsing-wave span:nth-child(1) { animation-delay: -0.32s; }
.pulsing-wave span:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulseDot {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--bg-composer);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: 5px 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.15s ease;
}

.composer-box:focus-within { border-color: var(--border-active); }

.action-circle-btn {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s ease;
}

.action-circle-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.composer-textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.45;
  max-height: 150px;
  resize: none;
  outline: none;
  font-family: var(--font-body);
  padding: 5px 2px;
}

.composer-textarea::placeholder { color: var(--text-subtle); }

.composer-end-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

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

.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.stop-btn {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  background: #ef4444;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
  flex-shrink: 0;
}

.composer-hints {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-subtle);
  padding: 0 2px;
  font-family: 'JetBrains Mono', monospace;
}

.hint-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   RIGHT SPLIT CANVAS / ARTIFACTS PANEL
   -------------------------------------------------------------------------- */

.artifacts-canvas-panel {
  width: 0;
  min-width: 0;
  background-color: var(--bg-canvas);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
  z-index: 25;
}

.artifacts-canvas-panel.open {
  width: 450px;
  min-width: 450px;
}

.canvas-header {
  height: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-sidebar);
}

.canvas-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.canvas-badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.canvas-title-group h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.canvas-type-tag {
  font-size: 0.62rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
}

.canvas-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.canvas-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
  padding: 0 6px;
}

.canvas-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: all 0.12s ease;
}

.canvas-tab:hover { color: var(--text-main); }
.canvas-tab.active { color: var(--text-main); border-bottom-color: var(--accent-primary); }

.canvas-body { flex: 1; overflow: hidden; position: relative; }
.canvas-pane {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: none;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

.canvas-pane.active { display: flex; }

.code-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.canvas-pre {
  flex: 1;
  margin: 0;
  padding: 12px;
  background: var(--bg-code);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

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

#canvasPreviewFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.markdown-preview-body {
  padding: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-main);
}

/* --------------------------------------------------------------------------
   STUDIO PARAMETERS MODAL
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-backdrop.open { display: flex; }

.modal-dialog {
  width: 100%;
  max-width: 540px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
}

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

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-icon-svg {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--pill-active-bg);
  border: 1px solid var(--border-active);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pill-active-text);
  flex-shrink: 0;
}

.modal-title-group h3 { font-size: 0.94rem; font-weight: 700; color: var(--text-main); }
.modal-title-group p { font-size: 0.72rem; color: var(--text-muted); }

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-section { display: flex; flex-direction: column; gap: 5px; }

.settings-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.settings-flex-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-btn {
  background: none;
  border: none;
  color: var(--pill-active-text);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.preset-pills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.preset-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: left;
}

.preset-pill:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--border-medium); }
.preset-pill.active { background: var(--pill-active-bg); border-color: var(--border-active); }

.preset-name { font-size: 0.78rem; font-weight: 700; color: var(--text-main); }
.preset-desc { font-size: 0.65rem; color: var(--text-muted); margin-top: 1px; }

.system-prompt-editor {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 8px;
  color: var(--text-main);
  font-size: 0.8rem;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  font-family: inherit;
}

.custom-range {
  width: 100%;
  accent-color: var(--accent-primary);
  margin-top: 3px;
}

.slider-val-badge {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--pill-active-text);
  font-family: 'JetBrains Mono', monospace;
}

.slider-hints {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-subtle);
}

.modal-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.primary-modal-btn {
  background: var(--accent-solid);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

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

/* --------------------------------------------------------------------------
   AGENT MODE UI
   -------------------------------------------------------------------------- */

.agent-activity-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px;
  gap: 16px;
  background: var(--bg-app);
}

.agent-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Checklist Styles */
.agent-task-checklist {
  flex: 0 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-main);
  padding: 6px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.task-item.placeholder {
  color: var(--text-subtle);
  font-style: italic;
}

.task-item .status-icon {
  margin-top: 2px;
  flex-shrink: 0;
}

.task-item.pending .status-icon { color: var(--text-subtle); }
.task-item.running {
  background: var(--message-user-bg);
  border: 1px solid var(--message-user-border);
}
.task-item.running .status-icon {
  color: var(--accent-primary);
  animation: pulse-glow 2s infinite;
}
.task-item.completed .status-icon { color: #10b981; }

@keyframes pulse-glow {
  0% { filter: drop-shadow(0 0 2px var(--accent-primary)); }
  50% { filter: drop-shadow(0 0 8px var(--accent-primary)); }
  100% { filter: drop-shadow(0 0 2px var(--accent-primary)); }
}

/* Terminal Feed Styles */
.agent-terminal-feed {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.terminal-output {
  flex: 1 1 auto;
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  overflow-y: auto;
  color: #a3a3a3;
  line-height: 1.6;
}

.terminal-line {
  margin-bottom: 4px;
  word-break: break-all;
}
.terminal-line.system { color: #60a5fa; font-weight: 600; }
.terminal-line.command { color: var(--accent-primary); }
.terminal-line.output { color: #d4d4d4; }
.terminal-line.error { color: #f87171; }

/* --------------------------------------------------------------------------
   RESPONSIVE BREAKPOINTS
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .artifacts-canvas-panel.open {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 60vw;
    min-width: 360px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
    z-index: 40;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 280px;
    transform: translateX(-100%);
    margin-left: 0 !important;
    z-index: 45;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.7);
  }

  .theme-switcher-group .theme-label { display: none; }
  .session-metric-badge { display: none; }
  .canvas-btn-text { display: none; }
  .model-current-name { max-width: 120px; }
  .discovery-grid { grid-template-columns: 1fr; }
  .model-banner-card { flex-direction: column; align-items: flex-start; }
  .preset-pills-grid { grid-template-columns: 1fr; }
  .composer-hints { display: none; }
  #deepThinkToggleBtn { display: none; }

  .artifacts-canvas-panel.open {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    min-width: 100%;
    z-index: 50;
  }
}

@media (max-width: 480px) {
  .model-current-name { max-width: 90px; font-size: 0.75rem; }
  .model-pill-badge { display: none; }
  .welcome-heading { font-size: 1.45rem; }
  .prompt-category-bar {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .prompt-category-bar::-webkit-scrollbar { display: none; }
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* --------------------------------------------------------------------------
   RESILIENT ERROR HANDLING & OFFLINE SYSTEM STYLES
   -------------------------------------------------------------------------- */

.offline-banner {
  background: #dc2626;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px;
  z-index: 30;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.error-diagnostic-card {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 10px 0;
  color: var(--text-main);
  font-size: 0.85rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.error-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}

.error-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.88rem;
}

.error-card-badge {
  font-size: 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.error-card-desc {
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-size: 0.82rem;
  line-height: 1.55;
}

.error-card-resolution {
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.error-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.error-action-btn {
  border: none;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.error-action-btn.primary {
  background: var(--accent-solid);
  color: #fff;
}
.error-action-btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.error-action-btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.error-action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.error-action-btn.outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  margin-left: auto;
}
.error-action-btn.outline:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
}

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

.stream-cutoff-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.stream-cutoff-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

