/* ============================================================
   WIDDX — Professional AI Agent Platform
   Design System v3.0 — Integrated
   ============================================================ */

/* ----- FONTS ----- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;450;500;600;700&display=swap');

/* ============================================================
   DESIGN TOKENS — Dark Theme (default)
   ============================================================ */
:root,
[data-theme="dark"] {
  --bg-app: #171717;
  --bg-nav: #1c1c1c;
  --bg-main: #1a1a1a;
  --bg-card: #212121;
  --bg-input: #1e1e1e;
  --bg-canvas: #161616;
  --bg-surface-hover: #252525;
  --bg-surface-active: #2a2a2a;

  --text-primary: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-tertiary: #7a7a7a;
  --text-muted: #555;
  --text-disabled: #404040;

  --accent: #0284f0;
  --accent-hover: #1a93fe;
  --accent-dim: rgba(2,132,240,0.12);
  --accent-glow: rgba(2,132,240,0.20);

  --success: #40c8ae;
  --success-dim: rgba(64,200,174,0.12);
  --warning: #f0a030;
  --warning-dim: rgba(240,160,48,0.12);
  --error: #f04848;
  --error-dim: rgba(240,72,72,0.12);

  --border-main: rgba(255,255,255,0.07);
  --border-light: rgba(255,255,255,0.04);
  --border-strong: rgba(255,255,255,0.10);
  --border-accent: rgba(2,132,240,0.25);

  --fill-hover: rgba(255,255,255,0.05);
  --fill-active: rgba(255,255,255,0.08);
  --fill-selected: rgba(2,132,240,0.10);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 24px rgba(2,132,240,0.12);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', ui-monospace, monospace;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 13.5px;
  --font-size-md: 14px;
  --font-size-lg: 16px;

  --sidebar-width: 260px;
  --sidebar-collapsed-width: 56px;
  --panel-width: 480px;
  --header-height: 52px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 350ms;
}

/* ============================================================
   DESIGN TOKENS — Light Theme
   ============================================================ */
[data-theme="light"] {
  --bg-app: #f5f5f5;
  --bg-nav: #fafafa;
  --bg-main: #ffffff;
  --bg-card: #f0f0f0;
  --bg-input: #ffffff;
  --bg-canvas: #f8f8f8;
  --bg-surface-hover: #f0f0f0;
  --bg-surface-active: #e8e8e8;

  --text-primary: #1a1a1a;
  --text-secondary: #555;
  --text-tertiary: #888;
  --text-muted: #777;
  --text-disabled: #ccc;

  --border-main: rgba(0,0,0,0.08);
  --border-light: rgba(0,0,0,0.04);
  --border-strong: rgba(0,0,0,0.12);
  --border-accent: rgba(2,132,240,0.3);

  --fill-hover: rgba(0,0,0,0.03);
  --fill-active: rgba(0,0,0,0.06);
  --fill-selected: rgba(2,132,240,0.08);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
  --shadow-glow: 0 0 24px rgba(2,132,240,0.08);
}

/* ============================================================
   STATUS DOT TYPES
   ============================================================ */
.status-dot { width: 7px; height: 7px; border-radius: var(--radius-full); flex-shrink: 0; }
.status-dot.running { background: var(--accent); animation: pulseDot 1.5s ease-in-out infinite; box-shadow: 0 0 6px var(--accent); }
.status-dot.success { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.warning { background: var(--warning); animation: pulseDot 2s ease-in-out infinite; box-shadow: 0 0 6px var(--warning); }
.status-dot.idle { background: var(--text-muted); }

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-app);
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  line-height: 1.5;
  transition: background var(--duration-slow) var(--ease-out),
              color var(--duration-slow) var(--ease-out);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

::selection { background: var(--accent-dim); color: var(--text-primary); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-nav);
  border-right: 1px solid var(--border-main);
  display: flex;
  flex-direction: column;
  transition: width var(--duration-slow) var(--ease-out),
              min-width var(--duration-slow) var(--ease-out);
  position: relative;
  z-index: 10;
  user-select: none;
  flex-shrink: 0;
}
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}
.sidebar-backdrop {
  display: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  flex-shrink: 0;
}
.brand-logo {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(2,132,240,0.25);
}
.brand-text { font-size: 15px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.3px; }
.brand-badge {
  font-size: 10px; font-weight: 500;
  padding: 1px 7px; border-radius: var(--radius-full);
  background: var(--accent-dim); color: var(--accent);
  letter-spacing: 0.3px; text-transform: uppercase;
}

.sidebar-new-task {
  margin: 4px 16px 12px;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius-lg);
  background: var(--fill-active); color: var(--text-primary);
  font-size: var(--font-size-md); font-weight: 500;
  cursor: pointer; border: 1px solid var(--border-light);
  transition: all var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}
.sidebar-new-task:hover {
  background: var(--fill-hover);
  border-color: var(--border-main);
  box-shadow: var(--shadow-sm);
}
.sidebar-new-task i { font-size: 16px; opacity: 0.7; flex-shrink: 0; }

.sidebar-search-wrap {
  margin: 0 16px 8px; position: relative; flex-shrink: 0;
}
.sidebar-search-wrap i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px;
  color: var(--text-tertiary); pointer-events: none;
}
.sidebar-search {
  width: 100%; height: 34px; border-radius: var(--radius-md);
  background: var(--bg-input); border: 1px solid var(--border-light);
  padding: 0 12px 0 34px; font-size: var(--font-size-sm);
  color: var(--text-primary); font-family: var(--font-sans);
  transition: all var(--duration-fast) var(--ease-out); outline: none;
}
.sidebar-search::placeholder { color: var(--text-muted); }
.sidebar-search:focus {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 8px; }

.nav-section-label {
  font-size: var(--font-size-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-tertiary); padding: 16px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: var(--font-size-md);
  font-weight: 500; cursor: pointer;
  -webkit-font-smoothing: antialiased;
  transition: all var(--duration-fast) var(--ease-out);
  margin-bottom: 1px; position: relative;
}
.nav-item:hover { background: var(--fill-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--fill-selected); color: var(--accent); font-weight: 500;
}
.nav-item i { font-size: 17px; flex-shrink: 0; opacity: 0.65; }
.nav-item.active i { opacity: 1; }
.nav-item .nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: var(--radius-full);
  background: var(--accent-dim); color: var(--accent);
}

