/* ==========================================================================
   BLACKAI — PERPLEXITY & REPLIT UNIFIED DESIGN SYSTEM (v3.0.0 PRO)
   Deep Obsidian Slate (#0e0f14), Perplexity Iconic "Ask" Omnibar,
   Replit Technical 1px Hairline Precision & Zero-Lag 144Hz Architecture.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS & COLOR SYSTEM
   -------------------------------------------------------------------------- */
:root {
  /* Perplexity & Replit Palette */
  --pplx-teal: #20b8cd;
  --pplx-teal-hover: #22d3ee;
  --pplx-teal-glow: rgba(32, 184, 205, 0.25);
  --pplx-teal-subtle: rgba(32, 184, 205, 0.08);

  --replit-crimson: #ef4457;
  --replit-orange: #f26522;

  /* Canvas & Layering Hierarchy (Dark Mode Elevation) */
  --bg-canvas: #0e0f14;
  --bg-sidebar: #13151c;
  --bg-surface: #171923;
  --bg-surface-raised: #1d202d;
  --bg-surface-hover: #232737;
  --bg-surface-active: #2a2f42;

  /* Hairline Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-muted: rgba(255, 255, 255, 0.13);
  --border-hover: rgba(255, 255, 255, 0.22);
  --border-active: rgba(32, 184, 205, 0.5);

  /* Typography Colors */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;

  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;

  /* Elevation Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.65);
  --shadow-omnibar: 0 10px 36px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.08) inset;

  /* Sizing */
  --sidebar-w: 260px;
  --topbar-h: 52px;
  --max-content-w: 840px;

  /* Transitions */
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Theme variations */
body.theme-blackgpt {
  --pplx-teal: #ef4457;
  --pplx-teal-hover: #ff596a;
  --pplx-teal-glow: rgba(239, 68, 87, 0.25);
  --pplx-teal-subtle: rgba(239, 68, 87, 0.08);
}

body.theme-crimson-fire {
  --pplx-teal: #ff4500;
  --pplx-teal-hover: #ff6a00;
  --pplx-teal-glow: rgba(255, 69, 0, 0.25);
  --pplx-teal-subtle: rgba(255, 69, 0, 0.08);
}

body.theme-sapphire-blue {
  --pplx-teal: #3b82f6;
  --pplx-teal-hover: #60a5fa;
  --pplx-teal-glow: rgba(59, 130, 246, 0.25);
  --pplx-teal-subtle: rgba(59, 130, 246, 0.08);
}

body.theme-cyber-cyan {
  --pplx-teal: #00f0ff;
  --pplx-teal-hover: #38bdf8;
  --pplx-teal-glow: rgba(0, 240, 255, 0.25);
  --pplx-teal-subtle: rgba(0, 240, 255, 0.08);
}

body.theme-emerald-neon {
  --pplx-teal: #10b981;
  --pplx-teal-hover: #34d399;
  --pplx-teal-glow: rgba(16, 185, 129, 0.25);
  --pplx-teal-subtle: rgba(16, 185, 129, 0.08);
}

/* --------------------------------------------------------------------------
   2. GLOBAL RESETS & ZERO-LAG OPTIMIZATION
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  outline: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

*:focus, *:focus-visible {
  outline: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Replit Style */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* --------------------------------------------------------------------------
   3. BACKGROUND & CANVAS LAYER (ZERO GPU LAG)
   -------------------------------------------------------------------------- */
.pplx-canvas-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: var(--bg-canvas);
  overflow: hidden;
}

.pplx-dot-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.85;
}

.mouse-glow {
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--pplx-teal-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   4. APP LAYOUT
   -------------------------------------------------------------------------- */
.app-layout {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   5. PERPLEXITY RAIL SIDEBAR
   -------------------------------------------------------------------------- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 90;
}

.pplx-sidebar,
.glass-sidebar {
  position: relative;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.24s var(--ease-smooth), transform 0.24s var(--ease-smooth);
  z-index: 100;
}

.pplx-sidebar.collapsed,
.glass-sidebar.collapsed {
  width: 0;
  overflow: hidden;
  border-right-color: transparent;
}

.sidebar-container {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  height: 100%;
  padding: 16px 14px;
  gap: 12px;
  overflow: hidden;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 4px 4px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.brand-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--pplx-teal-subtle);
  border: 1px solid rgba(32, 184, 205, 0.25);
  color: var(--pplx-teal);
}

