/* ==========================================================================
   ATLAS BY VYLEX TECHNOLOGIES — MOBILE-FIRST DESIGN SYSTEM
   Official Master Brand Hub Palette: Navy #051B38 & Golden Orange #FBA919
   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.15);
  --message-ai-bg: #051B38;
  --message-ai-border: rgba(255, 255, 255, 0.06);

  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --pill-active-bg: rgba(251, 169, 25, 0.14);
  --pill-active-text: #FBA919;
}

[data-theme="obsidian"] {
  --bg-app: #11100e;
  --bg-sidebar: #0c0b0a;
  --bg-card: #1a1815;
  --bg-card-hover: #23201c;
  --bg-composer: #1a1815;
  --bg-canvas: #0c0b0a;
  --bg-code: #070706;

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

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

  --border-subtle: #24211d;
  --border-medium: #332f29;
  --border-active: #e07a5f;

  --message-user-bg: #1e1b17;
  --message-user-border: #2d2923;
  --message-ai-bg: #141310;
  --message-ai-border: #211e1a;

  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --pill-active-bg: rgba(224, 122, 95, 0.14);
  --pill-active-text: #f4a261;
}

[data-theme="carbon"] {
  --bg-app: #0a0a0a;
  --bg-sidebar: #050505;
  --bg-card: #141414;
  --bg-card-hover: #1c1c1c;
  --bg-composer: #141414;
  --bg-canvas: #050505;
  --bg-code: #000000;

  --accent-primary: #10b981;
  --accent-secondary: #34d399;
  --accent-solid: #10b981;
  --accent-hover: #059669;

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

  --border-subtle: #222222;
  --border-medium: #303030;
  --border-active: #10b981;

  --message-user-bg: #171717;
  --message-user-border: #262626;
  --message-ai-bg: #0f0f0f;
  --message-ai-border: #1e1e1e;

  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --pill-active-bg: rgba(16, 185, 129, 0.14);
  --pill-active-text: #34d399;
}

/* --------------------------------------------------------------------------
   GLOBAL RESET & TYPOGRAPHY
   -------------------------------------------------------------------------- */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Global Link Styles */