.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-md);
  cursor: pointer; transition: all var(--duration-fast) var(--ease-out);
  margin-bottom: 1px; position: relative;
}
.chat-item:hover { background: var(--fill-hover); }
.chat-item.active { background: var(--fill-active); }
.chat-item-content { min-width: 0; flex: 1; }
.chat-item-title {
  font-size: var(--font-size-sm); color: var(--text-primary);
  font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item-meta { font-size: var(--font-size-xs); color: var(--text-tertiary); margin-top: 1px; }
.chat-item-actions { display: none; gap: 2px; flex-shrink: 0; }
.chat-item:hover .chat-item-actions { display: flex; }
.chat-item-actions button {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text-tertiary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
}
.chat-item-actions button:hover { background: var(--fill-active); color: var(--text-primary); }

.sidebar-footer {
  padding: 10px 16px; border-top: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: var(--font-size-sm); font-weight: 500; color: var(--text-primary); }
.user-plan  { font-size: var(--font-size-xs); color: var(--text-tertiary); }
.user-actions { display: flex; gap: 2px; flex-shrink: 0; }
.user-actions button {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text-tertiary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
}
.user-actions button:hover { background: var(--fill-hover); color: var(--text-primary); }
.user-actions button i { font-size: 16px; }

/* ═══════════════════════════════════════════════════════════
   FLOATING SIDEBAR TOGGLE
   ═══════════════════════════════════════════════════════════ */

.sidebar-floating-toggle {
  position: fixed;
  top: 56px;
  left: calc(var(--sidebar-width) - 13px);
  z-index: 20;
  width: 26px; height: 26px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-main);
  background: var(--bg-nav);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
.sidebar-floating-toggle:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
}
.sidebar-floating-toggle i {
  font-size: 14px;
  transition: transform var(--duration-normal) var(--ease-out);
}
.sidebar.collapsed ~ .sidebar-floating-toggle,
body:has(.sidebar.collapsed) .sidebar-floating-toggle {
  left: calc(var(--sidebar-collapsed-width) - 13px);
}
.sidebar.collapsed ~ .sidebar-floating-toggle i,
body:has(.sidebar.collapsed) .sidebar-floating-toggle i {
  transform: rotate(180deg);
}
@media (max-width: 820px) {
  .sidebar-floating-toggle { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   COLLAPSED SIDEBAR — Icon Rail Mode
   ═══════════════════════════════════════════════════════════ */
.sidebar.collapsed {
  overflow-y: auto;
  overflow-x: visible;
}
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 16px 8px; gap: 0; }
.sidebar.collapsed .brand-logo { width: 28px; height: 28px; font-size: 14px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .brand-badge { display: none; }

.sidebar.collapsed .sidebar-new-task {
  justify-content: center;
  margin: 6px 8px 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  font-size: 0;
  gap: 0;
}
.sidebar.collapsed .sidebar-new-task i { font-size: 18px; opacity: 0.8; margin: 0; }

.sidebar.collapsed .sidebar-search-wrap { display: none; }

.sidebar.collapsed .sidebar-nav { padding: 4px 6px; }
.sidebar.collapsed .nav-section-label { display: none; }

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
  font-size: 0;
  margin-bottom: 3px;
  border-radius: var(--radius-md);
  width: 44px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}
.sidebar.collapsed .nav-item i { font-size: 20px; flex-shrink: 0; }
.sidebar.collapsed .nav-item .nav-badge { display: none; }

.sidebar.collapsed .chat-item {
  display: none;
}

.sidebar.collapsed .sidebar-footer {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}
.sidebar.collapsed .user-avatar { width: 28px; height: 28px; font-size: 11px; }
.sidebar.collapsed .user-meta,
.sidebar.collapsed .user-actions { display: none; }

/* Tooltips on hover for collapsed items */
.sidebar.collapsed .nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
  z-index: 100;
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  height: 100vh; overflow: hidden; background: var(--bg-main);
  transition: background var(--duration-slow) var(--ease-out);
}
.main-wrapper {
  display: flex; flex: 1; min-width: 0;
  height: 100vh; overflow: hidden;
}
.chat-container {
  flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden;
  position: relative;
}

/* ============================================================
   CHAT HEADER
   ============================================================ */
.chat-header {
  display: flex; align-items: center; height: var(--header-height);
  padding: 0 20px; border-bottom: 1px solid var(--border-main);
  background: var(--bg-nav); flex-shrink: 0; gap: 10px;
  transition: background var(--duration-slow) var(--ease-out);
}
.model-selector {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--radius-md); cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  font-weight: 500; font-size: var(--font-size-md); color: var(--text-primary);
}
.model-selector:hover { background: var(--fill-hover); }
.model-chevron {
  font-size: 12px; color: var(--text-tertiary);
  transition: transform var(--duration-normal) var(--ease-out);
}
.model-dropdown {
  position: absolute;
  top: calc(var(--header-height) - 4px);
  left: 100px;
  width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  overflow: hidden;
  animation: fadeSlideIn 0.15s var(--ease-out);
}
.model-dropdown-header {
  padding: 10px 14px;
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.model-dropdown-list {
  max-height: 240px;
  overflow-y: auto;
}
.model-dropdown-item {
  padding: 8px 14px;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  transition: background var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  gap: 8px;
}
.model-dropdown-item:hover { background: var(--fill-hover); }
.model-dropdown-item.active { color: var(--accent); font-weight: 500; }
.model-dropdown-item.active::before {
  content: '✓';
  font-size: 12px;
  color: var(--accent);
}
.model-dropdown-footer {
  padding: 8px 14px;
  cursor: pointer;
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-light);
  text-align: center;
  transition: background var(--duration-fast) var(--ease-out);
}
.model-dropdown-footer:hover { background: var(--fill-hover); color: var(--text-primary); }
.chat-header-spacer { flex: 1; }

/* ── Skeleton loading ────────────────────────────────────────── */
@keyframes skeletonPulse {
  0% { opacity: 0.4; }
  50% { opacity: 0.7; }
  100% { opacity: 0.4; }
}
.skeleton {
  background: var(--fill-hover);
  border-radius: var(--radius-sm);
  animation: skeletonPulse 1.5s ease-in-out infinite;
  display: inline-block;
  min-width: 60px;
  min-height: 1em;
  vertical-align: middle;
}

/* ── Slash commands popup ──────────────────────────────────────── */
.slash-popup {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 8px;
  right: 8px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 50;
  display: none;
  animation: fadeSlideIn 0.12s var(--ease-out);
}
.slash-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--duration-fast) var(--ease-out);
}
.slash-item:hover,
.slash-item.active { background: var(--fill-hover); }
.slash-item i { width: 18px; text-align: center; color: var(--text-tertiary); font-size: 14px; }
.slash-cmd { font-weight: 500; color: var(--text-primary); font-size: var(--font-size-sm); }
.slash-desc { font-size: var(--font-size-xs); color: var(--text-muted); }