.pplx-asterism-icon {
  width: 18px;
  height: 18px;
}

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

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.text-teal {
  color: var(--pplx-teal) !important;
}

.text-crimson {
  color: var(--replit-crimson) !important;
}

.brand-subtitle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* Collapse Button */
.collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.collapse-btn:hover {
  background: var(--bg-surface-raised);
  color: #fff;
  border-color: var(--border-subtle);
}

.collapse-btn svg {
  width: 16px;
  height: 16px;
}

/* Perplexity Signature "+ New Thread" Button */
.pplx-new-thread-btn,
.glass-btn-primary.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--bg-surface-raised) !important;
  border: 1px solid var(--border-muted) !important;
  border-radius: 12px !important;
  padding: 10px 14px !important;
  color: #f1f5f9 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: all 0.18s ease !important;
  box-shadow: var(--shadow-sm);
}

.pplx-new-thread-btn:hover,
.glass-btn-primary.new-chat-btn:hover {
  background: var(--bg-surface-hover) !important;
  border-color: var(--border-hover) !important;
  color: #fff !important;
  transform: translateY(-1px);
}

.btn-content-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-content-left svg {
  width: 15px;
  height: 15px;
  color: var(--pplx-teal);
}

.shortcut-tag {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Search Box */
.search-box-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 10px !important;
  padding: 8px 12px !important;
  transition: border-color 0.18s ease;
}

.search-box-wrap:focus-within {
  border-color: var(--border-active) !important;
}

.search-box-wrap svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 12.5px;
  font-family: var(--font-sans);
}

.search-box-wrap input::placeholder {
  color: var(--text-muted);
}

/* Section Title */
.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.session-count {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  padding: 1px 7px;
  font-size: 10px;
  font-family: var(--font-mono);
}

/* Scrollable Session List */
.session-scroll-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}

.session-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  border-left: 2px solid transparent;
}

.session-card:hover {
  background: var(--bg-surface);
  color: #f8fafc;
}

.session-card.active {
  background: var(--pplx-teal-subtle) !important;
  border-left-color: var(--pplx-teal) !important;
  color: #fff !important;
  font-weight: 600;
}

.session-card-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card-actions {
  display: none;
  align-items: center;
  gap: 4px;
}

.session-card:hover .session-card-actions,
.session-card.active .session-card-actions {
  display: flex;
}

.session-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-action-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.session-action-btn svg {
  width: 12px;
  height: 12px;
}

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