a {
  color: var(--accent-primary, #fba919);
  text-decoration: underline;
  text-decoration-color: rgba(251, 169, 25, 0.35);
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
  color: #ffc247;
  text-decoration-color: var(--accent-primary, #fba919);
}

/* --------------------------------------------------------------------------
   APP LAYOUT & BACKDROP
   -------------------------------------------------------------------------- */

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

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

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

/* --------------------------------------------------------------------------
   SIDEBAR (MOBILE DRAWER FIRST)
   -------------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 280px;
  max-width: 85vw;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 120;
}

.sidebar.mobile-open {
  transform: translateX(0);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
}

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

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

.brand-mark {
  color: var(--accent-primary);
  display: flex;
  align-items: center;
}

.brand-info h2 {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  display: block;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
}

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

.sidebar-actions {
  padding: 8px 10px 4px;
  flex-shrink: 0;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
}

.new-chat-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
}

.shortcut-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-muted);
}

.history-search-box {
  padding: 6px 10px 8px;
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.history-search-box svg {
  position: absolute;
  left: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.history-search-box input {
  width: 100%;
  padding: 6px 8px 6px 26px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-main);
  font-size: 0.78rem;
  outline: none;
  font-family: inherit;
}

.history-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px;
  -webkit-overflow-scrolling: touch;
}

.history-group {
  margin-bottom: 10px;
}

.history-group-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 4px 6px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 1px;
}

.history-item:hover, .history-item.active {
  background: var(--bg-card);
  color: var(--text-main);
}

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

.history-item-del-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 2px;
}

.empty-history-state {
  text-align: center;
  padding: 20px 10px;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.sidebar-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-tool-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
}

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

/* --------------------------------------------------------------------------
   CENTER CHAT MAIN
   -------------------------------------------------------------------------- */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
  background: var(--bg-app);
  overflow: hidden;
  width: 100%;
}

.offline-banner {
  background: rgba(239, 68, 68, 0.15);
  border-bottom: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 0.75rem;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Top Navbar */
.top-navbar {
  height: 46px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  flex-shrink: 0;
  background: var(--bg-app);
  gap: 6px;
  z-index: 40;
}

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

.nav-left {
  flex: 1;
  min-width: 0;
}

.sidebar-toggle-btn {
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Model Dropdown Capsule */
.model-dropdown-capsule {
  position: relative;
  min-width: 0;
  max-width: clamp(140px, 40vw, 200px);
}

.model-pill-trigger {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
  min-width: 0;
}

.model-spark-icon {
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.model-pill-info {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.model-current-name {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-pill-badge {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 3px;
  border-radius: 3px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chevron-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.model-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 280px;
  max-width: calc(100vw - 24px);
  max-height: min(68vh, 68dvh, 380px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 4px;
  display: none;
  z-index: 200;
}

.model-dropdown-menu::-webkit-scrollbar {
  width: 4px;
}

.model-dropdown-menu::-webkit-scrollbar-track {
  background: transparent;
}

.model-dropdown-menu::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

.model-dropdown-menu.show {
  display: block;
}

.dropdown-header {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 4px 6px;
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 2;
}

.model-options-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-option-item {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.model-option-item:hover, .model-option-item.selected {
  background: var(--pill-active-bg);
}

.model-option-title {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

/* Theme Switcher */
.theme-switcher-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: transparent;
  border: none;
  padding: 3px 6px;
  min-height: 24px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}

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

.theme-btn.active {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.theme-dot {
  width: 7.5px;
  height: 7.5px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}

.theme-dot-vylex {
  background-color: #FBA919;
}

.theme-dot-obsidian {
  background-color: #e07a5f;
}

.theme-dot-carbon {
  background-color: #10b981;
}

.theme-btn.active .theme-dot {
  transform: scale(1.15);
}

/* Mobile-only compact mode: only active theme displays full word */
@media (max-width: 767px) {
  .theme-btn:not(.active) .theme-label {
    display: none;
  }
  
  .theme-btn:not(.active) {
    padding: 3px 6px;
    min-width: 22px;
    justify-content: center;
  }

  .theme-btn.active {
    padding: 3px 8px 3px 6px;
  }

  .theme-btn.active .theme-label {
    display: inline-block;
    font-size: 0.68rem;
    letter-spacing: 0.01em;
  }
}

/* Canvas Toggle Button */
.canvas-toggle-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}

.canvas-btn-text {
  display: none;
}

.session-metric-badge {
  display: none;
}

/* Export Menu */
.export-dropdown-wrapper {
  position: relative;
  flex-shrink: 0;
}

.export-menu-popup {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 200;
}

.export-menu-popup.show {
  display: block;
}

.export-opt-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
}

.export-opt-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.export-opt-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

/* --------------------------------------------------------------------------
   MESSAGES CONTAINER & WELCOME SCREEN (MOBILE-FIRST)
   -------------------------------------------------------------------------- */

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px clamp(180px, 24vh, 260px);
  scroll-padding-bottom: clamp(180px, 24vh, 260px);
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-overflow-scrolling: touch;
}

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

.welcome-brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  margin-bottom: 14px;
}

.welcome-brand-logo svg {
  width: 40px;
  height: 40px;
  display: block;
}

.welcome-header-block {
  margin-bottom: 14px;
}

.welcome-heading {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-main);
  margin-bottom: 4px;
  line-height: 1.35;
  max-width: 520px;
}

.greeting-action {
  color: var(--text-secondary);
  font-weight: 500;
  transition: color var(--transition-fast, 0.15s ease);
}

.greeting-punct {
  margin-right: 2px;
  color: var(--text-muted);
}

.welcome-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
  max-width: 440px;
}

/* 7 Investigation Modes Selector Grid — Mobile Horizontal Scroll */
.mode-selector-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 4px 10px 4px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.mode-selector-grid::-webkit-scrollbar {
  display: none;
}

.mode-card-pill {
  flex: 0 0 120px;
  min-width: 120px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.mode-card-pill:last-child {
  flex: 0 0 120px;
  min-width: 120px;
  grid-column: auto;
  max-width: none;
  margin: 0;
  width: auto;
}

.mode-card-pill:hover, .mode-card-pill.active {
  border-color: var(--accent-primary);
  background: var(--pill-active-bg);
}

.mode-icon {
  color: var(--accent-primary);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
}

.mode-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.mode-desc-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  margin-top: 1px;
}

/* Active Mode Banner */
.active-mode-banner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.active-mode-banner-left {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.active-mode-tag {
  font-weight: 600;
  color: var(--accent-primary);
  margin-right: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

#activeModeDesc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Suggested Inquiries */
.welcome-suggestions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

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

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

.prompt-card.suggestion-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   MESSAGE THREAD & ACCORDIONS
   -------------------------------------------------------------------------- */

.message-row {
  width: 100%;
  max-width: 720px;
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

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

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.message-row.user .avatar {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.message-row.assistant .avatar {
  background: var(--accent-primary);
  color: #fff;
}

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

.message-bubble {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.6;
  overflow-wrap: break-word;
  word-break: break-word;
  box-sizing: border-box;
}

.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%;
}

.bubble-status-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  user-select: none;
  padding: 2px 0;
}

.bubble-status-text {
  transition: opacity 0.15s ease;
  letter-spacing: 0.01em;
}

/* Production-Grade Error Card (Zero AI Gimmicks) */
.atlas-error-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--text-main);
  font-size: 0.82rem;
  margin-top: 6px;
}

.atlas-error-card.warning {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.25);
}

.atlas-error-card.info {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.2);
}

.atlas-error-card.offline {
  background: rgba(249, 115, 22, 0.08);
  border-color: rgba(249, 115, 22, 0.25);
}

.atlas-error-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f87171;
  flex-shrink: 0;
  margin-top: 1px;
}