/* ── Chat header actions ─────────────────────────────────────── */
.chat-header-actions { display: flex; align-items: center; gap: 4px; }
.header-btn {
  width: 34px; height: 34px; border-radius: var(--radius-md);
  border: none; background: transparent; color: var(--text-tertiary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) var(--ease-out); position: relative;
}
.header-btn:hover {
  background: var(--fill-hover); color: var(--text-primary);
}
.header-btn i { font-size: 17px; }
.header-btn.starred { color: #f0a030; }
.header-btn.starred:hover { color: #f5b840; }

.theme-btn {
  width: 34px; height: 34px; border-radius: var(--radius-md);
  border: none; background: transparent; color: var(--text-tertiary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) var(--ease-out); position: relative;
}
.theme-btn:hover { background: var(--fill-hover); color: var(--text-primary); }
.theme-btn .icon-sun,
.theme-btn .icon-moon {
  width: 17px; height: 17px; position: absolute;
  transition: all var(--duration-normal) var(--ease-out);
}
[data-theme="dark"] .icon-sun { opacity: 0; transform: scale(0.5) rotate(-90deg); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: scale(1) rotate(0deg); }
[data-theme="light"] .icon-sun { opacity: 1; transform: scale(1) rotate(0deg); }
[data-theme="light"] .icon-moon { opacity: 0; transform: scale(0.5) rotate(90deg); }

/* ── Onboarding ──────────────────────────────────────────────── */
.onboarding {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
  gap: 16px;
}
.onboarding-logo {
  width: 64px; height: 64px;
  background: var(--accent);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #fff;
  margin-bottom: 8px;
}
.onboarding h1 { font-size: 24px; font-weight: 600; color: var(--text-primary); }
.onboarding p { font-size: var(--font-size-md); color: var(--text-secondary); max-width: 400px; }
.onboarding-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: center; margin-top: 12px;
}
.onboarding-card {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  min-width: 140px;
}
.onboarding-card:hover {
  background: var(--fill-hover);
  border-color: var(--border-accent);
  color: var(--text-primary);
}
.onboarding-card i { font-size: 18px; color: var(--accent); flex-shrink: 0; }
.onboarding-tips {
  display: flex; gap: 20px; margin-top: 12px;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
.onboarding-tips kbd {
  background: var(--fill-hover);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid var(--border-main);
}

/* ── Gateway setup ──────────────────────────────────────────── */
.gw-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 20px 24px; min-width: 140px;
  background: var(--bg-card); border: 2px solid var(--border-main);
  border-radius: var(--radius-lg); cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.gw-option:hover { border-color: var(--border-accent); background: var(--fill-hover); }
.gw-option.selected { border-color: var(--accent); background: var(--fill-selected); }
.gw-option span { font-weight: 500; font-size: var(--font-size-md); color: var(--text-primary); }
.gw-option small { font-size: var(--font-size-xs); color: var(--text-muted); text-align: center; }

.gw-steps { display: flex; flex-direction: column; gap: 12px; }
.gw-step { display: flex; gap: 12px; align-items: flex-start; }
.gw-step-num {
  width: 28px; height: 28px; border-radius: var(--radius-full);
  background: var(--accent); color: #fff; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: var(--font-size-sm);
}
.gw-step code {
  background: var(--fill-hover); padding: 1px 6px;
  border-radius: var(--radius-xs); font-family: var(--font-mono);
}

.gateway-status-dot {
  width: 10px; height: 10px; border-radius: var(--radius-full);
  flex-shrink: 0;
}
.gateway-status-dot.connected { background: var(--success); }
.gateway-status-dot.disconnected { background: var(--text-muted); }
.gateway-status-label {
  font-size: var(--font-size-sm); font-weight: 500;
}
.gw-disconnect-btn {
  padding: 6px 16px; border-radius: var(--radius-sm);
  background: var(--error-dim); color: var(--error);
  border: 1px solid rgba(240,72,72,0.2);
  cursor: pointer; font-size: var(--font-size-xs);
  transition: all var(--duration-fast) var(--ease-out);
}
.gw-disconnect-btn:hover { background: var(--error); color: #fff; }

/* ── Settings cards ─────────────────────────────────────────── */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 8px;
}
.settings-card-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-select, .settings-input {
  width: 100%; height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-main);
  color: var(--text-primary);
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
}
.settings-select { cursor: pointer; }
.settings-select:focus, .settings-input:focus {
  border-color: var(--border-accent);
}
.btn-primary {
  height: 40px; padding: 0 24px;
  border-radius: var(--radius-md);
  background: var(--accent); color: #fff;
  border: none; font-size: 14px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: all var(--duration-fast) var(--ease-out);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════
   MESSAGES AREA
   ============================================================ */
.messages-area { flex: 1; overflow-y: auto; padding: 16px 0; scroll-behavior: smooth; }

.message-wrapper {
  padding: 6px 20px;
  margin-bottom: 2px;
  transition: background var(--duration-fast) var(--ease-out);
}
.message-wrapper.ai:hover,
.message-wrapper.assistant:hover {
  background: var(--fill-hover);
}
.message-wrapper.user { display: flex; justify-content: flex-end; }
.user-bubble {
  background: var(--accent); color: #fff; padding: 10px 16px;
  border-radius: 18px 18px 4px 18px; max-width: 80%;
  margin-left: auto; font-size: var(--font-size-base);
  line-height: 1.6; word-wrap: break-word;
  animation: msgIn 0.3s var(--ease-out);
  box-shadow: 0 2px 8px rgba(2,132,240,0.2);
}

.message-wrapper.ai,
.message-wrapper.assistant { display: flex; flex-direction: column; gap: 8px; }
.ai-avatar {
  width: 30px; height: 30px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, #0284f0, #7c3aed);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 600; margin-top: 4px;
  box-shadow: 0 0 12px rgba(2,132,240,0.15);
  transition: box-shadow var(--duration-fast) var(--ease-out);
}
.message-wrapper.ai:hover .ai-avatar,
.message-wrapper.assistant:hover .ai-avatar {
  box-shadow: 0 0 20px rgba(2,132,240,0.3);
}
.ai-content {
  min-width: 0; flex: 1; position: relative;
  animation: msgIn 0.35s var(--ease-out);
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.ai-content:hover {
  border-color: var(--border-strong);
}

.agent-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.agent-name { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); }
.agent-tag {
  font-size: 10px; font-weight: 500; padding: 1px 8px;
  border-radius: var(--radius-full); background: var(--accent-dim);
  color: var(--accent); text-transform: uppercase; letter-spacing: 0.3px;
}
.agent-time { font-size: var(--font-size-xs); color: var(--text-muted); margin-left: auto; }

.ai-text {
  color: var(--text-primary); font-size: var(--font-size-base);
  line-height: 1.7; margin-bottom: 10px;
  word-wrap: break-word; overflow-wrap: break-word;
  max-width: 72ch;
}

/* Step Card */
.step-card {
  margin: 8px 0; border-radius: var(--radius-lg);
  border: 1px solid var(--border-main); background: var(--bg-card);
  overflow: hidden;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-slow) var(--ease-out);
}
.step-card:hover { border-color: var(--border-strong); }
.step-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; cursor: pointer; user-select: none;
  transition: background var(--duration-fast) var(--ease-out);
}
.step-head:hover { background: var(--fill-hover); }
.step-check {
  width: 20px; height: 20px; border-radius: var(--radius-full);
  border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration-normal) var(--ease-out);
}
.step-check.done { background: var(--success); border-color: var(--success); color: #fff; }
.step-check.done i { font-size: 11px; }
.step-icon { font-size: 14px; flex-shrink: 0; }
.step-title { font-size: var(--font-size-sm); font-weight: 500; color: var(--text-primary); flex: 1; }
.step-time { font-size: var(--font-size-xs); color: var(--text-muted); flex-shrink: 0; }
.step-chevron {
  font-size: 12px; color: var(--text-tertiary); flex-shrink: 0;
  transition: transform var(--duration-normal) var(--ease-out);
}
.step-head.open .step-chevron { transform: rotate(180deg); }

.step-body {
  max-height: 0; overflow: hidden;
  transition: max-height var(--duration-slow) var(--ease-out),
              opacity var(--duration-normal) var(--ease-out);
  opacity: 0;
}
.step-body.open { max-height: 2000px; opacity: 1; }
.step-body-inner { padding: 0 14px 12px; border-top: 1px solid var(--border-light); }

.step-description {
  font-size: var(--font-size-sm); color: var(--text-tertiary);
  margin: 10px 0 8px; line-height: 1.55;
}
.step-body-inner .tool-card {
  background: var(--bg-canvas); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); padding: 10px 14px; margin: 8px 0;
  font-family: var(--font-mono); font-size: var(--font-size-sm);
  color: var(--text-secondary); display: flex; align-items: center; gap: 10px;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.step-body-inner .tool-card:hover { border-color: var(--border-strong); }

/* ═══════════════════════════════════════════════════════════════════
   v4.0 — Professional Message Rendering
   ═══════════════════════════════════════════════════════════════════ */

/* ── AI Message Wrapper ─────────────────────────────────────── */
.message-wrapper.assistant {
  padding: 0; background: transparent; border: none;
  margin-bottom: 24px;
}

/* ── AI Header (avatar + name + model + time) ────────────────── */
.ai-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  padding: 0 4px;
}
.ai-identity { display: flex; flex-direction: column; gap: 1px; }
.ai-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.ai-model {
  font-size: 10px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--accent);
  background: var(--accent-dim); padding: 1px 8px; border-radius: var(--radius-full);
  display: inline-block; width: fit-content; margin-top: 2px;
}
.ai-time { font-size: 11px; color: var(--text-muted); margin-left: auto; }

/* ── AI Body (thinking + tools + response blocks) ────────────── */
.ai-body {
  background: var(--bg-card); border: 1px solid var(--border-main);
  border-radius: var(--radius-lg); padding: 16px 18px;
  animation: msgIn 0.35s var(--ease-out);
  transition: border-color var(--duration-fast);
}
.ai-body:hover { border-color: var(--border-strong); }

/* ── AI Footer (action buttons) ──────────────────────────────── */
.ai-footer {
  display: flex; gap: 4px; padding: 6px 4px 0;
  opacity: 0; transition: opacity var(--duration-fast);
}
.message-wrapper.assistant:hover .ai-footer { opacity: 1; }
.ai-btn {
  background: none; border: 1px solid transparent; border-radius: var(--radius-md);
  color: var(--text-muted); padding: 4px 8px; cursor: pointer;
  font-size: 12px; transition: all var(--duration-fast);
}
.ai-btn:hover { color: var(--text-primary); background: var(--fill-hover); border-color: var(--border-light); }
.ai-btn.active { color: var(--accent); }