/* Sidebar Footer */
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1f2333, #2b3248);
  border: 1px solid var(--border-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11.5px;
  color: var(--pplx-teal);
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-status-text {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

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

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

.icon-control-btn:hover {
  background: var(--bg-surface-raised);
  border-color: var(--border-subtle);
  color: #fff;
}

.icon-control-btn svg {
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   6. MAIN CHAT VIEWPORT & REPLIT TOPBAR
   -------------------------------------------------------------------------- */
.chat-viewport {
  position: relative;
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-canvas);
}

/* Topbar Header */
.dynamic-topbar-wrap {
  width: 100%;
  padding: 8px 16px;
  z-index: 50;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.dynamic-topbar {
  width: 100%;
  max-width: var(--max-content-w);
  height: var(--topbar-h);
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.session-heading-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.session-heading {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.session-heading:hover {
  color: var(--pplx-teal);
}

.session-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}

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

.status-pulse-dot.thinking {
  background: var(--pplx-teal);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.token-window-badge {
  display: flex;
  align-items: center;
  gap: 5px;
}

.token-icon {
  width: 11px;
  height: 11px;
  color: var(--pplx-teal);
}

.token-mini-bar-wrap {
  width: 36px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  overflow: hidden;
}

.token-mini-bar {
  height: 100%;
  background: var(--pplx-teal);
  transition: width 0.3s ease;
}

/* Topbar Right Actions */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-action-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-action-pill:hover {
  background: var(--bg-surface-hover);
  color: #fff;
  border-color: var(--border-muted);
}

.topbar-action-pill.icon-only {
  padding: 0;
  width: 32px;
  justify-content: center;
}

.topbar-action-pill svg {
  width: 14px;
  height: 14px;
}

/* --------------------------------------------------------------------------
   7. MESSAGES CONTAINER & PERPLEXITY HERO
   -------------------------------------------------------------------------- */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  padding: 16px 20px 140px 20px;
}

.messages-track {
  width: 100%;
  max-width: var(--max-content-w);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Empty Hero State */
.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 0 24px 0;
  gap: 32px;
  margin: auto 0;
}

.pplx-hero-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pplx-hero-logo-box {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--pplx-teal-subtle);
  border: 1px solid rgba(32, 184, 205, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pplx-teal);
  box-shadow: 0 8px 24px var(--pplx-teal-glow);
}

.pplx-hero-svg {
  width: 32px;
  height: 32px;
}

.empty-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}

.empty-description {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 520px;
  line-height: 1.6;
}

/* Prompt Grid (Topic Suggestions) */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.prompt-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 12px !important;
  padding: 14px 16px !important;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease !important;
}

.prompt-card:hover {
  background: var(--bg-surface-raised) !important;
  border-color: var(--border-active) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.prompt-card-icon {
  font-size: 18px;
  line-height: 1;
  padding-top: 2px;
}

.prompt-card-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prompt-card-text b {
  font-size: 13.5px;
  font-weight: 600;
  color: #f1f5f9;
}

.prompt-card-text span {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
   8. CHAT MESSAGE FLOW (PERPLEXITY EDITORIAL + REPLIT IDE)
   -------------------------------------------------------------------------- */
.message-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* User Message */
.message-row.user {
  align-items: flex-end;
}

.message-row.user .message-bubble {
  background: var(--bg-surface-raised) !important;
  border: 1px solid var(--border-muted) !important;
  border-radius: 16px 16px 4px 16px !important;
  padding: 12px 18px !important;
  color: #f8fafc !important;
  font-size: 15px !important;
  max-width: 85%;
  box-shadow: var(--shadow-sm);
}

.user-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.message-row.user:hover .user-actions-bar {
  opacity: 1;
}

.user-tool-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.user-tool-btn:hover {
  color: #fff;
  background: var(--bg-surface);
}

.user-tool-btn svg {
  width: 12px;
  height: 12px;
}

/* Assistant Message (Perplexity Clean Unboxed Knowledge Stream) */
.message-row.assistant {
  align-items: flex-start;
}

.message-content-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.message-row.assistant .message-bubble {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: #e2e8f0 !important;
  font-size: 15px !important;
  line-height: 1.75 !important;
  width: 100%;
}

.message-body {
  width: 100%;
}

/* Typography Inside Assistant Messages */
.message-body p {
  margin-bottom: 14px;
}

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

.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4 {
  color: #fff;
  font-weight: 700;
  margin: 22px 0 10px 0;
  letter-spacing: -0.02em;
}

.message-body h1 { font-size: 22px; }
.message-body h2 { font-size: 18px; border-bottom: 1px solid var(--border-subtle); padding-bottom: 6px; }
.message-body h3 { font-size: 16px; }

.message-body ul,
.message-body ol {
  margin: 10px 0 16px 20px;
}

.message-body li {
  margin-bottom: 6px;
}

.message-body blockquote {
  background: var(--pplx-teal-subtle);
  border-left: 3px solid var(--pplx-teal);
  padding: 10px 16px;
  border-radius: 0 8px 8px 0;
  color: #cbd5e1;
  margin: 14px 0;
}

.message-body strong,
.message-body b {
  color: #fff;
  font-weight: 600;
}

/* Inline Code */
.message-body code:not(.code-content) {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--pplx-teal);
}

/* Markdown Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.markdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.markdown-table th {
  background: var(--bg-surface-raised);
  color: #fff;
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-muted);
}

.markdown-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: #cbd5e1;
}

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

/* Assistant Message Actions Toolbar */
.message-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.msg-tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.msg-tool-btn:hover {
  background: var(--bg-surface-raised);
  color: #fff;
  border-color: var(--border-muted);
}

.msg-tool-btn svg {
  width: 13px;
  height: 13px;
}

.message-speed-tag {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   9. REPLIT CODE STUDIO CODE BLOCKS
   -------------------------------------------------------------------------- */
.code-block-wrap {
  position: relative;
  width: 100%;
  background: #0c0d12 !important;
  border: 1px solid #1f232e !important;
  border-radius: 10px !important;
  margin: 18px 0 !important;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #14161f !important;
  border-bottom: 1px solid #1f232e !important;
  padding: 8px 14px !important;
}

.code-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.code-window-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-window-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.code-window-dots .dot.red { background: #ef4444; }
.code-window-dots .dot.yellow { background: #eab308; }
.code-window-dots .dot.green { background: #22c55e; }

.code-lang-label {
  font-size: 11.5px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
}

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

.code-header-actions button {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #1c1f2b;
  border: 1px solid #282d3d;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.code-header-actions button:hover {
  background: #252a3b;
  color: #fff;
  border-color: #3b4259;
}

.run-code-btn {
  color: var(--pplx-teal) !important;
  border-color: rgba(32, 184, 205, 0.3) !important;
}

.run-code-btn:hover {
  background: rgba(32, 184, 205, 0.15) !important;
}

.code-block-wrap pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: transparent;
}

.code-content {
  font-family: var(--font-mono) !important;
  font-size: 13.5px !important;
  line-height: 1.65 !important;
  color: #f1f5f9 !important;
}

/* --------------------------------------------------------------------------
   10. THE ICONIC PERPLEXITY "ASK" OMNIBAR
   -------------------------------------------------------------------------- */
.composer-dock-area {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 16px 20px;
  background: linear-gradient(180deg, transparent 0%, rgba(14, 15, 20, 0.85) 45%, rgba(14, 15, 20, 1) 100%);
  pointer-events: none;
  z-index: 40;
}

.composer-island {
  position: relative;
  width: 100%;
  max-width: var(--max-content-w);
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-muted) !important;
  border-radius: 18px !important;
  box-shadow: var(--shadow-omnibar) !important;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 12px 16px;
  gap: 10px;
  pointer-events: auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer-island:focus-within {
  border-color: var(--pplx-teal) !important;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--pplx-teal) !important;
}

/* Quick Commands Chips */
.quick-commands-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.cmd-chip {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.cmd-chip:hover {
  background: var(--bg-surface-hover);
  color: var(--pplx-teal);
  border-color: var(--border-hover);
}

.cmd-chip-prefix {
  color: var(--pplx-teal);
  font-weight: 700;
}

/* Textarea Input */
.input-row {
  width: 100%;
}

#composerInput {
  width: 100%;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  resize: none !important;
  color: #fff !important;
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.5;
  min-height: 24px;
  max-height: 180px;
}

#composerInput::placeholder {
  color: var(--text-muted);
}

/* Composer Toolbar */
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-top: 4px;
}

.toolbar-left-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-btn.icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn.icon-circle:hover {
  background: var(--bg-surface-hover);
  color: #fff;
  border-color: var(--border-muted);
}

.tool-btn.icon-circle svg {
  width: 16px;
  height: 16px;
}

/* Selector Pills (Model & Effort) */
.selector-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-surface-raised) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 8px !important;
  color: var(--text-secondary) !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.selector-pill:hover {
  background: var(--bg-surface-hover) !important;
  color: #fff !important;
  border-color: var(--border-muted) !important;
}

.selector-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.model-dot { background: var(--pplx-teal); }
.effort-dot.low { background: #38bdf8; }
.effort-dot.medium { background: var(--pplx-teal); }
.effort-dot.high { background: #a855f7; }

.selector-pill .arrow-icon {
  width: 10px;
  height: 10px;
  color: var(--text-muted);
}

/* Toolbar Right Group */
.toolbar-right-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.char-counter {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.submit-action-slot {
  display: flex;
  align-items: center;
}

/* Perplexity Signature Send Button */
.send-message-btn {
  width: 34px !important;
  height: 34px !important;
  border-radius: 9px !important;
  background: var(--pplx-teal) !important;
  color: #0b0c10 !important;
  border: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease !important;
  box-shadow: 0 2px 10px var(--pplx-teal-glow);
}

.send-message-btn:disabled {
  background: var(--bg-surface-raised) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed;
  box-shadow: none;
}

.send-message-btn:not(:disabled):hover {
  background: var(--pplx-teal-hover) !important;
  transform: translateY(-1px);
}

.send-message-btn svg {
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
}

.stop-generate-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--replit-crimson);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.composer-footnote {
  padding-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

/* Scroll To Bottom Button */
.scroll-bottom-btn {
  position: fixed;
  bottom: 110px;
  right: 28px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-muted);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 30;
}

.scroll-bottom-btn.show {
  opacity: 1;
  pointer-events: auto;
}

.scroll-bottom-btn svg {
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   11. POPOVERS & MENUS
   -------------------------------------------------------------------------- */
.dropdown-anchor {
  position: relative;
}

.glass-menu,
.more-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #161823 !important;
  border: 1px solid var(--border-muted) !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 6px !important;
  display: none;
  flex-direction: column;
  min-width: 220px;
  z-index: 120;
}

.more-popover {
  top: calc(100% + 8px);
  bottom: auto;
  right: 0;
  left: auto;
}

.glass-menu.show,
.more-popover.show {
  display: flex !important;
}

.menu-group-heading,
.more-menu-section-title {
  padding: 8px 10px 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.menu-item,
.more-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.menu-item:hover,
.more-menu-item:hover {
  background: var(--bg-surface-raised);
  color: #fff;
}

.menu-item.active {
  background: var(--pplx-teal-subtle);
  color: var(--pplx-teal);
}

.menu-item.active b {
  color: var(--pplx-teal);
}

.menu-item svg,
.more-menu-item svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.menu-item.active svg {
  color: var(--pplx-teal);
}

.more-menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

.more-menu-item.danger:hover {
  background: rgba(239, 68, 87, 0.15);
  color: var(--replit-crimson);
}

/* --------------------------------------------------------------------------
   12. MODALS (SETTINGS, SHORTCUTS, TOKEN MONITOR)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none !important;
}

.glass-modal-card {
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  background: #141620 !important;
  border: 1px solid var(--border-muted) !important;
  border-radius: 18px !important;
  box-shadow: var(--shadow-lg) !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-crimson-icon {
  font-size: 20px;
}

.modal-header h2,
.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.modal-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.close-modal-btn,
.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.close-modal-btn:hover,
.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
}

.setting-row.vertical {
  flex-direction: column;
  align-items: flex-start;
}

.setting-row.danger-border {
  border-color: rgba(239, 68, 87, 0.3);
}

.setting-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.setting-text b {
  font-size: 13.5px;
  color: #fff;
}

.setting-text span {
  font-size: 12px;
  color: var(--text-muted);
}

/* Color Picker */
.color-palette-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-dot-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.color-dot-btn.active {
  border-color: #fff;
  transform: scale(1.15);
}

/* Backend Status Card */
.backend-status-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.backend-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.backend-status-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.backend-live-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 9999px;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 700;
  color: #10b981;
}

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

.backend-info-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.backend-info-grid b {
  color: #e2e8f0;
}

/* Modals Buttons */
.glass-btn-sm,
.glass-btn-secondary,
.glass-btn-primary-action,
.glass-btn-danger {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.glass-btn-primary-action {
  background: var(--pplx-teal);
  color: #0b0c10;
}

.glass-btn-secondary {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  color: #fff;
}

.glass-btn-danger {
  background: rgba(239, 68, 87, 0.15);
  border: 1px solid rgba(239, 68, 87, 0.3);
  color: var(--replit-crimson);
}

/* Shortcuts Grid */
.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.shortcut-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #cbd5e1;
}

.shortcut-card kbd {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-muted);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--pplx-teal);
}

/* Toast */
.glass-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: #1c1f2e;
  border: 1px solid var(--border-muted);
  box-shadow: var(--shadow-lg);
  border-radius: 10px;
  padding: 10px 18px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s var(--ease-smooth);
  z-index: 300;
}

.glass-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------------------
   13. RESPONSIVE BEHAVIOR (MOBILE & TABLET)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .pplx-sidebar,
  .glass-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .pplx-sidebar:not(.collapsed),
  .glass-sidebar:not(.collapsed) {
    transform: translateX(0);
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .messages-container {
    padding: 12px 14px 150px 14px;
  }

  .composer-dock-area {
    padding: 0 10px 12px 10px;
  }

  .toolbar-left-group {
    gap: 4px;
  }

  .selector-pill {
    padding: 0 6px;
    font-size: 11px !important;
  }
}