.atlas-error-card.warning .atlas-error-icon {
  color: #fbbf24;
}

.atlas-error-card.info .atlas-error-icon {
  color: var(--text-muted);
}

.atlas-error-card.offline .atlas-error-icon {
  color: #f97316;
}

.atlas-error-body {
  flex: 1;
  min-width: 0;
}

.atlas-error-title {
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 2px;
  color: var(--text-main);
}

.atlas-error-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Link Styling inside Messages */
.message-bubble a {
  color: #60a5fa;
  text-decoration: underline;
  text-decoration-color: rgba(96, 165, 250, 0.4);
  text-underline-offset: 3px;
  font-weight: 500;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

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

.message-bubble a:visited {
  color: #c084fc;
}

/* Lists - Keep bullets and numbers strictly inside the message bubble border */
.message-bubble ul,
.message-bubble ol {
  margin: 8px 0;
  padding-left: 22px;
  list-style-position: outside;
  box-sizing: border-box;
}

.message-bubble li {
  margin-bottom: 4px;
  padding-left: 2px;
  line-height: 1.55;
  word-break: break-word;
}

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

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

/* Paragraphs & Headings in Message Bubbles */
.message-bubble p {
  margin: 6px 0;
  line-height: 1.55;
}

.message-bubble p:first-child {
  margin-top: 0;
}

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

.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
  margin: 12px 0 6px 0;
  line-height: 1.35;
  color: var(--text-main, #f8fafc);
  font-weight: 700;
}

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

.message-bubble h1 { font-size: 1.18rem; }
.message-bubble h2 { font-size: 1.05rem; }
.message-bubble h3 { font-size: 0.95rem; }
.message-bubble h4 { font-size: 0.88rem; }

.message-bubble blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--accent-primary, #fba919);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0 4px 4px 0;
  color: var(--text-secondary, #cbd5e1);
  font-size: 0.84rem;
}

.message-bubble hr {
  border: none;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  margin: 12px 0;
}

.message-bubble code:not(pre code) {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 0.82rem;
  color: #fca5a5;
  word-break: break-word;
}

.message-bubble img {
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  background: rgba(0, 0, 0, 0.25);
  margin: 8px 0;
  display: block;
  cursor: zoom-in;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.message-bubble img:hover {
  border-color: var(--accent-primary, #fba919);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.reasoning-accordion {
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  overflow: hidden;
}

.reasoning-accordion summary {
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
}

.reasoning-body {
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.15);
}

.streaming-caret {
  display: inline-block;
  width: 2px;
  height: 13px;
  background: var(--accent-primary);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 0.8s infinite;
}

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

.code-block-container {
  margin: 8px 0;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-code);
  max-width: 100%;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.copy-code-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.65rem;
  color: var(--text-secondary);
  cursor: pointer;
}

pre {
  padding: 10px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
}

code {
  font-family: var(--font-mono);
}

:not(pre) > code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.84em;
  color: var(--accent-secondary);
}