/* ── Thinking Strip (compact) ─────────────────────────────────── */
.think-strip { margin-bottom: 8px; }
.think-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-tertiary); padding: 2px 0;
  transition: color var(--duration-fast);
}
.think-toggle:hover { color: var(--text-secondary); }
.think-chevron {
  font-size: 9px; transition: transform var(--duration-normal);
}
.think-label { font-weight: 400; }
.think-body { display: none; }
.think-body.open { display: block; }
.think-content {
  margin-top: 6px; padding: 10px 12px;
  background: var(--bg-canvas); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); max-height: 400px; overflow-y: auto;
}
.think-content p {
  margin: 0; font-size: 12px; line-height: 1.7;
  color: var(--text-muted); font-style: italic;
}

/* ── Tool Pills (compact) ────────────────────────────────────── */
.tool-pills { margin-bottom: 8px; }
.tool-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px 3px 8px; margin: 2px 4px 2px 0;
  border-radius: 999px; font-size: 11px; line-height: 1.4;
  border: 1px solid var(--border-light);
  background: var(--bg-canvas);
  transition: all var(--duration-fast);
}
.tool-pill.running {
  border-color: var(--accent-dim); background: var(--accent-dim);
  color: var(--accent);
}
.tool-pill.success { border-color: var(--success-dim, rgba(34,197,94,0.15)); color: var(--success); }
.tool-pill.failed  { border-color: var(--error-dim, rgba(239,68,68,0.15)); color: var(--error); }
.tool-pill-status { display: inline-flex; align-items: center; width: 12px; justify-content: center; }
.tp-spinner {
  display: inline-block; width: 10px; height: 10px;
  border: 1.5px solid var(--accent); border-top-color: transparent;
  border-radius: 50%; animation: tp-spin 0.6s linear infinite;
}
@keyframes tp-spin { to { transform: rotate(360deg); } }
.tool-pill-name { font-weight: 500; }
.tool-pill-args {
  font-weight: 400; opacity: 0.65; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Response Block ──────────────────────────────────────────── */
.response-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-light); }
.response-content {
  color: var(--text-primary); font-size: var(--font-size-base);
  line-height: 1.7; word-wrap: break-word; overflow-wrap: break-word;
}
.response-content p { margin: 0 0 10px; }
.response-content pre {
  background: var(--bg-canvas); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); padding: 12px 16px;
  overflow-x: auto; font-family: var(--font-mono); font-size: 12px;
  line-height: 1.55; margin: 10px 0;
}
.response-content code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--fill-hover); padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.response-content pre code {
  background: none; padding: 0; border-radius: 0;
}

/* ── System Message ──────────────────────────────────────────── */
.system-msg {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; margin: 6px 0;
  background: var(--fill-hover); border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-muted);
  border-left: 3px solid var(--border-strong);
}
.system-msg i { color: var(--accent); font-size: 12px; }

/* ── User Bubble (polish) ────────────────────────────────────── */
.step-body-inner .tool-card-icon {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--fill-active); display: flex;
  align-items: center; justify-content: center; flex-shrink: 0; font-size: 13px;
}
.step-body-inner .tool-card-info { min-width: 0; flex: 1; }
.step-body-inner .tool-card-name { font-weight: 500; color: var(--text-primary); font-size: var(--font-size-xs); }
.step-body-inner .tool-card-path {
  color: var(--text-tertiary); font-size: var(--font-size-xs);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.summary-list { margin: 8px 0; padding: 0; list-style: none; }
.summary-list li {
  padding: 5px 0; font-size: var(--font-size-sm);
  color: var(--text-secondary); display: flex; align-items: flex-start;
  gap: 8px; line-height: 1.5;
}
.summary-list li::before {
  content: ''; width: 5px; height: 5px;
  border-radius: var(--radius-full); background: var(--accent);
  flex-shrink: 0; margin-top: 7px;
}

.credit-banner {
  margin: 10px 0; padding: 12px 16px; border-radius: var(--radius-lg);
  background: var(--warning-dim); border: 1px solid rgba(240,160,48,0.2);
  display: flex; align-items: center; gap: 12px;
}
.credit-banner-text { flex: 1; font-size: var(--font-size-sm); color: var(--warning); }
.credit-banner-text strong { font-weight: 600; }
.btn-upgrade {
  padding: 6px 16px; border-radius: var(--radius-full);
  background: var(--warning); color: #000; border: none;
  font-weight: 600; font-size: var(--font-size-sm); cursor: pointer;
  flex-shrink: 0; transition: all var(--duration-fast) var(--ease-out);
}
.btn-upgrade:hover { filter: brightness(1.1); transform: translateY(-1px); }

.msg-time { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 4px; padding-left: 42px; }

/* ============================================================
   TYPING INDICATOR — compact, aligned with avatar column
   ============================================================ */
.typing-indicator { display: none; align-items: center; gap: 10px; padding: 8px 20px 8px 52px; }
.typing-indicator.show { display: flex; }
.typing-dots { display: flex; gap: 4px; align-items: center; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: var(--radius-full);
  background: var(--text-tertiary);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }
.typing-label {
  font-size: var(--font-size-sm); color: var(--text-tertiary); font-style: italic;
}

/* ============================================================
   ACTIVITY BAR
   ============================================================ */
.activity-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 40px; padding: 0 20px; border-top: 1px solid var(--border-light);
  background: var(--bg-nav); flex-shrink: 0; font-size: var(--font-size-xs);
  transition: background var(--duration-slow) var(--ease-out);
}
.activity-status { display: flex; align-items: center; gap: 8px; min-width: 0; }
.activity-dot {
  width: 7px; height: 7px; border-radius: var(--radius-full);
  background: var(--success); flex-shrink: 0;
  animation: pulseDot 2s ease-in-out infinite;
  box-shadow: 0 0 6px var(--success);
}
.activity-label { color: var(--text-tertiary); white-space: nowrap; }
.activity-tool { color: var(--text-secondary); font-weight: 500; white-space: nowrap; }
.activity-divider {
  width: 1px; height: 14px; background: var(--border-strong);
  margin: 0 4px; flex-shrink: 0;
}
.activity-file {
  color: var(--text-tertiary); font-family: var(--font-mono);
  font-size: var(--font-size-xs); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.activity-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.activity-btn {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text-tertiary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) var(--ease-out); position: relative;
}
.activity-btn:hover { background: var(--fill-hover); color: var(--text-primary); }
.activity-btn i { font-size: 16px; }
.activity-btn.active { color: var(--accent); }

/* ============================================================
   INPUT AREA
   ============================================================ */
.input-textarea {
  width: 100%; border: none; resize: none; background: transparent;
  color: var(--text-primary); font-family: var(--font-sans);
  font-size: var(--font-size-base); line-height: 1.55;
  padding: 4px; min-height: 28px; max-height: 200px; outline: none; overflow-y: auto;
}
.input-textarea::placeholder { color: var(--text-muted); }
.input-toolbar { display: flex; align-items: center; justify-content: space-between; }
.input-toolbar-left { display: flex; gap: 2px; }
.input-toolbar-btn {
  width: 34px; height: 34px; border-radius: var(--radius-md);
  border: none; background: transparent; color: var(--text-tertiary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
}
.input-toolbar-btn:hover { background: var(--fill-hover); color: var(--text-primary); }
.input-toolbar-btn i { font-size: 17px; }
.send-btn {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  border: none; background: var(--accent); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) var(--ease-out); flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-hover); transform: scale(1.05); box-shadow: var(--shadow-glow); }
.send-btn:active { transform: scale(0.95); }
.send-btn i { font-size: 16px; }

.input-hint {
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  padding: 4px 0 0;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.disclaimer {
  text-align: center; font-size: var(--font-size-xs);
  color: var(--text-muted); padding: 4px 0 0;
}

/* Placeholder fades on focus */
.input-textarea::placeholder {
  color: var(--text-muted);
  transition: opacity 0.25s var(--ease-out);
}
.input-textarea:focus::placeholder { opacity: 0.4; }

/* ============================================================
   RIGHT PANEL — Computer View
   ============================================================ */
.right-panel {
  width: var(--panel-width); min-width: 0;
  border-left: 1px solid var(--border-main);
  background: var(--bg-nav); display: flex; flex-direction: column;
  overflow: hidden;
  transition: all var(--duration-slow) var(--ease-in-out);
}
.right-panel.collapsed { width: 0; border-left: none; opacity: 0; }

.right-panel-header {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 16px;
  border-bottom: 1px solid var(--border-main); flex-shrink: 0;
}
.right-panel-indicator {
  width: 8px; height: 8px; border-radius: var(--radius-full);
  background: var(--success); flex-shrink: 0;
  animation: pulseDot 2s ease-in-out infinite;
}
.right-panel-title { font-size: var(--font-size-md); font-weight: 500; color: var(--text-primary); }
.right-panel-subtitle { font-size: var(--font-size-xs); color: var(--success); font-weight: 500; }
.right-panel-header-spacer { flex: 1; }
.right-panel-close {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--text-tertiary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
}
.right-panel-close:hover { background: var(--fill-hover); color: var(--text-primary); }
.right-panel-close i { font-size: 16px; }

.right-panel-tabs {
  display: flex; border-bottom: 1px solid var(--border-main);
  flex-shrink: 0; padding: 0 12px; gap: 4px; overflow-x: auto;
}
.right-panel-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; font-size: var(--font-size-sm);
  color: var(--text-tertiary); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--duration-fast) var(--ease-out); white-space: nowrap;
}
.right-panel-tab:hover { color: var(--text-secondary); }
.right-panel-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.right-panel-tab i { font-size: 15px; }

.right-panel-body {
  flex: 1; overflow-y: auto; background: var(--bg-canvas);
  transition: background var(--duration-slow) var(--ease-out);
}

.panel-desktop-view {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; gap: 16px; color: var(--text-tertiary);
}
.panel-desktop-view i { font-size: 64px; opacity: 0.3; }
.panel-desktop-text {
  font-size: var(--font-size-sm); color: var(--text-muted);
  text-align: center; line-height: 1.6;
}

.code-area { padding: 12px 0; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.75; }
.code-line {
  display: flex; padding: 0 16px; min-height: 22px;
  transition: background var(--duration-fast) var(--ease-out);
}
.code-line:hover { background: var(--fill-hover); }
.code-line.add { background: var(--success-dim); }
.code-line.remove { background: var(--error-dim); }
.ln {
  width: 44px; flex-shrink: 0; color: var(--text-muted);
  text-align: right; padding-right: 16px; user-select: none; font-size: 11.5px;
}
.code-text { flex: 1; white-space: pre; color: var(--text-secondary); overflow-x: auto; }
.kw { color: #c792ea; }
.str { color: #9ed87e; }
.com { color: #5f7f8f; font-style: italic; }
.fn { color: #82aaff; }
.num { color: #f78c6c; }
.op { color: #89ddff; }
.type { color: #ffcb6b; }

.right-panel-footer {
  padding: 10px 16px; border-top: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px;
  font-size: var(--font-size-xs); color: var(--text-tertiary); flex-shrink: 0;
}
.panel-footer-dot {
  width: 6px; height: 6px; border-radius: var(--radius-full);
  background: var(--success); flex-shrink: 0;
}
.panel-footer-spacer { flex: 1; }
.progress-wrap { display: flex; align-items: center; gap: 8px; flex: 1; }
.progress-track {
  flex: 1; height: 3px; background: var(--fill-active);
  border-radius: var(--radius-full); overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: var(--radius-full);
  transition: width 0.5s var(--ease-out);
}
.progress-count { font-size: var(--font-size-xs); color: var(--text-tertiary); flex-shrink: 0; }

/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-8px); opacity: 1; }
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.8); }
}
/* ============================================================
   MESSAGE ACTION BUTTONS — bottom-right, delayed hide
   ============================================================ */
.msg-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.15s var(--ease-out);
  /* delay hides the buttons so cursor can reach them */
  transition-delay: 0.15s;
}
.message-wrapper.ai:hover .msg-actions,
.message-wrapper.assistant:hover .msg-actions {
  opacity: 1;
  transition-delay: 0s;
}
.msg-actions.show {
  opacity: 1;
  transition-delay: 0s;
}
.msg-action-btn {
  width: 30px; height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-main);
  background: var(--bg-card);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s var(--ease-out);
  font-size: 12px;
  position: relative;
}
.msg-action-btn:hover {
  background: var(--fill-active);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.msg-action-btn:active { transform: scale(0.93); }
.msg-action-btn.copied {
  color: var(--success);
  border-color: var(--success);
  background: var(--success-dim);
}
.msg-action-btn.thumbs-up:hover { color: var(--success); border-color: var(--success); }
.msg-action-btn.thumbs-down:hover { color: var(--error); border-color: var(--error); }

/* ============================================================
   MARKDOWN CONTENT STYLES
   ============================================================ */
.ai-text p { margin-bottom: 6px; }
.ai-text p:last-child { margin-bottom: 0; }
.ai-text strong { color: var(--text-primary); font-weight: 600; }
.ai-text em { color: var(--text-secondary); }
.ai-text code {
  background: var(--fill-active);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  border: 1px solid var(--border-light);
}
.ai-text pre {
  background: var(--bg-canvas);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  position: relative;
}
.ai-text pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: var(--text-secondary);
  font-size: inherit;
}
.ai-text ul, .ai-text ol { margin: 6px 0; padding-left: 20px; }
.ai-text li { margin-bottom: 3px; line-height: 1.6; }
.ai-text li::marker { color: var(--text-tertiary); }
.ai-text h3 { font-size: var(--font-size-md); font-weight: 600; color: var(--text-primary); margin: 12px 0 6px; }
.ai-text h4 { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); margin: 10px 0 4px; }
.ai-text blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 12px;
  margin: 8px 0;
  color: var(--text-tertiary);
  font-style: italic;
}
.ai-text hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 12px 0;
}
.ai-text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ai-text a:hover { color: var(--accent-hover); }

/* Table */
.ai-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: var(--font-size-sm);
}
.ai-text th {
  background: var(--fill-active);
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border: 1px solid var(--border-main);
}
.ai-text td {
  padding: 5px 10px;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

/* ============================================================
   CODE BLOCK COPY BUTTON
   ============================================================ */
/* Code language label */
.code-lang-label {
  font-size: 10px; color: var(--text-muted); text-transform: uppercase;
  position: absolute; top: 8px; left: 14px; font-family: var(--font-mono);
}

.code-block-wrapper {
  position: relative;
  margin: 8px 0;
}
.code-block-wrapper .copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px; height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: all var(--duration-fast) var(--ease-out);
  z-index: 5;
}
.code-block-wrapper:hover .copy-code-btn { opacity: 1; }
.copy-code-btn:hover { background: var(--fill-active); color: var(--text-primary); }
.copy-code-btn.copied { color: var(--success); border-color: var(--success); }

/* Tool card copy button */
.tool-card .copy-card-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px; height: 24px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  opacity: 0;
  transition: all var(--duration-fast) var(--ease-out);
}
.tool-card:hover .copy-card-btn { opacity: 1; }
.copy-card-btn:hover { background: var(--fill-hover); color: var(--text-primary); }
.copy-card-btn.copied { color: var(--success); }

/* ============================================================
   SCROLL TO BOTTOM BUTTON
   ============================================================ */