/* ─────────────────────────────────────────────────────────────
   MATHEMATICAL & SCIENTIFIC FORMULA STYLING (KATEX & MHCHEM)
   ───────────────────────────────────────────────────────────── */

.math-block-wrapper {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-code, #020b18);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  max-width: 100%;
}

.math-block-wrapper:hover {
  border-color: var(--border-medium);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.math-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.math-block-tag {
  color: var(--accent-primary, #fba919);
  font-weight: 600;
  letter-spacing: 0.05em;
  font-size: 0.65rem;
}

.math-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.math-copy-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-primary);
  color: var(--text-main);
}

.math-block-body {
  padding: 12px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.math-block-body::-webkit-scrollbar {
  height: 4px;
}

.math-block-body::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 2px;
}

.katex-inline-wrapper {
  display: inline-block;
  vertical-align: baseline;
  padding: 0 1px;
}

/* Global KaTeX enhancements */
.katex {
  font-size: 1.06em;
  color: var(--text-main, #f8fafc);
  text-rendering: auto;
}

.katex-display {
  margin: 0 !important;
  padding: 2px 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.katex-display > .katex {
  white-space: normal;
  text-align: center;
}

/* Chemical formula enhancements via KaTeX mhchem */
.katex .mhchem {
  font-family: var(--font-body), sans-serif;
  letter-spacing: 0.02em;
}

/* Table styling in messages */
.table-container {
  margin: 10px 0;
  max-width: 100%;
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.rich-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: left;
}

.rich-table th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-medium);
}

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

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

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

/* --------------------------------------------------------------------------
   INTEGRATED COMPOSER (MOBILE-FIRST SCROLLABLE TOOLBAR)
   -------------------------------------------------------------------------- */

.composer-outer-wrapper {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent 0%, rgba(3, 18, 39, 0.65) 25%, var(--bg-app) 60%);
  pointer-events: none;
  z-index: 30;
}

.composer-form {
  max-width: 720px;
  margin: 0 auto;
  pointer-events: auto;
}

.composer-box {
  background: var(--bg-composer);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
}

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

.composer-textarea {
  width: 100%;
  padding: 10px 10px 4px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: inherit;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.4;
}

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

.composer-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  gap: 4px;
}

.composer-controls-left {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}

.composer-controls-left::-webkit-scrollbar {
  display: none;
}

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

.composer-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 26px;
}

.composer-tool-btn.active-web {
  background: var(--pill-active-bg);
  border-color: var(--accent-primary);
  color: var(--pill-active-text);
}

.composer-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 26px;
  min-height: 26px;
}

.streaming-status-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--accent-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.status-spinner {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--accent-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.composer-engine-hint {
  display: none;
}

.send-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--accent-primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stop-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.composer-hints {
  display: none;
}

.scroll-bottom-fab {
  position: absolute;
  bottom: 70px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 50;
}

/* --------------------------------------------------------------------------
   RIGHT ARTIFACTS / CANVAS PANEL (MOBILE SLIDE-OVER)
   -------------------------------------------------------------------------- */

.artifacts-canvas-panel {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 130;
}

.artifacts-canvas-panel.open {
  transform: translateX(0);
}

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

.canvas-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.canvas-title-group h3 {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.canvas-type-tag {
  font-size: 0.65rem;
  color: var(--text-muted);
}

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

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

.canvas-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
}

.canvas-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 500;
}