.scroll-bottom-btn {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all var(--duration-normal) var(--ease-out);
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.scroll-bottom-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.scroll-bottom-btn:hover {
  background: var(--fill-active);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}

/* ═══════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .sidebar { width: 280px; }
}

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.35s var(--ease-out), toastOut 0.3s var(--ease-out) 1.8s forwards;
  pointer-events: auto;
  white-space: nowrap;
}
.toast i { font-size: 13px; }
.toast.success i { color: var(--success); }
.toast.info i { color: var(--accent); }
.toast.error i { color: var(--error); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* ============================================================
   GLASSMORPHISM INPUT
   ============================================================ */
.input-area-wrapper {
  padding: 0 20px 16px;
  flex-shrink: 0;
  position: relative;
}
.input-container {
  background: rgba(30,30,30,0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-xl);
  padding: 8px 12px;
  display: flex; flex-direction: column;
  position: relative;
  gap: 6px;
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
.input-container:focus-within {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow), 0 0 0 1px var(--border-accent);
  background: rgba(30,30,30,0.88);
}
[data-theme="light"] .input-container {
  background: rgba(255,255,255,0.72);
}
[data-theme="light"] .input-container:focus-within {
  background: rgba(255,255,255,0.92);
}

/* ============================================================
   COMMAND PALETTE
   ============================================================ */
.cmd-palette-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 9998; display: none; align-items: flex-start; justify-content: center;
  padding-top: 18vh; backdrop-filter: blur(4px);
}
.cmd-palette-overlay.show { display: flex; }
.cmd-palette {
  width: 560px; max-width: 90vw; background: var(--bg-card);
  border: 1px solid var(--border-main); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: paletteIn 0.15s var(--ease-out);
}
.cmd-palette-input {
  width: 100%; border: none; background: transparent;
  color: var(--text-primary); font-size: var(--font-size-lg);
  padding: 16px 20px; outline: none; font-family: var(--font-sans);
  border-bottom: 1px solid var(--border-light);
}
.cmd-palette-input::placeholder { color: var(--text-muted); }
.cmd-palette-results { max-height: 320px; overflow-y: auto; padding: 6px; }
.cmd-palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-md);
  cursor: pointer; transition: all var(--duration-fast) var(--ease-out);
  color: var(--text-secondary); font-size: var(--font-size-md);
}
.cmd-palette-item:hover, .cmd-palette-item.active {
  background: var(--fill-selected); color: var(--text-primary);
}
.cmd-palette-item i { font-size: 16px; width: 20px; text-align: center; opacity: 0.6; }
.cmd-palette-item .shortcut {
  margin-left: auto; font-size: var(--font-size-xs);
  color: var(--text-tertiary); font-family: var(--font-mono);
  background: var(--fill-active); padding: 2px 8px; border-radius: var(--radius-xs);
}
.cmd-palette-section {
  font-size: var(--font-size-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-tertiary);
  padding: 8px 14px 4px;
}

/* ============================================================
   MISSION CONTROL VIEWS
   ============================================================ */

/* -- Live badge -- */
.live-badge { color: var(--success); font-size: 9px; margin-left: auto; animation: pulseDot 2s ease-in-out infinite; }

/* -- View container -- */
.view-container { padding: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.view-header { padding: 20px 24px 12px; border-bottom: 1px solid var(--border-light); flex-shrink: 0; }
.view-header h2 { font-size: 18px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 10px; }
.view-header h2 i { color: var(--accent); font-size: 20px; }
.view-header p { font-size: var(--font-size-sm); color: var(--text-tertiary); margin-top: 4px; }
.view-body { flex: 1; overflow-y: auto; padding: 16px 24px; }

/* -- Dashboard Grid -- */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-main); border-radius: var(--radius-lg);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 6px;
  transition: all var(--duration-fast) var(--ease-out); position: relative; overflow: hidden;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
  width: 36px; height: 36px; border-radius: var(--radius-md); display: flex;
  align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0;
}
.stat-card .stat-icon.blue { background: var(--accent-dim); color: var(--accent); }
.stat-card .stat-icon.green { background: var(--success-dim); color: var(--success); }
.stat-card .stat-icon.orange { background: var(--warning-dim); color: var(--warning); }
.stat-card .stat-icon.gray { background: var(--fill-hover); color: var(--text-tertiary); }
.stat-icon.purple { background: rgba(124,58,237,0.12); color: #7c3aed; }
.stat-card .stat-row { display: flex; align-items: center; gap: 12px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); letter-spacing: -1px; line-height: 1; }
.stat-card .stat-label { font-size: var(--font-size-xs); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
.stat-card .stat-detail { font-size: var(--font-size-sm); color: var(--text-secondary); }

/* -- Section card -- */
.section-card {
  background: var(--bg-card); border: 1px solid var(--border-main); border-radius: var(--radius-lg);
  margin-bottom: 16px; overflow: hidden;
}
.section-card-header {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--border-light); font-weight: 600; font-size: var(--font-size-md);
  color: var(--text-primary); cursor: pointer; user-select: none;
  transition: background var(--duration-fast) var(--ease-out);
}
.section-card-header:hover { background: var(--fill-hover); }
.section-card-header i:first-child { color: var(--accent); font-size: 16px; }
.section-card-header .section-badge {
  margin-left: auto; font-size: 10px; font-weight: 600; padding: 2px 10px;
  border-radius: var(--radius-full); background: var(--accent-dim); color: var(--accent);
}
.section-card-body { padding: 14px 18px; }

/* -- Activity Feed -- */
.activity-feed { display: flex; flex-direction: column; gap: 2px; }
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 8px 12px; border-radius: var(--radius-md);
  transition: background var(--duration-fast) var(--ease-out);
}
.activity-item:hover { background: var(--fill-hover); }
.activity-item .activity-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px; margin-top: 1px;
}
.activity-icon.tool { background: var(--accent-dim); color: var(--accent); }
.activity-icon.agent { background: var(--success-dim); color: var(--success); }
.activity-icon.error { background: var(--error-dim); color: var(--error); }
.activity-icon.message { background: var(--fill-active); color: var(--text-tertiary); }
.activity-icon.system { background: rgba(124,58,237,0.12); color: #7c3aed; }
.activity-item .activity-content { flex: 1; min-width: 0; }
.activity-item .activity-detail {
  font-size: var(--font-size-sm); color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-item .activity-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 2px;
}
.activity-item .activity-agent {
  font-size: var(--font-size-xs); color: var(--text-tertiary); font-weight: 500;
}
.activity-item .activity-time {
  font-size: var(--font-size-xs); color: var(--text-muted);
}
.activity-item .activity-status {
  font-size: 10px; font-weight: 600; padding: 1px 8px;
  border-radius: var(--radius-full); text-transform: uppercase; letter-spacing: 0.3px;
}
.activity-status.done { background: var(--success-dim); color: var(--success); }
.activity-status.running { background: var(--accent-dim); color: var(--accent); }
.activity-status.error { background: var(--error-dim); color: var(--error); }

/* -- Gateway Cards -- */
.gateway-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.gateway-card {
  background: var(--bg-card); border: 1px solid var(--border-main); border-radius: var(--radius-lg);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  transition: all var(--duration-fast) var(--ease-out);
}
.gateway-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.gateway-card .gateway-top { display: flex; align-items: center; gap: 10px; }
.gateway-card .gateway-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.gateway-card .gateway-icon.telegram { background: rgba(0,136,204,0.12); color: #0088cc; }
.gateway-card .gateway-icon.discord { background: rgba(88,101,242,0.12); color: #5865f2; }
.gateway-card .gateway-name { font-weight: 600; font-size: var(--font-size-md); color: var(--text-primary); flex: 1; }
.gateway-card .gateway-status {
  font-size: var(--font-size-xs); font-weight: 500; padding: 2px 10px;
  border-radius: var(--radius-full); text-transform: uppercase; letter-spacing: 0.3px;
}
.gateway-status.connected { background: var(--success-dim); color: var(--success); }
.gateway-status.disconnected { background: var(--error-dim); color: var(--error); }
.gateway-status.not_available, .gateway-status.checking { background: var(--fill-active); color: var(--text-tertiary); }
.gateway-card .gateway-meta { font-size: var(--font-size-xs); color: var(--text-tertiary); }
.gateway-card .gateway-error {
  font-size: var(--font-size-xs); color: var(--warning); padding: 6px 8px;
  background: var(--warning-dim); border-radius: var(--radius-sm);
}

/* -- Delegation Tree -- */
.delegation-tree { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.delegation-node {
  background: var(--bg-card); border: 1px solid var(--border-main); border-radius: var(--radius-lg);
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  transition: all var(--duration-fast) var(--ease-out); position: relative;
}
.delegation-node:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.delegation-node .node-avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.delegation-node .node-avatar.main { background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff; }
.delegation-node .node-avatar.child { background: var(--fill-active); color: var(--text-secondary); }
.delegation-node .node-info { flex: 1; min-width: 0; }
.delegation-node .node-title { font-size: var(--font-size-sm); font-weight: 500; color: var(--text-primary); }
.delegation-node .node-detail { font-size: var(--font-size-xs); color: var(--text-tertiary); margin-top: 1px; }
.delegation-node .node-status {
  font-size: 10px; font-weight: 600; padding: 2px 10px;
  border-radius: var(--radius-full); text-transform: uppercase;
}
.node-status.running { background: var(--accent-dim); color: var(--accent); }
.node-status.done { background: var(--success-dim); color: var(--success); }
.node-status.waiting { background: var(--fill-active); color: var(--text-tertiary); }
.node-status.error { background: var(--error-dim); color: var(--error); }
.delegation-connector {
  display: flex; align-items: center; padding-left: 44px; gap: 8px;
  color: var(--border-strong); font-size: 12px;
}

/* -- Skill Cards -- */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.skill-card {
  background: var(--bg-card); border: 1px solid var(--border-main); border-radius: var(--radius-lg);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  transition: all var(--duration-fast) var(--ease-out);
}
.skill-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.skill-card .skill-top { display: flex; align-items: flex-start; gap: 10px; }
.skill-card .skill-icon {
  width: 34px; height: 34px; border-radius: var(--radius-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: var(--accent-dim); color: var(--accent);
}
.skill-card .skill-info { flex: 1; min-width: 0; }
.skill-card .skill-name { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); }
.skill-card .skill-desc { font-size: var(--font-size-xs); color: var(--text-tertiary); margin-top: 2px; line-height: 1.4; }
.skill-card .skill-tag {
  font-size: 9px; font-weight: 600; padding: 1px 8px; border-radius: var(--radius-full);
  text-transform: uppercase; letter-spacing: 0.3px; align-self: flex-start;
  background: var(--fill-active); color: var(--text-tertiary);
}
.skill-card .skill-toggle {
  width: 100%; padding: 5px; border-radius: var(--radius-sm); border: 1px solid var(--border-light);
  background: transparent; color: var(--text-secondary); cursor: pointer; font-size: var(--font-size-xs);
  transition: all var(--duration-fast) var(--ease-out); text-align: center;
}
.skill-card .skill-toggle:hover { background: var(--fill-hover); color: var(--text-primary); }
.skill-card .skill-toggle.active { background: var(--accent-dim); color: var(--accent); border-color: var(--border-accent); }

/* -- Settings tab content -- */
.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }

/* -- Filter bar -- */
.filter-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar input[type="text"] {
  flex: 1; min-width: 180px; height: 36px; border-radius: var(--radius-md);
  background: var(--bg-input); border: 1px solid var(--border-light);
  padding: 0 12px 0 34px; font-size: var(--font-size-sm);
  color: var(--text-primary); font-family: var(--font-sans); outline: none;
  transition: all var(--duration-fast) var(--ease-out);
}
.filter-bar input[type="text"]:focus { border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.filter-bar input[type="text"]::placeholder { color: var(--text-muted); }
.filter-bar .filter-icon { position: relative; }
.filter-bar .filter-icon i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary); font-size: 14px; z-index: 1; pointer-events: none;
}
.filter-bar select {
  height: 36px; border-radius: var(--radius-md); background: var(--bg-input);
  border: 1px solid var(--border-light); color: var(--text-secondary);
  padding: 0 28px 0 12px; font-size: var(--font-size-sm); font-family: var(--font-sans);
  outline: none; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a7a7a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.filter-bar select:focus { border-color: var(--border-accent); }
.filter-bar .filter-btn {
  height: 36px; padding: 0 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-light); background: var(--bg-input);
  color: var(--text-secondary); cursor: pointer; font-size: var(--font-size-sm);
  transition: all var(--duration-fast) var(--ease-out); display: flex; align-items: center; gap: 6px;
}
.filter-bar .filter-btn:hover { background: var(--fill-hover); color: var(--text-primary); }

/* -- Empty state -- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; color: var(--text-tertiary); gap: 12px;
}
.empty-state i { font-size: 48px; opacity: 0.2; }
.empty-state h3 { font-size: var(--font-size-lg); color: var(--text-primary); font-weight: 500; }
.empty-state p { font-size: var(--font-size-sm); color: var(--text-muted); text-align: center; max-width: 360px; line-height: 1.6; }
.empty-state .btn { margin-top: 8px; }

/* -- Skeleton loading -- */
.skeleton-wrap { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.skeleton-row { display: flex; gap: 12px; align-items: center; }
.skeleton-block {
  background: var(--fill-active); border-radius: var(--radius-sm);
  animation: skeletonPulse 1.5s ease-in-out infinite; height: 14px;
}
.skeleton-card {
  background: var(--bg-card); border: 1px solid var(--border-main);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.skeleton-card .skeleton-block { background: var(--fill-hover); }
.skeleton-avatar { width: 36px; height: 36px; border-radius: var(--radius-full); flex-shrink: 0; }
.skeleton-line { height: 12px; border-radius: var(--radius-xs); }
.skeleton-line.w-20 { width: 20%; } .skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-60 { width: 60%; } .skeleton-line.w-80 { width: 80%; }

/* -- Confirmation dialog -- */
.dialog-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 10000; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.dialog-overlay.open { display: flex; }
.dialog-box {
  background: var(--bg-card); border: 1px solid var(--border-main);
  border-radius: var(--radius-xl); padding: 28px 32px;
  max-width: 400px; width: 90vw; box-shadow: var(--shadow-lg);
  animation: msgIn 0.2s var(--ease-out);
}
.dialog-icon { font-size: 32px; text-align: center; margin-bottom: 12px; }
.dialog-icon.warning i { color: var(--warning); }
.dialog-icon.error i { color: var(--error); }
.dialog-icon.info i { color: var(--accent); }
.dialog-title { font-size: 18px; font-weight: 600; color: var(--text-primary); text-align: center; margin-bottom: 8px; }
.dialog-desc { font-size: var(--font-size-sm); color: var(--text-secondary); text-align: center; margin-bottom: 24px; line-height: 1.5; }
.dialog-actions { display: flex; gap: 10px; justify-content: center; }
.dialog-btn {
  padding: 10px 24px; border-radius: var(--radius-md); border: none;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out); min-width: 100px;
}
.dialog-btn.primary { background: var(--accent); color: #fff; }
.dialog-btn.primary:hover { background: var(--accent-hover); }
.dialog-btn.secondary { background: var(--fill-active); color: var(--text-secondary); }
.dialog-btn.secondary:hover { background: var(--fill-hover); color: var(--text-primary); }
.dialog-btn.danger { background: var(--error); color: #fff; }
.dialog-btn.danger:hover { filter: brightness(1.1); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .right-panel { width: 380px; }
}
@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 200;
    width: 280px;
    min-width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease-out);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar .sidebar-brand { justify-content: flex-start; padding: 16px 20px; gap: 10px; }
  .sidebar .brand-logo { width: 32px; height: 32px; font-size: 16px; }
  .sidebar .brand-text,
  .sidebar .brand-badge { display: inline; }
  .sidebar .sidebar-new-task { justify-content: flex-start; margin: 4px 16px 12px; padding: 12px 14px; font-size: var(--font-size-md); gap: 8px; border-radius: var(--radius-lg); min-height: 44px; }
  .sidebar .sidebar-new-task i { font-size: 16px; opacity: 0.7; margin: 0; }
  .sidebar .sidebar-search-wrap { display: block; }
  .sidebar .sidebar-nav { padding: 4px 8px; }
  .sidebar .nav-section-label { display: block; }
  .sidebar .nav-item { justify-content: flex-start; padding: 12px; gap: 10px; font-size: var(--font-size-md); width: auto; margin: 0 0 2px 0; min-height: 44px; }
  .sidebar .nav-item i { font-size: 17px; }
  .sidebar .nav-item .nav-badge { display: inline; }
  .sidebar .chat-item { display: flex; padding: 12px; width: auto; margin: 0 0 1px 0; min-height: 44px; }
  .sidebar .chat-item-content { display: block; }
  .sidebar .chat-item-actions { display: none; }
  .sidebar .sidebar-footer { justify-content: flex-start; padding: 10px 16px; gap: 10px; min-height: 52px; }
  .sidebar .sidebar-toggle { display: none; }
  .sidebar .user-meta,
  .sidebar .user-actions { display: flex; }

  /* Backdrop overlay */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s var(--ease-out);
  }
  .sidebar-backdrop.show {
    display: block;
    opacity: 1;
  }

  /* Hamburger button — visible only on mobile */
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    transition: all var(--duration-fast) var(--ease-out);
    flex-shrink: 0;
  }
  .hamburger-btn:hover { background: var(--fill-hover); color: var(--text-primary); }

  .right-panel { width: 0; border-left: none; }
  .right-panel.expanded { width: 100vw; position: absolute; right: 0; top: 0; height: 100vh; z-index: 30; }

  /* Mobile tap target improvements */
  .header-btn, .theme-btn, .lang-btn, .input-toolbar-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 16px; }
  .send-btn { width: 44px; height: 44px; }
  .activity-btn { width: 44px; height: 44px; }
  .chat-item-actions button { width: 36px; height: 36px; }
  .input-textarea { font-size: 16px; } /* prevents iOS zoom */
  .msg-action-btn { width: 36px; height: 36px; }
  .code-block-wrapper .copy-code-btn { width: 36px; height: 36px; }
}
/* Hide hamburger on desktop */
@media (min-width: 821px) {
  .hamburger-btn { display: none; }
  .sidebar-backdrop { display: none !important; }
}