.canvas-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.canvas-pane {
  display: none;
  height: 100%;
}

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

.code-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.canvas-pre {
  height: calc(100% - 25px);
  margin: 0;
  background: var(--bg-code);
}

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

.markdown-preview-body {
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   MODALS (MOBILE-FIRST FULL DIALOG)
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 10px;
}

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

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

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

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

.modal-title-group h3 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.modal-title-group p {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.modal-body {
  padding: 12px 14px;
  overflow-y: auto;
}

.settings-section {
  margin-bottom: 12px;
}

.settings-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

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

.text-btn {
  background: transparent;
  border: none;
  color: var(--accent-secondary);
  font-size: 0.7rem;
  cursor: pointer;
}

.preset-pills-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

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

.preset-pill.active {
  border-color: var(--accent-primary);
  background: var(--pill-active-bg);
}

.preset-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
}

.preset-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.system-prompt-editor {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-main);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  outline: none;
  resize: vertical;
}

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

.slider-val-badge {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.slider-hints {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.primary-modal-btn {
  padding: 6px 12px;
  background: var(--accent-primary);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

/* OCR Modal */
.atlas-ocr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 350;
  padding: 14px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.atlas-ocr-overlay.active {
  display: flex;
  opacity: 1;
}

.atlas-ocr-modal {
  width: 100%;
  max-width: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

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

.atlas-ocr-body {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 240px;
}

.atlas-ocr-panel {
  padding: 10px;
  position: relative;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.atlas-ocr-video, .atlas-ocr-preview {
  max-width: 100%;
  max-height: 180px;
  border-radius: 4px;
  object-fit: contain;
}

.atlas-ocr-textarea {
  width: 100%;
  height: 120px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 8px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  resize: none;
  outline: none;
}

.atlas-ocr-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.atlas-ocr-btn {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.atlas-ocr-btn.primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

/* --------------------------------------------------------------------------
   DESKTOP RESPONSIVE BREAKPOINTS (>= 768px & >= 1024px)
   -------------------------------------------------------------------------- */

@media (min-width: 768px) {
  .sidebar {
    position: static;
    transform: none;
    width: 250px;
    max-width: none;
  }

  .sidebar.collapsed {
    width: 0;
    overflow: hidden;
    border-right: none;
  }

  .sidebar-backdrop {
    display: none;
  }

  .top-navbar {
    height: 48px;
    padding: 0 16px;
    gap: 8px;
  }

  .model-dropdown-capsule {
    max-width: 240px;
  }

  .model-current-name {
    font-size: 0.78rem;
  }

  .theme-btn {
    padding: 3px 8px;
    min-width: auto;
  }

  .theme-btn:not(.active) .theme-label {
    display: inline-block;
  }

  .theme-btn.active {
    padding: 3px 8px;
  }

  .canvas-btn-text {
    display: inline;
  }

  .session-metric-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 3px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
  }

  .messages-container {
    padding: 16px 20px clamp(200px, 26vh, 290px);
    scroll-padding-bottom: clamp(200px, 26vh, 290px);
  }

  .welcome-heading {
    font-size: 1.5rem;
  }

  .welcome-subtitle {
    font-size: 0.88rem;
  }

  .welcome-brand-logo svg {
    width: 44px;
    height: 44px;
  }

  .mode-selector-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    overflow-x: visible;
    overflow-y: visible;
    padding: 0;
    scroll-snap-type: none;
    max-width: none;
  }

  .mode-card-pill {
    flex: initial;
    width: auto;
    min-width: 0;
    padding: 10px 12px;
    scroll-snap-align: none;
  }

  .mode-card-pill:last-child {
    grid-column: auto;
    max-width: none;
    margin: 0;
    width: auto;
    flex: initial;
    min-width: 0;
  }

  .mode-desc-hint {
    white-space: normal;
  }

  .composer-outer-wrapper {
    padding: 8px 16px 14px;
  }

  .composer-textarea {
    font-size: 0.9rem;
    padding: 12px 14px 6px;
  }

  .composer-engine-hint {
    display: inline-block;
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
  }

  .composer-hints {
    display: block;
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 6px;
  }

  .artifacts-canvas-panel {
    position: static;
    transform: none;
    width: 0;
    height: 100%;
    border-left: none;
    transition: width 0.2s ease;
  }

  .artifacts-canvas-panel.open {
    width: 460px;
    border-left: 1px solid var(--border-subtle);
  }

  .preset-pills-grid {
    grid-template-columns: 1fr 1fr;
  }

  .atlas-ocr-body {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .mode-selector-grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

/* ─────────────────────────────────────────────────────────────
   SHORT VIEWPORT / LANDSCAPE RESPONSIVENESS (height <= 560px)
   ───────────────────────────────────────────────────────────── */
@media (max-height: 560px) {
  .model-dropdown-menu {
    max-height: calc(100vh - 54px);
    max-height: calc(100dvh - 54px);
  }

  .model-option-item {
    padding: 4px 6px;
  }

  .model-option-title {
    font-size: 0.74rem;
  }

  .model-option-desc {
    font-size: 0.62rem;
  }

  .messages-container {
    padding-bottom: clamp(140px, 28vh, 180px);
  }
}

/* ─────────────────────────────────────────────────────────────
   MESSAGE ACTIONS BAR (COPY, SPEAK, ETC)
   ───────────────────────────────────────────────────────────── */
.message-actions-bar {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding: 0 4px;
}

.action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

/* --------------------------------------------------------------------------
   UNIFIED SETTINGS MODAL
   -------------------------------------------------------------------------- */
.unified-settings-dialog {
  max-width: 800px;
  width: 90vw;
  height: 80vh;
  max-height: 700px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.unified-settings-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Sidebar */
.settings-sidebar-nav {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  flex-shrink: 0;
}

.settings-nav-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 16px;
  padding-left: 8px;
}

.settings-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

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

.settings-nav-btn.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
}

.settings-nav-btn svg {
  color: inherit;
}

/* Main Content Area */
.settings-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  overflow: hidden;
}

.settings-content-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-content-title h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.settings-content-title p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.settings-panes-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.settings-pane {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
}

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

.settings-pane-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.settings-pane .modal-footer {
  padding: 16px 32px;
  background: var(--bg-app);
}

/* Mobile Responsiveness for Settings */
@media (max-width: 768px) {
  .unified-settings-dialog {
    height: 95vh;
    width: 95vw;
  }
  
  .unified-settings-layout {
    flex-direction: column;
  }
  
  .settings-sidebar-nav {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 12px 16px;
    flex-direction: row;
    overflow-x: auto;
  }
  
  .settings-nav-header {
    display: none; /* Hide header on mobile to save space */
  }
  
  .settings-nav-btn {
    width: auto;
    margin-bottom: 0;
    margin-right: 8px;
    white-space: nowrap;
    padding: 8px 12px;
  }
  
  .settings-content-header {
    padding: 16px;
  }
  
  .settings-pane-scrollable {
    padding: 16px;
  }
  
  .settings-pane .modal-footer {
    padding: 12px 16px;
  }
}

/* Slash Commands Popup */
.slash-commands-popup {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.5);
  z-index: 1000;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  padding: 8px;
  backdrop-filter: blur(12px);
}

.slash-command-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
  color: var(--text-main);
  transition: background 0.2s ease;
}

.slash-command-item:hover, .slash-command-item.selected {
  background: var(--bg-card-hover);
}

.slash-command-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
}

.slash-command-info {
  display: flex;
  flex-direction: column;
}

.slash-command-name {
  font-weight: 500;
  font-size: 0.9rem;
}

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