/* ============================================================
   LANGUAGE TOGGLE BUTTON (.lang-btn)
   ============================================================ */
.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-main);
  background: var(--fill-hover);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}
.lang-btn:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--border-accent);
}

/* ============================================================
   RTL / ARABIC SUPPORT
   html[dir="rtl"] overrides — activated by lang.js
   Font: Cairo covers Arabic script beautifully
   ============================================================ */
html[dir="rtl"] {
  --font-sans-rtl: 'Cairo', 'Segoe UI', system-ui, sans-serif;
}

html[dir="rtl"] body {
  font-family: var(--font-sans-rtl);
  direction: rtl;
  text-align: right;
}

/* ── Sidebar: flip to right side ─────────────────────────── */
html[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border-main);
  transform: translateX(100%);
}
html[dir="rtl"] .sidebar.open {
  transform: translateX(0);
}
html[dir="rtl"] .sidebar-brand {
  flex-direction: row-reverse;
}
html[dir="rtl"] .sidebar-new-task {
  flex-direction: row-reverse;
}
html[dir="rtl"] .nav-item {
  flex-direction: row-reverse;
  text-align: right;
}
html[dir="rtl"] .nav-badge {
  margin-right: auto;
  margin-left: 0;
}
html[dir="rtl"] .sidebar-footer {
  flex-direction: row-reverse;
}
html[dir="rtl"] .user-meta {
  text-align: right;
}

/* ── Floating sidebar toggle: mirror for RTL ──────────────── */
html[dir="rtl"] .sidebar-floating-toggle {
  left: auto;
  right: calc(var(--sidebar-width) - 13px);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
html[dir="rtl"] .sidebar-floating-toggle i {
  transform: rotate(180deg);
}
html[dir="rtl"] body.sidebar-collapsed .sidebar-floating-toggle {
  right: calc(var(--sidebar-collapsed-width) - 13px);
  left: auto;
}

/* ── Main content: offset from right sidebar ─────────────── */
html[dir="rtl"] .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-collapsed-width);
  transition: margin-right var(--duration-slow) var(--ease-out);
}
html[dir="rtl"] body.sidebar-open .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

/* ── Chat header: reverse flex ───────────────────────────── */
html[dir="rtl"] .chat-header {
  flex-direction: row-reverse;
}
html[dir="rtl"] .chat-header-actions {
  flex-direction: row-reverse;
}
html[dir="rtl"] .chat-header-spacer {
  margin-left: 0;
  margin-right: auto;
}

/* ── Model dropdown: align to right ──────────────────────── */
html[dir="rtl"] .model-dropdown {
  left: auto;
  right: 0;
}

/* ── Message bubbles ─────────────────────────────────────── */
html[dir="rtl"] .msg-user .msg-bubble {
  margin-left: 0;
  margin-right: auto;
  border-radius: var(--radius-lg) var(--radius-xs) var(--radius-lg) var(--radius-lg);
}
html[dir="rtl"] .msg-ai .msg-bubble {
  margin-right: 0;
  margin-left: auto;
}
html[dir="rtl"] .msg-row {
  flex-direction: row-reverse;
}
html[dir="rtl"] .msg-user .msg-row {
  flex-direction: row;
}
html[dir="rtl"] .msg-meta {
  flex-direction: row-reverse;
}
html[dir="rtl"] .msg-copy-btn {
  margin-left: 0;
  margin-right: auto;
}

/* ── Input area ──────────────────────────────────────────── */
html[dir="rtl"] .input-textarea {
  text-align: right;
  direction: rtl;
}
html[dir="rtl"] .input-toolbar {
  flex-direction: row-reverse;
}
html[dir="rtl"] .input-toolbar-left {
  margin-right: 0;
  margin-left: auto;
}

/* ── Activity bar ────────────────────────────────────────── */
html[dir="rtl"] .activity-bar {
  flex-direction: row-reverse;
}
html[dir="rtl"] .activity-status {
  flex-direction: row-reverse;
}

/* ── Right panel: flip to left side ──────────────────────── */
html[dir="rtl"] .right-panel {
  left: 0;
  right: auto;
  border-left: none;
  border-right: 1px solid var(--border-main);
}
html[dir="rtl"] .right-panel-header {
  flex-direction: row-reverse;
}
html[dir="rtl"] .right-panel-footer {
  flex-direction: row-reverse;
}

/* ── Command palette ─────────────────────────────────────── */
html[dir="rtl"] .cmd-palette-input {
  text-align: right;
  direction: rtl;
}
html[dir="rtl"] .cmd-palette-item {
  flex-direction: row-reverse;
  text-align: right;
}
html[dir="rtl"] .cmd-palette-item .shortcut {
  margin-left: 0;
  margin-right: auto;
}

/* ── Toast notifications ─────────────────────────────────── */
html[dir="rtl"] .toast-container {
  left: 16px;
  right: auto;
}
html[dir="rtl"] .toast {
  flex-direction: row-reverse;
}

/* ── Mobile sidebar in RTL ───────────────────────────────── */
@media (max-width: 820px) {
  html[dir="rtl"] .right-panel.expanded {
    left: 0;
    right: auto;
  }
}


.skill-chip { display:inline-block; padding:4px 10px; margin:2px; background:var(--fill-active); color:var(--accent); border-radius:999px; font-size:11px; cursor:pointer; transition:all .15s; }
.skill-chip:hover { background:var(--accent-dim); transform:scale(1.05); }
#skill-suggestions { padding:6px 12px; display:none; }
.cancel-btn { position:absolute; right:60px; bottom:16px; width:32px; height:32px; border-radius:50%; border:1px solid var(--error); background:transparent; color:var(--error); cursor:pointer; font-size:14px; display:none; z-index:5; transition:all .15s; }
.cancel-btn:hover { background:var(--error); color:#fff; }
.cancel-btn.visible { display:block; }


.quick-port-btn { padding:2px 6px; font-size:10px; border-radius:4px; border:1px solid var(--border-main); background:var(--bg-input); color:var(--text-secondary); cursor:pointer; font-family:var(--font-mono); transition:all .15s; }
.quick-port-btn:hover { background:var(--accent-dim); color:var(--accent); border-color:var(--accent); }
