:root {
  --bg-primary: #121214;
  --bg-secondary: #18181b;
  --bg-tertiary: #202024;
  --bg-hover: #27272c;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-focus: rgba(99, 102, 241, 0.35);
  --border: rgba(255, 255, 255, 0.08);
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: rgba(99, 102, 241, 0.12);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --shimmer-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --primary-accent: #6366f1;
  --brand-indigo: #6366f1;
  --brand-violet: #8b5cf6;
  --brand-pink: #ec4899;
  --brand-emerald: #10b981;
  --brand-amber: #f59e0b;
  --brand-rose: #ef4444;
  --card-glass-bg: rgba(24, 24, 27, 0.85);
  --card-glass-border: rgba(255, 255, 255, 0.08);
  --card-hover-border: rgba(99, 102, 241, 0.35);
  --user-msg-bg: #1f1f24;
  --user-msg-border: rgba(255, 255, 255, 0.09);
  --user-msg-text: #f4f4f5;
  --assistant-msg-bg: #18181b;
  --code-bg: #0d0d11;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.65);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.2);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, "Fira Code", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

[data-theme="light"] {
  --bg-primary: #F9F9F8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #F2F2F0;
  --bg-hover: #ECECE9;
  --border-color: rgba(0, 0, 0, 0.07);
  --border-color-focus: rgba(99, 102, 241, 0.35);
  --border: rgba(0, 0, 0, 0.07);
  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #78716c;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: rgba(99, 102, 241, 0.08);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --shimmer-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --user-msg-bg: #F0F0EE;
  --user-msg-border: rgba(0, 0, 0, 0.06);
  --user-msg-text: #1c1917;
  --assistant-msg-bg: #ffffff;
  --code-bg: #f5f5f4;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.12);
}
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 25px rgba(37, 99, 235, 0.15);
}

/* ========================================================
   Custom Sleek Modern Scrollbars
   ======================================================== */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

[data-theme="light"] * {
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 9999px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

::-webkit-scrollbar-thumb:active {
  background: var(--accent-color);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.16);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:active {
  background: var(--accent-color);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

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

html, body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  width: 100%;
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Mobile Sidebar Backdrop */
.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;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* App Container */
.app-container {
  display: flex;
  width: 100%;
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.24s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, transform 0.25s ease;
  z-index: 20;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

.sidebar > * {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

@media (min-width: 769px) {
  .app-container.sidebar-collapsed .sidebar {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-right-width: 0 !important;
    border-right-color: transparent !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden;
  }
}

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

.sidebar-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-tertiary, #94a3b8);
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 0;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.08));
  color: var(--text-primary, #f8fafc);
  border-color: var(--border-color);
  transform: scale(1.05);
}

.sidebar-collapse-btn:active {
  transform: scale(0.95);
}

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

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #18181b 0%, #27272a 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

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

.brand-title {
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.btn-new-chat {
  margin: 12px 14px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-new-chat:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Sidebar History Search Filter & Time Collapse Toggle Row */
.sidebar-search-row {
  margin: 0 14px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar-collapse-all-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s ease;
  padding: 0;
}

.sidebar-collapse-all-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.35);
}

.sidebar-collapse-all-btn svg {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapse-all-btn.all-collapsed svg {
  transform: rotate(180deg);
}

[data-theme="light"] .sidebar-collapse-all-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

.sidebar-search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 6px 26px 6px 30px;
  font-size: 0.78rem;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
  box-sizing: border-box;
}

.sidebar-search-input:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.sidebar-search-clear {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-search-clear:hover {
  color: var(--text-primary);
}

.conversations-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Timeline Groups & Collapsible Nodes */
.conv-timeline-group {
  display: flex;
  flex-direction: column;
}

.conv-timeline-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  user-select: none;
  position: relative;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
}

.conv-timeline-node:hover {
  background-color: var(--bg-hover, rgba(255, 255, 255, 0.04));
  color: var(--text-secondary);
}

.conv-timeline-node:focus-visible {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.conv-timeline-node:first-child {
  margin-top: 0;
}

.timeline-node-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--accent-color);
  opacity: 0.75;
  flex-shrink: 0;
}

.timeline-node-title {
  flex: 1;
  text-transform: none;
  font-size: 0.74rem;
}

.timeline-node-count {
  font-size: 0.66rem;
  padding: 1px 6px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.timeline-node-chevron {
  width: 12px;
  height: 12px;
  color: var(--text-muted);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  margin-left: 2px;
}

.conv-timeline-node.is-collapsed .timeline-node-chevron {
  transform: rotate(-90deg);
}

.conv-timeline-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: opacity 0.2s ease;
}

.conv-timeline-group.is-collapsed .conv-timeline-items {
  display: none;
}

[data-theme="light"] .timeline-node-count {
  background: rgba(0, 0, 0, 0.04);
}

.conversation-item {
  padding: 7px 10px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.84rem;
  transition: all 0.15s ease;
  position: relative;
  text-decoration: none;
  border: 1px solid transparent;
  min-height: 38px;
  box-sizing: border-box;
}

.conversation-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.conversation-item.active {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 500;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .conversation-item.active {
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.08);
}

.conversation-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.conversation-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  width: 100%;
}

.conversation-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  padding-right: 4px;
  color: var(--text-primary);
  line-height: 1.35;
}

.conversation-time {
  font-size: 0.69rem;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  opacity: 0.72;
}

/* Ensure conversation time stays clearly visible on hover */
.conversation-item:hover .conversation-time {
  opacity: 0.92;
  color: var(--text-secondary);
}

.conversation-del-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, color 0.15s;
}

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

.conversation-del-btn:hover {
  color: #ef4444;
}

.sidebar-footer {
  flex-shrink: 0;
  overflow: hidden;
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.setting-select {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

/* Main Chat Container */
.main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  background-color: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* Top Navbar */
.top-navbar {
  height: 52px;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10;
}

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

.toggle-sidebar-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.toggle-sidebar-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.current-model-tag {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.82rem;
  padding: 5px 12px;
  border-radius: 9999px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.current-model-tag:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-1px);
}

.header-model-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  max-width: 170px;
}

.header-model-select option {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  padding: 6px;
}

.msg-model-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-weight: 500;
  margin-right: 4px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
  transition: all 0.3s var(--ease-spring);
  flex-shrink: 0;
}

.status-dot.generating {
  background-color: #8b5cf6;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.85);
  animation: statusPulse 1.1s infinite ease-in-out;
}

.status-dot.error {
  background-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.9);
  animation: none;
}

@keyframes statusPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.55; }
}

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

.icon-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-spring);
}

.icon-btn span {
  display: none;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateY(-1px);
}

[data-theme="light"] .icon-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .icon-btn:hover {
  background: rgba(0, 0, 0, 0.07);
  border-color: rgba(0, 0, 0, 0.16);
  color: #09090b;
}

/* User Account Pill & Dropdown */
.user-menu-container {
  position: relative;
}

.user-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 0.82rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.user-badge:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.badge-tag {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  background-color: rgba(59, 130, 246, 0.2);
  color: var(--accent-color);
  font-weight: 600;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 190px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: none;
  flex-direction: column;
  padding: 6px;
  z-index: 100;
}

.user-dropdown.show {
  display: flex;
}

.dropdown-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}

.dropdown-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

.dropdown-item.danger:hover {
  color: #ef4444;
}

/* Chat Messages Area - Modern Wide Stream */
.chat-messages {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 32px 36px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  box-sizing: border-box;
}

/* Architecture C: Minimalist Hero & Suggestion Chips */
.welcome-screen {
  margin: auto;
  text-align: center;
  max-width: 760px;
  width: 100%;
  padding: 60px 24px 30px;
  animation: welcomeFadeIn 0.5s var(--ease-spring);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

@keyframes welcomeFadeIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 9999px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.22);
  color: #60a5fa;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  margin-bottom: 22px;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.1);
}

.welcome-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 8px #3b82f6;
  animation: pulseDot 2s infinite ease-in-out;
}

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

.welcome-title {
  font-size: 2.3rem;
  font-weight: 600;
  margin-bottom: 14px;
  letter-spacing: -0.035em;
  line-height: 1.25;
  background: linear-gradient(180deg, #ffffff 40%, rgba(255, 255, 255, 0.68) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #ffffff;
}

[data-theme="light"] .welcome-title {
  background: linear-gradient(180deg, #18181b 30%, #52525b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #18181b;
}

.welcome-subtitle {
  color: #a1a1aa;
  font-size: 0.96rem;
  margin-bottom: 40px;
  line-height: 1.6;
  max-width: 580px;
  letter-spacing: -0.01em;
}

[data-theme="light"] .welcome-subtitle {
  color: #71717a;
}

.suggestions-chips-wrap {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 720px;
  text-align: left;
}

.suggestion-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .suggestion-chip {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.suggestion-chip:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -4px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .suggestion-chip:hover {
  background: #fcfcfd;
  border-color: rgba(0, 0, 0, 0.16);
  box-shadow: 0 10px 20px -4px rgba(0, 0, 0, 0.08);
}

.chip-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

[data-theme="light"] .chip-icon {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.04);
}

.chip-text {
  font-size: 0.88rem;
  font-weight: 500;
  color: #e4e4e7;
  letter-spacing: -0.01em;
  line-height: 1.45;
  flex: 1;
}

[data-theme="light"] .chip-text {
  color: #27272a;
}

.chip-arrow {
  font-size: 0.88rem;
  color: #a1a1aa;
  opacity: 0.35;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.suggestion-chip:hover .chip-arrow {
  opacity: 1;
  transform: translateX(4px);
  color: #38bdf8;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  text-align: left;
}

.suggestion-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .suggestion-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.suggestion-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.suggestion-card h4 {
  font-size: 0.88rem;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-weight: 600;
}

.suggestion-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Message Rows - Silkiness & Fluid Physics */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message-row {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  animation: messageSlideIn 0.32s var(--ease-spring) forwards;
  will-change: transform, opacity;
}

/* ==============================================================================
   ChatGPT Conversational Style: User on the Right, Assistant on the Left
   ============================================================================== */
.message-row.user {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  justify-content: flex-end !important;
  margin-top: 24px;
  margin-bottom: 16px;
  margin-left: auto !important;
  margin-right: 0 !important;
  padding-bottom: 0;
  border-bottom: none !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.message-row.user .message-bubble {
  align-self: flex-end !important;
  margin-left: auto !important;
  margin-right: 0 !important;
  max-width: min(85%, 880px) !important;
  width: fit-content !important;
  background: var(--bg-tertiary, #27272a) !important;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1)) !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22) !important;
  border-radius: 20px 20px 4px 20px !important;
  padding: 12px 18px !important;
  color: var(--text-primary, #ffffff) !important;
  box-sizing: border-box;
}

.message-row.user .message-body {
  font-size: 0.95rem !important;
  font-weight: 400 !important;
  line-height: 1.6 !important;
  letter-spacing: normal !important;
  color: var(--text-primary, #ffffff) !important;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row.user .message-footer {
  display: flex !important;
  align-self: flex-end;
  margin-top: 4px;
  margin-right: 4px;
  font-size: 0.72rem;
  opacity: 0.6;
}

/* Light Theme User Bubble */
[data-theme="light"] .message-row.user .message-bubble {
  background: #f1f5f9 !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #0f172a !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .message-row.user .message-body {
  color: #0f172a !important;
}

/* Argon Theme User Bubble */
[data-theme="argon"] .message-row.user .message-bubble {
  background: #1c1734 !important;
  border: 1px solid rgba(168, 85, 247, 0.3) !important;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.2) !important;
  color: #ffffff !important;
}

.message-avatar {
  display: none !important;
}

.assistant-avatar {
  display: none !important;
}

.user-avatar {
  display: none !important;
}

.message-bubble {
  max-width: 100%;
  width: 100%;
  font-size: 0.96rem;
  line-height: 1.82;
  letter-spacing: -0.003em;
  word-break: break-word;
  overflow-wrap: break-word;
  position: relative;
}

.message-row.assistant .message-bubble {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 4px 0 0 0 !important;
  width: 100%;
  max-width: 100%;
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
  line-height: 1.82;
  letter-spacing: -0.003em;
}

.message-row.assistant .message-body p {
  margin-bottom: 14px;
}

[data-theme="light"] .message-row.assistant .message-bubble {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.message-footer {
  margin-top: 12px;
  padding-top: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 0.74rem;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.message-row.assistant:hover .message-footer {
  opacity: 1;
}

.msg-tokens-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: var(--bg-secondary, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: help;
  transition: all 0.2s ease;
}

.msg-tokens-badge:hover {
  border-color: rgba(96, 165, 250, 0.4);
  background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}

.msg-tokens-badge .token-chip {
  display: inline-flex;
  align-items: center;
}

.msg-tokens-badge .token-in {
  color: #60a5fa; /* Soft sky blue for input */
}

.msg-tokens-badge .token-out {
  color: #34d399; /* Emerald green for output */
}

.msg-tokens-badge .token-cache {
  color: #fbbf24; /* Amber / gold for cache hit */
  font-weight: 500;
}

.msg-tokens-badge .token-total {
  color: var(--text-secondary);
}

.msg-tokens-badge .token-sep {
  opacity: 0.4;
  font-size: 0.68rem;
  margin: 0 1px;
}

[data-theme="light"] .msg-tokens-badge {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}
[data-theme="light"] .msg-tokens-badge .token-in {
  color: #2563eb;
}
[data-theme="light"] .msg-tokens-badge .token-out {
  color: #059669;
}
[data-theme="light"] .msg-tokens-badge .token-cache {
  color: #d97706;
}
[data-theme="light"] .msg-tokens-badge .token-total {
  color: #334155;
}

.msg-duration-badge {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.copy-msg-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.73rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s var(--ease-spring);
}

.copy-msg-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

.copy-msg-btn.copied {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
}

/* Markdown typography & spacing */
.message-bubble p {
  margin-bottom: 1.05em;
  line-height: 1.78;
}
.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble strong,
.message-bubble b {
  font-weight: 650;
  color: var(--text-primary);
  margin: 0 1px;
}

.message-bubble ul,
.message-bubble ol {
  padding-left: 26px;
  margin: 10px 0 16px 0;
}
.message-bubble li {
  margin-bottom: 7px;
  line-height: 1.75;
}
.message-bubble li:last-child {
  margin-bottom: 0;
}
.message-bubble li > ul,
.message-bubble li > ol {
  margin: 6px 0 6px 0;
  padding-left: 22px;
}
.message-bubble li > p {
  margin-bottom: 6px;
}

.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: normal;
}
.message-bubble h1 {
  font-size: 1.42rem;
  margin-top: 1.6em;
  margin-bottom: 0.8em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  line-height: 1.4;
}
.message-bubble h2 {
  font-size: 1.25rem;
  margin-top: 1.45em;
  margin-bottom: 0.7em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  line-height: 1.4;
}
.message-bubble h3 {
  font-size: 1.12rem;
  margin-top: 1.25em;
  margin-bottom: 0.55em;
  line-height: 1.45;
}
.message-bubble h4 {
  font-size: 1.02rem;
  margin-top: 1.05em;
  margin-bottom: 0.45em;
  line-height: 1.45;
}
.message-bubble > :first-child {
  margin-top: 0 !important;
}
.message-bubble > :last-child {
  margin-bottom: 0 !important;
}

.message-bubble hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 24px 0;
  opacity: 0.65;
}

.message-bubble blockquote {
  border-left: 3px solid var(--accent-color);
  padding: 10px 18px;
  margin: 16px 0;
  color: var(--text-secondary);
  background-color: rgba(99, 102, 241, 0.05);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  line-height: 1.74;
}
.message-bubble blockquote > :last-child {
  margin-bottom: 0;
}

.message-bubble code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2.5px 7px;
  margin: 0 3px;
  background-color: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-sm);
  color: #a5b4fc;
  font-weight: 500;
  vertical-align: baseline;
}

[data-theme="light"] .message-bubble code:not(pre code) {
  background-color: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
  color: #4f46e5;
}

/* Markdown Tables */
.markdown-table-wrapper {
  width: 100%;
  margin: 18px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  min-width: 460px;
  text-align: left;
}

.message-bubble thead {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .message-bubble thead {
  background: rgba(0, 0, 0, 0.04);
}

.message-bubble th {
  padding: 10px 16px;
  font-weight: 650;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
}

.message-bubble th:last-child {
  border-right: none;
}

.message-bubble td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  color: var(--text-secondary);
  line-height: 1.62;
}

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

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

.message-bubble tbody tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

[data-theme="light"] .message-bubble tbody tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

/* Pre / Code Blocks - macOS IDE Touch */
.code-block-wrapper {
  margin: 14px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: var(--code-bg);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.code-block-wrapper:hover {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.36);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-tertiary);
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

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

.mac-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.mac-dot.red { background-color: #ff5f56; }
.mac-dot.yellow { background-color: #ffbd2e; }
.mac-dot.green { background-color: #27c93f; }

.code-lang-label {
  font-weight: 600;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-left: 4px;
}

.code-copy-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.74rem;
  padding: 3px 8px;
  border-radius: 6px;
  transition: all 0.2s var(--ease-spring);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.code-copy-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

.code-copy-btn.copied {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
}

.code-block-wrapper pre {
  margin: 0;
  padding: 14px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Streaming Cursor - Smooth Neon Pulse */
@keyframes cursorGlow {
  0%, 100% {
    opacity: 1;
    transform: scaleY(1);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.75);
  }
  50% {
    opacity: 0.3;
    transform: scaleY(0.85);
    box-shadow: 0 0 2px rgba(59, 130, 246, 0.2);
  }
}

.streaming-cursor {
  display: inline-block;
  width: 6px;
  height: 18px;
  border-radius: 3px;
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
  vertical-align: middle;
  margin-left: 5px;
  animation: cursorGlow 0.9s var(--ease-smooth) infinite;
}

/* Ensure no stray cursor ever shows after generation completes */
.message-body:not(.is-streaming) .streaming-cursor,
.message-row:not(.is-streaming) .streaming-cursor {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Floating Scroll-to-Bottom Pulse Button */
.floating-scroll-bottom-btn {
  position: absolute;
  right: calc(50% - 410px + 16px);
  bottom: 96px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(24, 24, 27, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.2);
  color: #f4f4f5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 45;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  animation: fadeIn 0.2s ease;
}

@media (max-width: 860px) {
  .floating-scroll-bottom-btn {
    right: 20px;
    bottom: 84px;
  }
}

.floating-scroll-bottom-btn:hover {
  background: rgba(39, 39, 42, 0.95);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

.floating-scroll-bottom-btn:active {
  transform: scale(0.92);
}

.scroll-new-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 1.5s infinite;
}

[data-theme="light"] .floating-scroll-bottom-btn {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  color: #18181b;
}

[data-theme="light"] .floating-scroll-bottom-btn:hover {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.22);
}

/* Input Area - Floating Glass Capsule Omnibar (Architecture C) */
.input-section {
  flex-shrink: 0;
  padding: 10px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  position: sticky;
  bottom: 0;
  z-index: 40;
}

.input-box-container {
  background: rgba(18, 18, 24, 0.92);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 26px;
  padding: 14px 18px 10px;
  box-shadow: 0 16px 44px -8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  transition: all 0.25s var(--ease-spring);
}

[data-theme="light"] .input-box-container {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.input-box-container:focus-within {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 20px 48px -6px rgba(0, 0, 0, 0.75), 0 0 0 2px rgba(99, 102, 241, 0.35);
  transform: translateY(-2px);
}

.chat-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.94rem;
  line-height: 1.6;
  max-height: 220px;
  min-height: 26px;
  letter-spacing: -0.01em;
}

.chat-textarea::placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: opacity 0.2s ease;
}

.chat-textarea:focus::placeholder {
  opacity: 0.65;
}

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .input-toolbar {
  border-top-color: rgba(0, 0, 0, 0.05);
}

/* Drag and Drop Hover */
.input-box-container.drag-over {
  border-color: var(--accent-color) !important;
  background-color: rgba(59, 130, 246, 0.06);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Attachment Preview Bar (Above Textarea) */
.attachment-preview-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--border-color);
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-primary);
  max-width: 260px;
}

.attachment-chip img.chip-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.attachment-chip .chip-icon {
  font-size: 1.1rem;
}

.attachment-chip .chip-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip .chip-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip .chip-size {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.attachment-chip .chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.9rem;
  line-height: 1;
  border-radius: 50%;
  transition: all 0.15s;
}

.attachment-chip .chip-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.attachment-chip.uploading {
  opacity: 0.7;
}

/* Toolbar Left (Attach Button) */
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-attach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-attach:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-primary);
}

.btn-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-tool:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-primary);
}

/* Message Attachments in Chat History */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.msg-attachment-img {
  max-width: 280px;
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  object-fit: cover;
  cursor: zoom-in;
  transition: transform 0.2s;
  background: #000;
}

.msg-attachment-img:hover {
  transform: scale(1.02);
}

.msg-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  transition: all 0.2s;
}

.msg-attachment-file:hover {
  border-color: var(--accent-color);
  background: rgba(59, 130, 246, 0.08);
}

.msg-attachment-file .file-icon {
  font-size: 1.4rem;
}

.msg-attachment-file .file-details {
  display: flex;
  flex-direction: column;
}

.msg-attachment-file .file-name {
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-attachment-file .file-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.input-hints {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.btn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f4f4f5;
  border: none;
  color: #09090b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: all 0.2s var(--ease-spring);
}

.btn-send:hover {
  background: #ffffff;
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.25);
}

.btn-send:active {
  transform: scale(0.93);
}

.btn-send:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.25);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
  opacity: 0.6;
}

[data-theme="light"] .btn-send {
  background: #09090b;
  color: #ffffff;
}

[data-theme="light"] .btn-send:disabled {
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.25);
}

.btn-send.stop-btn {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.45);
}

.btn-send.stop-btn:hover {
  background: #dc2626;
  transform: scale(1.05);
}

/* Modals & Overlays */
.modal-overlay,
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-overlay.active,
.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 90%;
  max-width: 500px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease-out;
}

.modal-card.wide {
  max-width: 680px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  border-radius: 4px;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 75vh;
}

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-input {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus {
  border-color: var(--accent-color);
}

.form-tip {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.form-error {
  color: #ef4444;
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background-color: rgba(239, 68, 68, 0.1);
  margin-bottom: 12px;
  display: none;
}

.form-success {
  color: #10b981;
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background-color: rgba(16, 185, 129, 0.1);
  margin-bottom: 12px;
  display: none;
}

.btn-primary {
  background-color: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

/* Tabs */
.tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
}

.tab-pane {
  display: none;
}

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

/* Switch Toggle Component */
.switch-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.switch-info h4 {
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.switch-info p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #4b5563;
  transition: .3s;
  border-radius: 26px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-color);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* User Management Table */
.users-table-container {
  overflow-x: auto;
  margin-bottom: 24px;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.users-table th, .users-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.users-table th {
  color: var(--text-muted);
  font-weight: 600;
  background-color: var(--bg-tertiary);
}

.table-action-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  margin-right: 4px;
}

.table-action-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.table-action-btn.danger:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: none;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.55);
  }

  /* Top Navbar on Mobile: Keep clean and prevent any horizontal overflow */
  .top-navbar {
    height: 48px;
    padding: 0 8px;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
  }
  .top-left {
    gap: 6px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }
  .toggle-sidebar-btn {
    padding: 6px;
    flex-shrink: 0;
  }
  .current-model-tag {
    font-size: 0.72rem;
    padding: 3px 8px;
    max-width: 130px;
    flex-shrink: 1;
  }
  .current-model-tag span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Hide crowded items on mobile topbar */
  .top-quota-pill,
  #authModeBadge,
  #btnSplitToggle {
    display: none !important;
  }

  .top-actions {
    gap: 4px;
    flex-shrink: 0;
  }
  .icon-btn {
    padding: 6px 7px;
  }
  .icon-btn span {
    display: none !important; /* Hide button text, preserve icons */
  }
  .user-badge {
    padding: 4px 7px;
  }
  .user-badge span {
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
  }

  /* Split screen mobile vertical layout */
  .chat-panes-wrapper.split-active {
    flex-direction: column !important;
  }
  .chat-panes-wrapper.split-active .pane-primary {
    width: 100% !important;
    min-width: 100% !important;
    height: 50% !important;
    border-right: none !important;
    border-bottom: 2px solid var(--border-color) !important;
  }
  .chat-panes-wrapper.split-active .pane-secondary {
    width: 100% !important;
    min-width: 100% !important;
    height: 50% !important;
    display: flex !important;
  }
  .secondary-pane-header {
    padding: 6px 10px;
  }
  .secondary-conv-select {
    max-width: 160px;
    font-size: 0.72rem;
  }

  /* Chat Messages & Bubbles */
  .chat-messages {
    padding: 10px 8px 14px;
    gap: 12px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  .welcome-screen {
    padding: 24px 12px;
    max-width: 100%;
  }
  .welcome-badge {
    font-size: 0.72rem;
    padding: 4px 10px;
    margin-bottom: 14px;
  }
  .welcome-title {
    font-size: 1.4rem;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
  }
  .welcome-subtitle {
    font-size: 0.82rem;
    margin-bottom: 20px;
    line-height: 1.5;
  }
  .suggestions-chips-wrap {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .suggestion-chip {
    padding: 10px 14px;
    border-radius: 12px;
  }
  .chip-text {
    font-size: 0.82rem;
  }
  .suggestions-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .suggestion-card {
    padding: 8px 10px;
  }
  .suggestion-card h4 {
    font-size: 0.82rem;
  }
  .suggestion-card p {
    font-size: 0.74rem;
  }
  .message-row {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  .message-avatar {
    display: none !important;
  }
  .message-bubble {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    font-size: 0.92rem;
    line-height: 1.7;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    box-sizing: border-box;
  }
  .message-row.user {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    justify-content: flex-end !important;
    margin-top: 18px;
    margin-bottom: 12px;
    padding-bottom: 0;
    border-bottom: none !important;
  }
  .message-row.user .message-bubble {
    align-self: flex-end !important;
    max-width: 88% !important;
    width: fit-content !important;
    padding: 10px 14px !important;
    border-radius: 16px 16px 4px 16px !important;
  }
  .message-row.user .message-body {
    font-size: 0.9rem !important;
    font-weight: 400 !important;
  }
  .message-row.assistant .message-bubble {
    max-width: 100% !important;
    padding: 0 !important;
    flex: 1;
    min-width: 0;
  }
  .message-bubble pre {
    max-width: 100%;
    font-size: 0.78rem;
    padding: 8px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Input Section on Mobile */
  .input-section {
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  .input-box-container {
    padding: 8px 12px;
    border-radius: 20px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  .chat-textarea {
    font-size: 16px !important; /* Prevents auto-zoom in Safari iOS */
    padding: 3px 0;
    max-height: 120px;
  }
  .input-toolbar {
    padding-top: 6px;
    gap: 6px;
  }
  .toolbar-left {
    gap: 6px;
  }
  .btn-attach span,
  .btn-tool span,
  .input-hints {
    display: none !important;
  }
  .btn-attach, .btn-tool {
    padding: 5px 8px;
    height: 32px;
  }
  .btn-send {
    width: 32px;
    height: 32px;
  }

  /* Modals on Mobile */
  .modal-overlay {
    padding: 10px;
  }
  .modal-card {
    width: 96vw;
    max-width: 96vw;
    max-height: 92vh;
    border-radius: 12px;
    margin: auto;
  }
  .file-preview-card {
    width: 96vw;
    max-width: 96vw;
    height: 92vh;
  }
  .file-preview-path {
    max-width: 140px;
  }
  .file-preview-actions .btn-tool {
    padding: 4px 6px;
    font-size: 0.72rem;
  }
  .users-table th, .users-table td {
    padding: 6px 8px;
    font-size: 0.75rem;
  }
  #addUserForm {
    grid-template-columns: 1fr !important;
  }
}

/* ========================================================
   Compact Expandable Quota Monitoring Widget
   (Consolidated into single compact bar, click to expand)
   ======================================================== */
.sidebar-quota-widget {
  margin: 8px 12px 6px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar-quota-widget:hover {
  border-color: rgba(59, 130, 246, 0.45);
}

.sidebar-quota-widget.expanded {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.quota-compact-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  gap: 8px;
  transition: background 0.15s ease;
}

.quota-compact-bar:hover {
  background: var(--bg-hover);
}

.quota-bar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.quota-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulseDot 2s infinite;
}

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

.quota-compact-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.quota-bar-center {
  flex: 1;
  min-width: 40px;
  max-width: 80px;
}

.quota-progress-track {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

[data-theme="light"] .quota-progress-track {
  background-color: rgba(0, 0, 0, 0.08);
}

.quota-progress-bar {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s;
  background: linear-gradient(90deg, #10b981, #06b6d4);
}

.quota-progress-bar.warning {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.quota-progress-bar.danger {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

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

.quota-main-percent {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.quota-key-badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.18);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 4px;
  padding: 1px 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.quota-key-badge:hover {
  background: rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
}

.btn-refresh-quota {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, transform 0.3s;
}

.btn-refresh-quota:hover {
  color: var(--text-primary);
}

.btn-refresh-quota.spinning svg {
  animation: spinIcon 0.8s linear infinite;
}

@keyframes spinIcon {
  100% { transform: rotate(360deg); }
}

.quota-chevron-icon {
  color: var(--text-muted);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.sidebar-quota-widget.expanded .quota-chevron-icon {
  transform: rotate(180deg);
  color: var(--accent-color);
}

/* Expandable Details Container */
.quota-expandable-panel {
  display: none;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.12);
  animation: fadeIn 0.2s ease-out;
}

.sidebar-quota-widget.expanded .quota-expandable-panel {
  display: block;
}

.quota-panel-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.72rem;
}

.quota-main-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.quota-reset-text {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.quota-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
}

.breakdown-name {
  color: var(--text-secondary);
}

.breakdown-pct {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.breakdown-track {
  height: 4px;
  background-color: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}

.breakdown-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
  background-color: var(--accent-color);
}

/* Tool Buttons in Input Bar */
.btn-tool {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-tool:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-color);
}

.btn-tool.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

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

.btn-stop-stream {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-stop-stream:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

/* Queue & Schedule Preview Bars */
.queue-preview-bar,
.schedule-preview-bar {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  animation: fadeIn 0.15s ease-out;
}

.queue-preview-bar {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #d97706;
}

[data-theme="dark"] .queue-preview-bar {
  color: #fbbf24;
}

.schedule-preview-bar {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent-color);
}

.bar-content {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-title {
  font-weight: 600;
}

.bar-desc {
  color: var(--text-secondary);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

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

.bar-btn {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.bar-btn:hover {
  background: currentColor;
  color: #fff;
}

/* Schedule Popover */
.schedule-popover {
  position: absolute;
  bottom: 80px;
  left: 20px;
  width: 290px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 14px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: modalIn 0.15s ease-out;
}

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

.schedule-popover-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.schedule-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.schedule-close-btn:hover {
  color: var(--text-primary);
}

.schedule-quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.schedule-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.schedule-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.schedule-custom-row {
  display: flex;
  gap: 6px;
}

.schedule-input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 6px;
  outline: none;
}

.schedule-input:focus {
  border-color: var(--accent-color);
}

.schedule-confirm-btn {
  background: var(--accent-color);
  border: none;
  color: #fff;
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.schedule-confirm-btn:hover {
  background: var(--accent-hover);
}

/* Thinking Box in Assistant Messages */
@keyframes thinkingAura {
  0%, 100% {
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.12), inset 0 0 10px rgba(168, 85, 247, 0.04);
    border-color: rgba(168, 85, 247, 0.35);
  }
  50% {
    box-shadow: 0 0 24px rgba(168, 85, 247, 0.28), inset 0 0 16px rgba(168, 85, 247, 0.08);
    border-color: rgba(168, 85, 247, 0.65);
  }
}

/* ==============================================================================
   ChatGPT Minimalist Thinking UI (Collapsible Pill + Left-Rail Stream)
   ============================================================================== */
.thinking-box {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  margin: 4px 0 10px 0 !important;
  padding: 0 !important;
  width: fit-content !important;
  max-width: 100% !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  transition: all 0.2s ease;
}

.thinking-box.expanded {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.thinking-box.active {
  background: transparent !important;
  animation: none !important;
}

.thinking-header {
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  padding: 4px 11px 4px 9px !important;
  border-radius: 9999px !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.09) !important;
  color: var(--text-muted, #9ca3af) !important;
  font-size: 0.81rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  user-select: none !important;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1) !important;
  box-shadow: none !important;
  line-height: 1.4 !important;
  width: fit-content !important;
}

.thinking-header:hover {
  background: rgba(255, 255, 255, 0.09) !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
  color: var(--text-primary, #ffffff) !important;
}

.thinking-header:active {
  transform: scale(0.98);
}

.thinking-left {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.thinking-spinner {
  width: 15px !important;
  height: 15px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  border: none !important;
  animation: none !important;
  color: var(--text-muted, #9ca3af) !important;
}

.thinking-spinner.done {
  color: var(--text-muted, #9ca3af) !important;
  border: none !important;
  animation: none !important;
}

.thinking-spinner.done .gpt-think-icon {
  opacity: 0.85;
}

.gpt-think-spinner {
  animation: gptThinkSpin 1s linear infinite !important;
  color: var(--accent-primary, #818cf8) !important;
}

@keyframes gptThinkSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.thinking-spinner.error {
  border: none !important;
  animation: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ef4444;
  font-size: 13px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  background: rgba(239, 68, 68, 0.15);
  border-radius: 50%;
}

.thinking-spinner.stopped {
  border: none !important;
  animation: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  width: 16px;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

/* Explicit Failure Card */
.message-error-card {
  margin: 10px 0;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  color: var(--text-primary);
  font-size: 0.93rem;
  line-height: 1.65;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.12);
  animation: messageSlideIn 0.25s var(--ease-spring);
}

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

.error-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 650;
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.error-card-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.error-card-body {
  color: #f87171;
  font-weight: 500;
  word-break: break-word;
  white-space: pre-wrap;
  font-family: var(--font-sans);
}

.error-card-hint {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(239, 68, 68, 0.15);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.thinking-status {
  font-weight: 500 !important;
  color: inherit !important;
  font-size: 0.81rem !important;
  letter-spacing: -0.01em !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.thinking-tag {
  font-size: 0.7rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* Expanded thinking details: sleek indented left-rail line, muted text (like ChatGPT) */
.thinking-details {
  margin: 8px 0 14px 4px !important;
  padding: 4px 0 6px 14px !important;
  border-top: none !important;
  border-left: 2px solid rgba(255, 255, 255, 0.12) !important;
  font-family: var(--font-sans) !important;
  font-size: 0.84rem !important;
  color: var(--text-secondary, #94a3b8) !important;
  max-height: 440px !important;
  overflow-y: auto !important;
  line-height: 1.75 !important;
  position: relative !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

.thinking-details::before {
  display: none !important;
}

.thinking-details p {
  margin-bottom: 8px !important;
}

.thinking-details p:last-child {
  margin-bottom: 0 !important;
}

.thinking-arrow.gpt-think-chevron {
  color: inherit !important;
  opacity: 0.55 !important;
  transition: transform 0.22s var(--ease-spring), opacity 0.2s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  flex-shrink: 0 !important;
}

.thinking-header:hover .thinking-arrow.gpt-think-chevron {
  opacity: 0.95 !important;
}

.thinking-box.expanded .thinking-arrow.gpt-think-chevron {
  transform: rotate(180deg) !important;
  opacity: 0.95 !important;
}

/* Light Theme Variables */
[data-theme="light"] .thinking-header {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: #64748b !important;
}

[data-theme="light"] .thinking-header:hover {
  background: rgba(0, 0, 0, 0.08) !important;
  border-color: rgba(0, 0, 0, 0.14) !important;
  color: #0f172a !important;
}

[data-theme="light"] .thinking-details {
  border-left-color: rgba(0, 0, 0, 0.12) !important;
  color: #475569 !important;
}

/* Argon Theme Variables */
[data-theme="argon"] .thinking-header {
  background: rgba(168, 85, 247, 0.08) !important;
  border-color: rgba(168, 85, 247, 0.22) !important;
  color: #c084fc !important;
}

[data-theme="argon"] .thinking-header:hover {
  background: rgba(168, 85, 247, 0.15) !important;
  border-color: rgba(168, 85, 247, 0.38) !important;
  color: #ffffff !important;
}

[data-theme="argon"] .thinking-details {
  border-left-color: rgba(168, 85, 247, 0.3) !important;
  color: #d8b4fe !important;
}

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

/* ========================================================
   Split Screen (Dual Panes)
   ======================================================== */
.chat-panes-wrapper {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  width: 100%;
  max-width: 100%;
  position: relative;
  overflow: hidden;
}

.chat-panes-wrapper.split-active .pane-primary {
  flex: 1;
  min-width: 320px;
  border-right: 1px solid var(--border-color);
}

.chat-panes-wrapper.split-active .pane-secondary {
  flex: 1;
  min-width: 320px;
  display: flex !important;
}

.secondary-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 10px;
}

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

.secondary-pane-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-color);
  background: rgba(59, 130, 246, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.btn-secondary-new {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent-color);
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-secondary-new:hover {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

.secondary-conv-select {
  flex: 1;
  max-width: 260px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}

.secondary-conv-select:focus {
  border-color: var(--accent-color);
}

.icon-btn-sm {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.icon-btn-sm:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.secondary-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.secondary-placeholder .placeholder-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  color: var(--accent-color);
}

.secondary-placeholder h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.secondary-placeholder p {
  font-size: 0.82rem;
  max-width: 320px;
  line-height: 1.5;
}

.secondary-box {
  background: var(--bg-secondary);
}

/* ========================================================
   Conversation Actions (Rename & Delete)
   ======================================================== */
.conversation-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, max-width 0.18s ease;
  z-index: 2;
}

.conversation-item:hover .conversation-actions {
  opacity: 1;
  max-width: 80px;
  pointer-events: auto;
}

.conversation-item.active .conversation-actions {
  pointer-events: auto;
}

.conversation-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.conversation-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.conversation-split-btn:hover {
  color: var(--accent-color);
  background: rgba(59, 130, 246, 0.15);
}

.conversation-del-btn:hover {
  color: #ef4444;
}

/* Background generating working badge in conversation sidebar */
.conv-working-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
  margin-right: 4px;
  white-space: nowrap;
  animation: pulse-border 1.8s infinite ease-in-out;
}

.badge-dot-pulse {
  width: 6px;
  height: 6px;
  background-color: #3b82f6;
  border-radius: 50%;
  animation: badge-pulse 1.2s infinite ease-in-out;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(59, 130, 246, 0.25); }
  50% { border-color: rgba(59, 130, 246, 0.7); }
}

.conversation-rename-input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--accent-color);
  color: var(--text-primary);
  font-size: 0.82rem;
  padding: 2px 6px;
  border-radius: 4px;
  outline: none;
  min-width: 0;
}

/* ========================================================
   File Preview Modal & Inline Link
   ======================================================== */
.file-preview-card {
  max-width: 1440px;
  width: 96vw;
  height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.file-preview-card.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  margin: 0 !important;
  border-radius: 0 !important;
  z-index: 99999 !important;
}

.file-preview-card.is-fullscreen .file-preview-body {
  height: calc(100vh - 56px) !important;
  max-height: calc(100vh - 56px) !important;
  padding: 0 !important;
}

.file-preview-card.is-fullscreen .preview-doc-render {
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  height: 100% !important;
}

.file-preview-card.is-fullscreen .preview-doc-render iframe {
  height: calc(100vh - 56px) !important;
  border-radius: 0 !important;
  border: none !important;
}

.file-preview-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.file-preview-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.file-preview-path {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 360px;
  display: block;
}

.file-preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.file-preview-view-tabs {
  display: inline-flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: 6px;
  padding: 2px;
  border: 1px solid var(--border-color);
  gap: 2px;
}

.file-preview-view-tabs .btn-tool {
  border: none;
  background: transparent;
  padding: 4px 9px;
  font-size: 0.75rem;
  border-radius: 4px;
}

.file-preview-view-tabs .btn-tool.active {
  background: var(--bg-secondary);
  color: var(--accent-color);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.file-preview-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background: var(--bg-primary);
  min-width: 0;
  box-sizing: border-box;
}

.preview-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.preview-doc-render {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 24px 28px;
  color: var(--text-primary);
  line-height: 1.8;
  font-size: 0.95rem;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  white-space: normal !important;
  max-width: 100%;
  box-sizing: border-box;
}

.preview-doc-render iframe {
  width: 100%;
  height: 80vh;
  border: none;
  border-radius: 8px;
  background: #ffffff;
  display: block;
}

.preview-doc-render h1,
.preview-doc-render h2,
.preview-doc-render h3,
.preview-doc-render h4,
.preview-doc-render p,
.preview-doc-render li,
.preview-doc-render blockquote {
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
}

.preview-doc-render pre {
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 14px 0;
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.preview-code {
  margin: 0;
  padding: 18px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--text-primary);
  overflow-x: auto;
  overflow-y: auto;
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  max-width: 100%;
  box-sizing: border-box;
}

.preview-code.no-wrap {
  white-space: pre !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
}

.preview-code code {
  white-space: inherit !important;
  word-break: inherit !important;
  overflow-wrap: inherit !important;
  display: block;
  max-width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}

.preview-img-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  padding: 20px;
}

.preview-img-container img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.preview-error {
  padding: 16px;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 6px;
  font-size: 0.85rem;
}

/* In-message file reference link badge */
.file-preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.32);
  color: #60a5fa;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  vertical-align: middle;
  margin: 0 3px;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.file-preview-badge:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
  color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(59, 130, 246, 0.28);
}

.file-preview-badge:active {
  transform: translateY(0);
}

.file-preview-badge .badge-icon {
  font-size: 0.85rem;
}

.file-preview-badge .badge-name {
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(96, 165, 250, 0.35);
}

.file-preview-badge .badge-action {
  font-size: 0.7rem;
  background: rgba(59, 130, 246, 0.25);
  color: #dbeafe;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 2px;
}

/* ========================================================
   Sidebar Bottom Settings Button & Pill Badge
   ======================================================== */
.sidebar-bottom-bar {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.sidebar-settings-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
}

.sidebar-settings-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

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

.settings-pill-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  letter-spacing: 0.02em;
}

/* ========================================================
   Settings & Plugins Modal & Tabs
   ======================================================== */
.settings-modal-card {
  max-width: 1040px;
  width: 95%;
  height: 88vh;
  max-height: 880px;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.settings-modal-icon {
  font-size: 1.4rem;
}

.settings-modal-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.settings-tabs-nav {
  display: flex;
  gap: 8px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(10px);
}

.settings-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.settings-tab-btn:hover {
  color: var(--text-primary);
}

.settings-tab-btn.active {
  color: #60a5fa;
  border-bottom-color: #3b82f6;
}

.settings-tab-btn .tab-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.settings-tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.settings-tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ========================================================
   Skills Tab: List, Toolbar, Switches
   ======================================================== */
.skills-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.skills-search-box {
  flex: 1;
  max-width: 380px;
  position: relative;
  display: flex;
  align-items: center;
}

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

.skills-search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  transition: all 0.2s;
}

.skills-search-box input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.skills-actions {
  display: flex;
  gap: 8px;
}

.btn-subtle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-subtle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-color);
}

.btn-subtle-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.74rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-subtle-sm:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-color);
}

.skills-tip-banner {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.8rem;
  color: #93c5fd;
  margin-bottom: 16px;
  line-height: 1.5;
}

.skills-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(390px, 1fr));
  gap: 14px;
}

.skill-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s var(--ease-spring);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}

.skill-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.skill-card.disabled {
  opacity: 0.65;
  background: rgba(255, 255, 255, 0.02);
}

.skill-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.skill-title-block {
  flex: 1;
  min-width: 0;
}

.skill-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.skill-display-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.skill-code-tag {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  padding: 1px 6px;
  border-radius: 5px;
  color: #cbd5e1;
}

.skill-category-badge {
  font-size: 0.66rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.skill-category-badge.builtin {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.skill-category-badge.custom {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.skill-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.skill-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.skill-detail-link {
  font-size: 0.74rem;
  color: var(--accent-color);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.15s;
}

.skill-detail-link:hover {
  text-decoration: underline;
  color: #60a5fa;
}

/* iOS Style Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.25s var(--ease-spring);
  border-radius: 24px;
  border: 1px solid var(--border-color);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.25s var(--ease-spring);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ========================================================
   Token Analytics & Calendar Tab
   ======================================================== */
/* ========================================================
   Token Analytics & Calendar Tab
   ======================================================== */
.token-analytics-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 20px;
}

/* 1. Top: Calendar Card */
.calendar-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}

.calendar-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.calendar-nav-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cal-nav-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.cal-nav-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-color);
  color: #3b82f6;
}

.cal-month-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.calendar-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cal-header-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: 8px;
}

.cal-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.cal-stat-value {
  font-size: 0.88rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #60a5fa;
}

.cal-today-btn {
  padding: 5px 12px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #60a5fa;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.cal-today-btn:hover {
  background: #3b82f6;
  color: #fff;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 6px 0 8px;
  border-bottom: 1px solid var(--border-color);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.cal-day-cell {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  position: relative;
  transition: all 0.18s var(--ease-spring);
  padding: 5px 4px;
}

.cal-day-cell.empty {
  cursor: default;
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}

.cal-day-cell:hover:not(.empty) {
  background: var(--bg-hover);
  border-color: rgba(99, 102, 241, 0.35);
  transform: translateY(-2px);
  z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.cal-day-cell.today {
  border-color: rgba(96, 165, 250, 0.4);
  background: rgba(59, 130, 246, 0.05);
}

.cal-day-cell.today .day-number {
  color: #60a5fa;
  font-weight: 800;
}

.cal-day-cell.selected {
  border-color: #3b82f6 !important;
  background: rgba(59, 130, 246, 0.16) !important;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.35);
  transform: translateY(-2px) scale(1.02);
  z-index: 3;
}

.cal-day-cell.selected .day-number {
  color: #93c5fd;
}

.day-number {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1;
}

.day-token-pill {
  font-size: 0.62rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  margin-top: 4px;
  line-height: 1;
  white-space: nowrap;
}

.day-token-pill.level-1 {
  background: rgba(6, 182, 212, 0.2);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.day-token-pill.level-2 {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.45);
}

.day-token-pill.level-3 {
  background: rgba(168, 85, 247, 0.3);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.5);
}

.calendar-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  margin-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.legend-right {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.level-0 { background: rgba(255, 255, 255, 0.15); }
.legend-dot.level-1 { background: #06b6d4; }
.legend-dot.level-2 { background: #3b82f6; }
.legend-dot.level-3 { background: #a855f7; }

/* 2. Middle: Token Trend Line Chart Card */
.trend-chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.chart-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-header-title svg {
  color: #3b82f6;
}

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

.chart-badge-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.chart-badge-line .badge-dot {
  width: 14px;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
  border-radius: 2px;
}

.chart-badge-peak {
  font-size: 0.74rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: #c084fc;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
}

.chart-wrapper {
  width: 100%;
  height: 200px;
  position: relative;
}

.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-grid-line {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-mono);
}

.chart-line-path {
  fill: none;
  stroke: url(#tokenLineGrad);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area-path {
  fill: url(#tokenAreaGrad);
}

.chart-point-dot {
  fill: #3b82f6;
  stroke: #ffffff;
  stroke-width: 2;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chart-point-dot:hover {
  r: 7;
  fill: #8b5cf6;
  stroke: #ffffff;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.8));
}

.chart-point-dot.selected {
  r: 7;
  fill: #8b5cf6;
  stroke: #60a5fa;
  stroke-width: 3;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.9));
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -120%);
  transition: opacity 0.15s ease;
  z-index: 10;
}

.chart-tooltip-title {
  font-weight: 700;
  color: #93c5fd;
  margin-bottom: 2px;
}

.chart-tooltip-val {
  font-family: var(--font-mono);
  color: #fff;
}

/* 3. Bottom: Analytics Detail Card */
.analytics-detail-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

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

.detail-date-badge {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.detail-date-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.kpi-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.kpi-value.primary {
  background: linear-gradient(135deg, #60a5fa 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.kpi-sub {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.detail-split-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
}

.analytics-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.model-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.model-breakdown-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.15s;
}

.model-breakdown-item:hover {
  border-color: rgba(99, 102, 241, 0.35);
}

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

.model-item-name {
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-item-stats {
  font-size: 0.76rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.model-item-tokens {
  font-weight: 700;
  color: #60a5fa;
}

.model-progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.model-progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
  transition: width 0.4s var(--ease-spring);
}

.model-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.aggregate-strip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.agg-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
}

.agg-label {
  color: var(--text-muted);
}

.agg-val {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 700;
}

.skill-detail-modal-card {
  max-width: 780px;
  width: 90%;
  max-height: 80vh;
}

.skill-detail-body {
  overflow-y: auto;
  max-height: 60vh;
  padding: 18px;
}

@media (max-width: 920px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .detail-split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .calendar-header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .cal-day-cell {
    min-height: 44px;
  }
  .day-token-pill {
    font-size: 0.55rem;
    padding: 1px 3px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .skills-list {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Subscription & Model Market Management (Task 4 - Redesigned UI)
   ========================================================================== */
.sub-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 6px 0;
}

.sub-budget-card,
.sub-channels-card,
.sub-models-card {
  background: linear-gradient(180deg, rgba(22, 22, 27, 0.75) 0%, rgba(15, 15, 19, 0.85) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.45), inset 0 1px 0 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.25s var(--ease-smooth);
}

.sub-budget-card:hover,
.sub-channels-card:hover,
.sub-models-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.sub-budget-header,
.sub-channels-header,
.sub-models-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.sub-budget-title-box,
.sub-channels-title-box,
.sub-models-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sub-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  font-size: 1.25rem;
  line-height: 1;
}

.sub-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.sub-card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Status Badge with Glowing Dot */
.sub-budget-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.12);
  transition: all 0.3s ease;
}

.sub-budget-status-badge.blocked {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.2);
}

.guard-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulse-guard-dot 2s infinite ease-in-out;
}

@keyframes pulse-guard-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}

/* Telemetry KPI Metrics Grid */
.sub-budget-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.sub-budget-metrics .metric-block {
  background: rgba(10, 10, 13, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s, background 0.2s;
}

.sub-budget-metrics .metric-block:hover {
  background: rgba(18, 18, 24, 0.7);
  border-color: rgba(255, 255, 255, 0.1);
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.metric-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
}

.metric-value.spent-val {
  color: #fbbf24;
  text-shadow: 0 0 16px rgba(251, 191, 36, 0.2);
}

.metric-value.limit-val {
  color: #818cf8;
  text-shadow: 0 0 16px rgba(129, 140, 248, 0.2);
}

.metric-value.remain-val {
  color: #34d399;
  text-shadow: 0 0 16px rgba(52, 211, 153, 0.2);
}

.progress-block {
  justify-content: center;
}

.sub-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  position: relative;
}

.sub-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #6366f1 60%, #f59e0b 85%, #ef4444 100%);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.35);
}

/* Quick Adjust Action Row */
.sub-budget-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.quick-adjust-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.adjust-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-quick-raise {
  font-weight: 700 !important;
  color: #a5b4fc !important;
  background: rgba(99, 102, 241, 0.1) !important;
  border: 1px solid rgba(99, 102, 241, 0.28) !important;
  padding: 5px 12px !important;
  border-radius: 8px !important;
  font-size: 0.78rem !important;
  transition: all 0.18s var(--ease-smooth) !important;
}

.btn-quick-raise:hover {
  background: rgba(99, 102, 241, 0.22) !important;
  color: #ffffff !important;
  border-color: rgba(99, 102, 241, 0.55) !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.25) !important;
}

.btn-quick-raise:active {
  transform: translateY(0);
}

.custom-limit-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-limit-group input {
  width: 140px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(10, 10, 13, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font-mono);
  outline: none;
  transition: all 0.2s;
}

.custom-limit-group input:focus {
  border-color: var(--brand-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Upstream Channels Grid */
.sub-channels-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.sub-channel-item {
  background: rgba(10, 10, 13, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.22s var(--ease-smooth);
}

.sub-channel-item:hover {
  background: rgba(16, 16, 22, 0.75);
  border-color: rgba(99, 102, 241, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.sub-channel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sub-channel-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sub-channel-type-badge {
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.14);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.sub-channel-item.disabled {
  opacity: 0.52;
  background: rgba(10, 10, 13, 0.35);
  border-color: rgba(255, 255, 255, 0.04);
  filter: grayscale(0.2);
}

.sub-channel-item.disabled:hover {
  opacity: 0.75;
  border-color: rgba(255, 255, 255, 0.1);
  transform: none;
}

.sub-channel-item.disabled .sub-channel-name {
  color: var(--text-muted);
}

/* Custom iOS/Shadcn Slider Switch for Channel Status */
.sub-channel-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.sub-channel-switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 18px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  position: relative;
  outline: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  flex-shrink: 0;
}

.sub-channel-switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sub-channel-switch input[type="checkbox"]:checked {
  background: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
}

.sub-channel-switch input[type="checkbox"]:checked::after {
  transform: translateX(14px);
}

.channel-switch-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.2s;
  min-width: 36px;
}

.sub-channel-item:not(.disabled) .channel-switch-label {
  color: #34d399;
}

.channel-pill.channel-off {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  text-decoration: line-through;
  opacity: 0.65;
}

.latency-badge {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.latency-badge.fast {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.latency-badge.medium {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.28);
}

.latency-badge.slow {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.latency-badge.untested {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sub-channel-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sub-channel-base-url {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.btn-primary-outline {
  background: rgba(99, 102, 241, 0.12) !important;
  color: #a5b4fc !important;
  border: 1px solid rgba(99, 102, 241, 0.35) !important;
  font-weight: 600 !important;
}

.btn-primary-outline:hover {
  background: #6366f1 !important;
  color: #ffffff !important;
  border-color: #6366f1 !important;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.35) !important;
}

/* Modality Category Filter Pills (Segment Control) */
.sub-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  background: rgba(10, 10, 13, 0.6);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.cat-pill {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease-smooth);
}

.cat-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.cat-pill.active {
  background: #6366f1;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.sub-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 10, 13, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 12px;
  transition: border-color 0.2s;
}

.sub-search-box:focus-within {
  border-color: var(--brand-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.sub-search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  width: 200px;
}

.sub-models-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Models Grid & High-End Cards */
.sub-models-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.sub-model-card {
  background: rgba(12, 12, 16, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.24s var(--ease-smooth);
  position: relative;
  overflow: hidden;
}

.sub-model-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.5), transparent);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sub-model-card:hover {
  background: rgba(18, 18, 24, 0.85);
  border-color: rgba(99, 102, 241, 0.38);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px -4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.sub-model-card:hover::before {
  opacity: 1;
}

.sub-model-card.disabled {
  opacity: 0.55;
  filter: grayscale(0.2);
}

.sub-model-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sub-model-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sub-model-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sub-model-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sub-model-provider {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.merged-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.18));
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.15);
}

/* Custom iOS/Shadcn Slider Switch for Model Toggle */
.sub-model-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.sub-model-switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  position: relative;
  outline: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  flex-shrink: 0;
}

.sub-model-switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sub-model-switch input[type="checkbox"]:checked {
  background: #6366f1;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.sub-model-switch input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

.switch-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  transition: color 0.2s;
}

.sub-model-card:not(.disabled) .switch-label {
  color: #a5b4fc;
}

.sub-model-desc {
  font-size: 0.77rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sub-model-modalities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modality-badge {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.modality-badge:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.modality-badge.ctx {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
  font-weight: 600;
}

.sub-model-pricing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.pricing-rates {
  font-size: 0.76rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.pricing-rates span {
  color: var(--text-primary);
  font-weight: 600;
}

.discount-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(239, 68, 68, 0.16));
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.12);
}

.channel-routes {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.channel-pill {
  font-size: 0.66rem;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.channel-pill.has-key {
  color: #34d399;
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}

/* Modal Form Styles */
.modal-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.modal-form-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.modal-form-input,
.modal-form-select {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(10, 10, 13, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}

.modal-form-input:focus,
.modal-form-select:focus {
  border-color: var(--brand-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

@media (max-width: 900px) {
  .sub-budget-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .sub-channels-grid {
    grid-template-columns: 1fr;
  }
  .sub-models-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================================
   PWA & Mobile Standalone / Touch Optimizations
   ======================================================== */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* Standalone Native App Mode (when installed to home screen) */
.is-pwa-standalone .top-navbar {
  padding-top: max(var(--sat), 10px) !important;
  height: calc(52px + max(var(--sat), 0px)) !important;
}

.is-pwa-standalone .input-section {
  padding-bottom: max(var(--sab), 12px) !important;
}

/* Prevent Pull-to-refresh rubber banding on iOS/Android */
body {
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

.chat-messages {
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

/* Mobile Touch Target Expansion */
@media (max-width: 768px) {
  .btn-attach, .btn-tool {
    padding: 6px 10px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 9px !important;
    touch-action: manipulation;
  }
  .btn-send {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    touch-action: manipulation;
  }
  .toggle-sidebar-btn {
    padding: 8px 10px !important;
    min-height: 38px !important;
    min-width: 38px !important;
    touch-action: manipulation;
  }
  .btn-attach:active, .btn-tool:active, .btn-send:active, .toggle-sidebar-btn:active {
    transform: scale(0.92);
    transition: transform 0.08s ease;
  }
}

/* PWA Install Banner Floating Widget */
.pwa-install-banner {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: 12px;
  right: 12px;
  max-width: 480px;
  margin: 0 auto;
  z-index: 9999;
  background: rgba(18, 18, 24, 0.94);
  border: 1px solid rgba(99, 102, 241, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 20px rgba(99, 102, 241, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: pwaBannerSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="light"] .pwa-install-banner {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

@keyframes pwaBannerSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.pwa-banner-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.pwa-banner-text {
  min-width: 0;
  flex: 1;
}

.pwa-banner-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}

.pwa-banner-desc {
  font-size: 0.74rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pwa-btn-install {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  background: var(--accent-color);
  color: #ffffff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
  transition: all 0.15s ease;
}

.pwa-btn-install:active {
  transform: scale(0.95);
}

.pwa-btn-dismiss {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 6px;
}

.pwa-btn-dismiss:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* iOS Safari Install Tutorial Sheet */
.ios-install-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 calc(10px + env(safe-area-inset-bottom, 0px)) 0;
  animation: fadeIn 0.2s ease forwards;
}

.ios-install-card {
  width: 94vw;
  max-width: 440px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  animation: pwaBannerSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ios-install-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.ios-install-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.ios-install-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.ios-install-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.ios-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ios-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent-color);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}


/* ========================================================
   Multimodal Global Drag & Drop Overlay
   ======================================================== */
.global-drop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: fadeIn 0.15s ease;
}

.drop-overlay-content {
  border: 2px dashed rgba(99, 102, 241, 0.6);
  border-radius: 24px;
  background: rgba(99, 102, 241, 0.08);
  padding: 48px 64px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 40px rgba(99, 102, 241, 0.1);
  transform: scale(1.02);
  transition: transform 0.2s ease;
}

.drop-overlay-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: bounce 1s infinite alternate ease-in-out;
}

.drop-overlay-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
  letter-spacing: -0.015em;
}

.drop-overlay-subtitle {
  font-size: 0.92rem;
  color: #a1a1aa;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

/* ========================================================
   Export & Share Modal
   ======================================================== */
.export-modal-card {
  max-width: 520px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(18, 18, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.7);
  padding: 24px;
  margin: auto;
}

[data-theme="light"] .export-modal-card {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 24px 50px -10px rgba(0, 0, 0, 0.12);
}

.export-summary-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 16px 0 20px;
}

[data-theme="light"] .export-summary-box {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

.export-summary-title {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-summary-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.export-options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.export-option-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  width: 100%;
}

[data-theme="light"] .export-option-btn {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

.export-option-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .export-option-btn:hover {
  background: #f8fafc;
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

.export-opt-icon {
  font-size: 1.4rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  flex-shrink: 0;
}

.export-opt-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-opt-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.export-opt-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.export-opt-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.export-toast-feedback {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  animation: fadeIn 0.2s ease;
}

/* ========================================================
   Enhanced Image Lightbox Modal with Zoom & Pan & Rotation
   ======================================================== */
.image-lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(7, 8, 12, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.lightbox-toolbar {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(18, 18, 24, 0.75);
  backdrop-filter: blur(12px);
  z-index: 2;
  user-select: none;
}

.lightbox-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 45%;
}

.lightbox-file-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.lightbox-filename {
  font-size: 0.88rem;
  color: #f4f4f5;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-meta-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  font-size: 0.72rem;
  color: #a1a1aa;
  font-family: var(--font-mono, monospace);
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lightbox-zoom-group {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 2px;
}

.lightbox-level-btn {
  border: none;
  background: transparent;
  color: #e4e4e7;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 54px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono, monospace);
  transition: all 0.15s ease;
}

.lightbox-level-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lightbox-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f4f4f5;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
  transform: translateY(-1px);
}

.lightbox-btn:active {
  transform: translateY(0);
}

.lightbox-btn-close:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.lightbox-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
}

.lightbox-canvas {
  position: absolute;
  transform-origin: center center;
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: none;
}

.lightbox-canvas img {
  max-width: none;
  max-height: none;
  pointer-events: none;
  border-radius: 8px;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.85);
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-tip-bar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  background: rgba(18, 18, 24, 0.8);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s ease;
  white-space: nowrap;
  z-index: 2;
}

/* ========================================================
   Chat Message Image Cards & Zoom UI
   ======================================================== */
.chat-image-card {
  margin: 12px 0;
  display: inline-block;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  cursor: zoom-in;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  text-align: left;
}

.chat-image-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.chat-image-box {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 480px;
  background: rgba(0, 0, 0, 0.06);
}

.chat-markdown-img {
  display: block;
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  cursor: zoom-in;
  border-radius: 6px;
  transition: transform 0.25s ease;
}

.chat-image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.chat-image-card:hover .chat-image-overlay {
  opacity: 1;
}

.chat-image-zoom-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(18, 18, 24, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transform: scale(0.92);
  transition: transform 0.2s ease;
}

.chat-image-card:hover .chat-image-zoom-pill {
  transform: scale(1);
}

.chat-image-caption {
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Also style any raw img tag inside message bodies or thinking blocks */
.message-body img,
.thinking-details-content img,
.markdown-body img {
  cursor: zoom-in !important;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.message-body img:hover,
.thinking-details-content img:hover,
.markdown-body img:hover {
  transform: scale(1.015);
  border-color: var(--accent-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

/* ========================================================
   Print / PDF Export Media Styles
   ======================================================== */
@media print {
  body.print-hide-thinking .thinking-box,
  body.print-hide-thinking .thinking-details,
  body.print-hide-thinking .thinking-stepper-container,
  body.print-hide-thinking .thinking-stepper-header,
  body.print-hide-thinking .thinking-stepper-body {
    display: none !important;
  }
  .sidebar,
  .top-navbar,
  .input-section,
  .floating-scroll-bottom-btn,
  .modal-backdrop,
  .modal-overlay,
  .pwa-install-banner,
  .user-dropdown,
  .code-copy-btn,
  .copy-msg-btn,
  .message-footer {
    display: none !important;
  }
  body, .app-container, .main-chat, .chat-pane, .chat-messages {
    background: #ffffff !important;
    color: #111827 !important;
    height: auto !important;
    overflow: visible !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .message-row.user {
    border-bottom: 2px solid #e5e7eb !important;
    margin-top: 24px !important;
    page-break-after: avoid;
  }
  .message-row.user .message-body {
    color: #111827 !important;
    font-size: 1.3rem !important;
  }
  .message-row.assistant .message-bubble {
    color: #374151 !important;
    font-size: 1rem !important;
    line-height: 1.7 !important;
  }
  .thinking-box {
    border-left: 2px solid #d1d5db !important;
    background: #f9fafb !important;
    color: #6b7280 !important;
    page-break-inside: avoid;
  }
  .code-block-wrapper {
    border: 1px solid #e5e7eb !important;
    background: #f3f4f6 !important;
    page-break-inside: avoid;
  }
  .code-block-wrapper pre {
    color: #111827 !important;
  }
}


/* ==========================================================================
   Thinking Stepper Accordion Component (Claude 3.7 / 4o Progressive Stepper)
   ========================================================================== */
.thinking-stepper-box {
  background: var(--bg-tertiary, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
  margin: 10px 0 16px 0;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.thinking-stepper-box.active {
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.12);
}

.thinking-stepper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  transition: background 0.15s ease;
}

.thinking-stepper-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.thinking-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary, #9ca3af);
  min-width: 0;
}

.thinking-status-text {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary, #e5e7eb);
}

.thinking-duration-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  font-family: var(--font-mono, monospace);
  font-weight: 600;
}

.thinking-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-tertiary, #6b7280);
  font-size: 0.78rem;
  flex-shrink: 0;
}

.thinking-chevron {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.thinking-stepper-box.is-collapsed .thinking-chevron {
  transform: rotate(-90deg);
}

.thinking-stepper-box:not(.is-collapsed) .thinking-chevron {
  transform: rotate(0deg);
}

.thinking-stepper-body {
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.15);
  font-size: 0.86rem;
  line-height: 1.6;
  max-height: 480px;
  overflow-y: auto;
}

.thinking-details-content {
  color: var(--text-secondary, #9ca3af);
}

.thinking-details-content p:last-child {
  margin-bottom: 0;
}

.thinking-spinner.pulse {
  display: inline-block;
  color: #818cf8;
  animation: thinkingPulse 1.2s infinite ease-in-out;
}

@keyframes thinkingPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.thinking-spinner.done {
  color: #10b981;
  font-weight: 700;
}

.thinking-spinner.error {
  color: #ef4444;
  font-weight: 700;
}


/* ==========================================================================
   Header Export Button & Selective Export Modal Enhancements
   ========================================================================== */
.header-export-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  height: 34px !important;
  padding: 0 12px !important;
  border-radius: 9px !important;
  background: rgba(99, 102, 241, 0.15) !important;
  border: 1px solid rgba(99, 102, 241, 0.38) !important;
  color: #c7d2fe !important;
  font-size: 0.84rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  user-select: none !important;
}

.header-export-btn span.btn-text {
  display: inline-block !important;
  font-size: 0.84rem !important;
}

.header-export-btn:hover {
  background: rgba(99, 102, 241, 0.28) !important;
  border-color: rgba(99, 102, 241, 0.65) !important;
  color: #ffffff !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25) !important;
}

.welcome-action-btn:hover {
  background: rgba(99, 102, 241, 0.24) !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
  color: #ffffff !important;
  transform: translateY(-1px) !important;
}


/* ==========================================================================
   Export Message Selection & Multi-Format Options Grid
   ========================================================================== */
.export-scope-container {
  background: var(--bg-secondary, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.export-section-subtitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary, #e5e7eb);
  margin-bottom: 10px;
}

.export-scope-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary, #9ca3af);
  font-weight: normal;
}

.export-options-toggle-bar {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
}

[data-theme="light"] .export-options-toggle-bar {
  border-top-color: rgba(0, 0, 0, 0.08);
}

.export-thinking-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary, #9ca3af);
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

.export-thinking-toggle-label:hover {
  color: var(--text-primary, #e5e7eb);
}

.export-thinking-toggle-label input[type="checkbox"] {
  accent-color: #6366f1;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.export-thinking-toggle-label .toggle-subtext {
  font-size: 0.72rem;
  color: var(--text-muted, #71717a);
  margin-left: 4px;
}

.msg-select-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 8px;
}

.msg-select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary, #d1d5db);
  cursor: pointer;
  user-select: none;
}

.msg-select-right {
  display: flex;
  gap: 6px;
}

.select-tool-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary, #9ca3af);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.select-tool-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.4);
}

.msg-select-scroll-area {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

.msg-select-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  transition: background 0.15s ease;
  user-select: none;
}

.msg-select-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.msg-select-role {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.role-user {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
}

.role-assistant {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

.msg-select-snippet {
  font-size: 0.78rem;
  color: var(--text-secondary, #9ca3af);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.msg-select-time {
  font-size: 0.7rem;
  color: var(--text-tertiary, #6b7280);
  flex-shrink: 0;
}

/* Format Card Accents */
.badge-excel {
  background: rgba(16, 185, 129, 0.18) !important;
  color: #10b981 !important;
  border-color: rgba(16, 185, 129, 0.3) !important;
}

.badge-word {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #3b82f6 !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
}

.badge-ppt {
  background: rgba(249, 115, 22, 0.18) !important;
  color: #f97316 !important;
  border-color: rgba(249, 115, 22, 0.3) !important;
}

.badge-image {
  background: rgba(236, 72, 153, 0.18) !important;
  color: #ec4899 !important;
  border-color: rgba(236, 72, 153, 0.3) !important;
}

/* ==========================================================================
   AI Works Workbench: Core Layout, Distraction-Free Styling & Canvas
   ========================================================================== */

/* 1. Sidebar Time Group Header */
.conv-group-header {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 14px 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}

/* 2. Top Quota Monitoring Progress Bar */
.quota-monitor-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  flex-shrink: 0;
  z-index: 15;
}

.quota-top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.quota-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: quotaPulse 2s infinite ease-in-out;
}

@keyframes quotaPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.quota-title-text {
  font-weight: 600;
  color: var(--text-primary);
}

.quota-percent-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.quota-percent-badge.warning {
  background: rgba(245, 158, 11, 0.14);
  color: #f59e0b;
}

.quota-percent-badge.danger {
  background: rgba(239, 68, 68, 0.14);
  color: #ef4444;
}

.quota-top-progress-wrap {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.quota-top-track {
  flex: 1;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

[data-theme="dark"] .quota-top-track {
  background: rgba(255, 255, 255, 0.1);
}

.quota-top-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #10b981, #6366f1);
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.quota-reset-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.quota-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.quota-auto-timer {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.quota-refresh-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.quota-refresh-pill-btn:hover {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
  border-color: rgba(99, 102, 241, 0.3);
}

.quota-refresh-pill-btn.loading svg {
  animation: spin 0.8s linear infinite;
}

/* 3. Collaborative Dual-Screen Canvas Layout */
.chat-panes-wrapper {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: var(--bg-primary);
}

/* 3. Collaborative Dual-Screen Canvas Layout (Freely Resizable, Default 20% Canvas) */
.chat-panes-wrapper {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: var(--bg-primary);
}

/* Chat Stream & AI Reply Pane (Flex 1, fills rest of space ~80% by default) */
.chat-pane.pane-primary {
  flex: 1 1 0;
  min-width: 280px;
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* Draggable Splitter Divider between AI Chat Stream and Canvas */
.pane-resizer-divider {
  width: 9px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
  touch-action: none;
  transition: background 0.15s ease;
}

.pane-resizer-divider:hover,
.pane-resizer-divider.dragging {
  background: rgba(99, 102, 241, 0.12);
}

.pane-resizer-divider .resizer-handle-grip {
  width: 2px;
  height: 100%;
  background: var(--border-color);
  transition: all 0.15s ease;
  position: relative;
}

.pane-resizer-divider:hover .resizer-handle-grip,
.pane-resizer-divider.dragging .resizer-handle-grip {
  width: 3px;
  background: var(--accent-color);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.6);
}

.pane-resizer-divider .resizer-handle-grip::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 28px;
  border-radius: 4px;
  background: var(--border-color);
  transition: all 0.15s ease;
}

.pane-resizer-divider:hover .resizer-handle-grip::after,
.pane-resizer-divider.dragging .resizer-handle-grip::after {
  background: var(--accent-color);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.6);
}

/* Body state during drag */
body.is-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.is-resizing * {
  user-select: none !important;
}

/* Right Artifact / Canvas Panel (Default 20% width, min-width 200px, max-width 85%) */
.artifact-canvas-panel {
  width: var(--canvas-width, 20%);
  min-width: 200px;
  max-width: 85%;
  flex-shrink: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.03);
  position: relative;
  overflow: hidden;
  container-type: inline-size;
  container-name: canvas-panel;
}

/* When Canvas is collapsed */
.chat-panes-wrapper.canvas-collapsed .artifact-canvas-panel,
.chat-panes-wrapper.canvas-collapsed .pane-resizer-divider {
  display: none !important;
}

.chat-panes-wrapper.canvas-collapsed .chat-pane.pane-primary {
  width: 100% !important;
  max-width: 100% !important;
}

.chat-panes-wrapper.canvas-collapsed .chat-messages {
  max-width: 100% !important;
  margin: 0 !important;
  width: 100% !important;
  padding-left: clamp(24px, 4vw, 72px) !important;
  padding-right: clamp(24px, 4vw, 72px) !important;
}

.chat-panes-wrapper.canvas-collapsed .floating-composer-card {
  max-width: 860px;
}

/* Canvas Panel Header - Adaptive Layout preventing UI clashing */
.canvas-panel-header {
  height: 48px;
  min-height: 48px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  user-select: none;
  overflow: hidden;
  transition: height 0.2s ease, min-height 0.2s ease;
}

.canvas-panel-title-area {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.canvas-panel-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.canvas-panel-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.canvas-artifact-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-color);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.canvas-artifact-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Canvas Tabs Switcher */
.canvas-tabs-switcher {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  gap: 2px;
  flex-shrink: 0;
}

.canvas-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.canvas-tab-btn:hover {
  color: var(--text-primary);
}

.canvas-tab-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Canvas Actions */
.canvas-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.canvas-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.canvas-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.canvas-icon-btn.btn-close-canvas {
  padding: 5px 8px;
  font-size: 0.85rem;
  line-height: 1;
}

/* ==========================================================================
   Container Queries & Class Fallbacks: Prevent Canvas Header UI Collision on Narrow Widths
   ========================================================================== */
.artifact-canvas-panel.canvas-narrow .canvas-artifact-badge,
@container canvas-panel (max-width: 580px) {
  .canvas-artifact-badge {
    display: none !important;
  }
  .canvas-icon-btn span {
    display: none !important;
  }
  .canvas-icon-btn {
    padding: 5px 6px !important;
  }
  .canvas-tab-btn {
    padding: 4px 7px !important;
    font-size: 0.74rem !important;
  }
}

.artifact-canvas-panel.canvas-narrow .canvas-panel-header {
  height: auto !important;
  min-height: 76px !important;
  flex-wrap: wrap !important;
  padding: 6px 8px 8px !important;
  gap: 6px !important;
}
.artifact-canvas-panel.canvas-narrow .canvas-panel-title-area {
  order: 1 !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
}
.artifact-canvas-panel.canvas-narrow .canvas-actions {
  order: 2 !important;
  margin-left: auto !important;
  gap: 4px !important;
}
.artifact-canvas-panel.canvas-narrow .canvas-icon-btn span {
  display: none !important;
}
.artifact-canvas-panel.canvas-narrow .canvas-tabs-switcher {
  order: 3 !important;
  width: 100% !important;
  margin-top: 2px !important;
  display: flex !important;
  gap: 2px !important;
}
.artifact-canvas-panel.canvas-narrow .canvas-tab-btn {
  flex: 1 1 0% !important;
  justify-content: center !important;
  padding: 4px 4px !important;
  font-size: 0.72rem !important;
  gap: 4px !important;
}
.artifact-canvas-panel.canvas-compact .canvas-artifact-title {
  display: none !important;
}
.artifact-canvas-panel.canvas-compact .canvas-tab-btn {
  padding: 4px 2px !important;
  font-size: 0.68rem !important;
}

@container canvas-panel (max-width: 440px) {
  .canvas-panel-header {
    height: auto !important;
    min-height: 76px !important;
    flex-wrap: wrap !important;
    padding: 6px 8px 8px !important;
    gap: 6px !important;
  }
  .canvas-panel-title-area {
    order: 1 !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  .canvas-actions {
    order: 2 !important;
    margin-left: auto !important;
    gap: 4px !important;
  }
  .canvas-tabs-switcher {
    order: 3 !important;
    width: 100% !important;
    margin-top: 2px !important;
    display: flex !important;
    gap: 2px !important;
  }
  .canvas-tab-btn {
    flex: 1 1 0% !important;
    justify-content: center !important;
    padding: 4px 4px !important;
    font-size: 0.72rem !important;
    gap: 4px !important;
  }
  .canvas-tab-btn .tab-dot {
    display: inline-block !important;
  }
}

@container canvas-panel (max-width: 270px) {
  .canvas-artifact-title {
    display: none !important;
  }
  .canvas-tab-btn {
    padding: 4px 2px !important;
    font-size: 0.68rem !important;
  }
}

/* Canvas Accent Strip */
.canvas-accent-strip {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 30%, #ec4899 60%, #06b6d4 100%);
  flex-shrink: 0;
}

.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.tab-dot.preview-dot {
  background: #6366f1;
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.6);
}
.tab-dot.code-dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* Canvas Panel Body */
.canvas-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  position: relative;
  background: var(--bg-secondary);
  padding: 16px 14px;
}

.canvas-view-container {
  width: 100%;
  height: 100%;
}

/* Canvas Document Card with Vibrant Visual Touches */
.canvas-doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  margin-bottom: 24px;
}

.canvas-doc-card-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(99, 102, 241, 0.04);
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.canvas-type-indicator {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-color);
}

.canvas-type-indicator.code {
  background: rgba(16, 185, 129, 0.14);
  color: #10b981;
}

.canvas-type-indicator.table {
  background: rgba(245, 158, 11, 0.14);
  color: #f59e0b;
}

.canvas-reading-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.canvas-doc-content {
  font-size: 0.94rem;
  line-height: 1.75;
  color: var(--text-primary);
  padding: 20px 24px;
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
}

/* Canvas Colorful Headings */
.canvas-doc-content h1 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0.8em 0 0.5em;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.canvas-doc-content h2 {
  font-size: 1.18rem;
  font-weight: 600;
  margin: 1.3em 0 0.5em;
  padding-left: 10px;
  border-left: 4px solid #6366f1;
  color: var(--text-primary);
}

.canvas-doc-content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.1em 0 0.4em;
  color: #4f46e5;
}

[data-theme="dark"] .canvas-doc-content h3 {
  color: #a5b4fc;
}

/* Canvas Blockquotes / Callouts */
.canvas-doc-content blockquote {
  margin: 14px 0;
  padding: 10px 16px;
  border-radius: 0 8px 8px 0;
  border-left: 4px solid #6366f1;
  background: rgba(99, 102, 241, 0.06);
  color: var(--text-primary);
}

/* Canvas Tables with Gradient Headers */
.canvas-doc-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 16px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.canvas-doc-content th {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.12));
  color: var(--accent-color);
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
}

.canvas-doc-content td {
  padding: 9px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .canvas-doc-content td {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.canvas-doc-content tr:nth-child(even) td {
  background: rgba(99, 102, 241, 0.025);
}

/* Canvas Inline Code */
.canvas-doc-content code:not(pre code) {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.86em;
}

[data-theme="dark"] .canvas-doc-content code:not(pre code) {
  background: rgba(165, 180, 252, 0.12);
  color: #a5b4fc;
  border-color: rgba(165, 180, 252, 0.25);
}

/* macOS Terminal Style for Code View */
.canvas-code-wrapper {
  border-radius: 12px;
  overflow: hidden;
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.canvas-code-mac-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #161b22;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.canvas-mac-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mac-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.mac-dot.red { background: #ff5f56; }
.mac-dot.yellow { background: #ffbd2e; }
.mac-dot.green { background: #27c93f; }

.canvas-code-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.canvas-code-lang-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  letter-spacing: 0.05em;
}

.canvas-code-stats-tag {
  font-size: 0.72rem;
  color: #8b949e;
}

.canvas-code-block {
  width: 100%;
  flex: 1;
  margin: 0;
  padding: 16px;
  border: none;
  border-radius: 0;
  background: #0d1117;
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  box-sizing: border-box;
}

/* Empty Hero Canvas Workspace with Gradient Icon and Feature Pills */
.canvas-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
}

.canvas-empty-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(236, 72, 153, 0.15) 100%);
  border: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.canvas-empty-icon {
  font-size: 2.2rem;
}

.canvas-empty-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.canvas-empty-desc {
  font-size: 0.85rem;
  max-width: 440px;
  line-height: 1.6;
  margin-bottom: 20px;
}

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

.canvas-feature-pill {
  font-size: 0.74rem;
  padding: 4px 10px;
  border-radius: 9999px;
  font-weight: 500;
}

.canvas-feature-pill.blue {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.canvas-feature-pill.green {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.canvas-feature-pill.purple {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.25);
}

.canvas-feature-pill.amber {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* ==========================================================================
   Canvas Live Sandboxed Runner & Fullscreen Overlay
   ========================================================================== */
.canvas-sandbox-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-primary, #ffffff);
}

[data-theme="dark"] .canvas-sandbox-container {
  background: #0f172a;
}

.sandbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(99, 102, 241, 0.04);
  border-bottom: 1px solid rgba(99, 102, 241, 0.15);
  flex-shrink: 0;
}

.sandbox-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6366f1;
}

[data-theme="dark"] .sandbox-status-chip {
  color: #a5b4fc;
}

.sandbox-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseGreen 2s infinite ease-in-out;
}

@keyframes pulseGreen {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

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

.sandbox-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.08);
  color: var(--accent-color, #6366f1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  cursor: pointer;
  transition: all 0.2s;
}

.sandbox-btn:hover {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.35);
}

.sandbox-viewport {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.canvas-sandbox-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

[data-theme="dark"] .canvas-sandbox-iframe {
  background: #0f172a;
}

/* Fullscreen Theater Overlay */
.canvas-fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.canvas-fullscreen-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.fullscreen-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(30, 41, 59, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.fullscreen-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fullscreen-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  letter-spacing: 0.06em;
}

.fullscreen-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f8fafc;
}

.fullscreen-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fullscreen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.2s;
}

.fullscreen-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.fullscreen-body {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 16px;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
}

.fullscreen-body iframe {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Inline Selection AI Companion Toolbar (Glassmorphic Floating Pill HUD)
   ========================================================================== */
.selection-ai-toolbar {
  position: fixed;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px) scale(0.96);
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-select: none;
}

.selection-ai-toolbar.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.selection-toolbar-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28), 0 0 1px rgba(255, 255, 255, 0.4);
}

[data-theme="light"] .selection-toolbar-inner {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(99, 102, 241, 0.22);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.selection-toolbar-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.selection-pills-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.selection-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 9999px;
  background: transparent;
  border: 1px solid transparent;
  color: #e2e8f0;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

[data-theme="light"] .selection-pill-btn {
  color: #374151;
}

.selection-pill-btn:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.35);
  color: #ffffff;
  transform: translateY(-1px);
}

[data-theme="light"] .selection-pill-btn:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
  color: #4f46e5;
}

.selection-pill-btn:active {
  transform: translateY(0) scale(0.96);
}

.selection-pill-btn .pill-icon {
  font-size: 0.8rem;
  line-height: 1;
}

.selection-pill-btn .pill-label {
  line-height: 1;
}

/* ==========================================================================
   Web Search Sources Favicon Wall & Multi-stage Thinking Graph HUD
   ========================================================================== */
.search-sources-wall {
  margin: 10px 0 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.04);
  border: 1px solid rgba(99, 102, 241, 0.16);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

[data-theme="dark"] .search-sources-wall {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.25);
}

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

.sources-wall-title-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sources-wall-icon {
  font-size: 0.9rem;
}

.sources-wall-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sources-count-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

[data-theme="dark"] .sources-count-badge {
  background: rgba(165, 180, 252, 0.2);
  color: #a5b4fc;
}

.sources-wall-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sources-pill-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.source-pill-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px solid rgba(99, 102, 241, 0.18);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .source-pill-card {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
}

.source-pill-card:hover {
  transform: translateY(-1px);
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.18);
  color: #4f46e5;
}

[data-theme="dark"] .source-pill-card:hover {
  color: #a5b4fc;
  border-color: #8b5cf6;
}

.source-index-num {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
}

.source-favicon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  object-fit: cover;
}

.source-favicon-fallback {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.source-title-text {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.source-domain-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.source-external-icon {
  opacity: 0.5;
  transition: opacity 0.15s;
}

.source-pill-card:hover .source-external-icon {
  opacity: 1;
}

/* Multi-stage Thinking Graph HUD */
.thinking-graph-hud {
  margin: 10px 0 14px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.03);
  border: 1px solid rgba(139, 92, 246, 0.2);
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.thinking-graph-hud.running {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06) 0%, rgba(139, 92, 246, 0.06) 50%, rgba(236, 72, 153, 0.04) 100%);
  border-color: rgba(139, 92, 246, 0.35);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.1);
}

.thinking-hud-header {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(139, 92, 246, 0.12);
}

.thinking-hud-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.thinking-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8b5cf6;
  box-shadow: 0 0 8px #8b5cf6;
  animation: pulsePurple 1.8s infinite ease-in-out;
}

@keyframes pulsePurple {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.thinking-hud-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}

.thinking-duration-chip {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  background: rgba(139, 92, 246, 0.12);
  color: #8b5cf6;
}

.thinking-hud-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.15s;
}

.thinking-hud-toggle-btn:hover {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
}

.thinking-stepper-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 6px;
}

.thinking-node-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  flex-shrink: 0;
}

.thinking-node {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  transition: all 0.2s;
}

.thinking-node-item.active .thinking-node {
  background: rgba(139, 92, 246, 0.2);
  border-color: #8b5cf6;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.35);
  transform: scale(1.08);
}

.node-pulse-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(139, 92, 246, 0.6);
  animation: ringPulse 1.6s infinite ease-out;
}

@keyframes ringPulse {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.node-check-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinking-node-item .node-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.thinking-node-item.active .node-label {
  color: #8b5cf6;
  font-weight: 600;
}

.thinking-node-item.done .node-label {
  color: var(--text-secondary);
}

.thinking-edge {
  flex: 1;
  height: 2px;
  background: rgba(139, 92, 246, 0.15);
  margin-top: -16px;
  border-radius: 9999px;
  transition: all 0.25s;
}

.thinking-edge.active {
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.35);
}

.thinking-hud-body {
  padding: 10px 14px;
  border-top: 1px dashed rgba(139, 92, 246, 0.2);
  background: rgba(0, 0, 0, 0.02);
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.thinking-raw-content {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
}

/* 4. Chain-of-Thought Accordion (Step-by-Step with Subtle Shimmer) */
.thinking-accordion-card {
  margin: 10px 0 14px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.03);
  border: 1px solid rgba(99, 102, 241, 0.18);
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.thinking-accordion-card.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06) 0%, rgba(139, 92, 246, 0.06) 50%, rgba(236, 72, 153, 0.04) 100%);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.12);
}

.thinking-accordion-header {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.thinking-step-track {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.thinking-step-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.thinking-step-item.active {
  color: #8b5cf6;
  font-weight: 600;
}

.thinking-step-arrow {
  color: rgba(139, 92, 246, 0.4);
  font-size: 0.7rem;
}

.thinking-chevron {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.thinking-accordion-card.expanded .thinking-chevron {
  transform: rotate(180deg);
}

.thinking-accordion-body {
  padding: 10px 14px;
  border-top: 1px dashed rgba(99, 102, 241, 0.15);
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
  background: rgba(0, 0, 0, 0.02);
  display: none;
}

.thinking-accordion-card.expanded .thinking-accordion-body {
  display: block;
}

/* 5. Suggestion Chips Bar (Floating above Composer) */
.composer-suggestion-chips-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin: 0 auto 6px;
  max-width: 96%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.composer-suggestion-chips-bar::-webkit-scrollbar {
  display: none;
}

.suggestion-chip-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.suggestion-chip-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
  transform: translateY(-1.5px);
}

.suggestion-chip-pill:active {
  transform: translateY(0);
  background: rgba(99, 102, 241, 0.15);
}

/* 6. Floating Prompt Bar Composer */
.floating-composer-container {
  padding: 0 16px 14px;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.floating-composer-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
  padding: 10px 14px 10px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.floating-composer-card:focus-within {
  border-color: var(--border-color-focus);
  box-shadow: 0 10px 32px rgba(99, 102, 241, 0.1);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .composer-toolbar {
  border-top-color: rgba(255, 255, 255, 0.05);
}

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

.composer-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.composer-tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Web Search Toggle Pill */
.composer-toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.18s ease;
}

.composer-toggle-pill .pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  transition: background 0.18s ease;
}

.composer-toggle-pill.active {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.composer-toggle-pill.active .pill-dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* Composer Model Dropdown */
.composer-model-select {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px 8px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.composer-model-select:hover {
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--text-primary);
}

/* Subtle Shimmer Gradient exclusively for Send Button */
.btn-send-shimmer {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%) !important;
  background-size: 200% 200% !important;
  animation: subtleShimmer 4s ease infinite !important;
  color: #ffffff !important;
  border: none !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.32) !important;
  transition: transform 0.15s ease !important;
}

.btn-send-shimmer:hover {
  transform: scale(1.05);
}

@keyframes subtleShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 7. QQ Bot Dynamic Verification Code Login Modal */
.qq-login-modal-card {
  max-width: 440px;
  width: 90%;
  border-radius: 18px;
  padding: 24px;
}

.qq-login-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  margin-bottom: 14px;
}

.qq-bot-avatar {
  font-size: 1.8rem;
}

.qq-bot-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.qq-bot-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.qq-target-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 14px;
}

.qq-target-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qq-target-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-color);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.qq-target-num {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.03em;
}

.qq-input-row {
  display: flex;
  gap: 8px;
}

.btn-get-code {
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--accent-color);
  border: 1px solid var(--border-color);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-get-code:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.15);
}

.btn-get-code:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  color: var(--text-muted);
}

.code-input {
  letter-spacing: 0.25em;
  font-size: 1.1rem;
  text-align: center;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

/* Trust Device Row in Login Modal */
.trust-device-row {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 9px;
  transition: all 0.2s ease;
}

.trust-device-row:hover {
  background: var(--bg-hover);
  border-color: rgba(99, 102, 241, 0.35);
}

.trust-device-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.82rem;
  color: var(--text-primary);
  margin: 0;
}

.trust-device-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-color, #6366f1);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.trust-device-text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.trust-device-title {
  font-weight: 600;
  color: var(--text-primary);
}

.trust-device-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: normal;
}

[data-theme="light"] .trust-device-row {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

.qq-login-footer-hints {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* 8. Sidebar Bottom Navigation & User Profile */
.sidebar-actions-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin: 6px 10px;
  width: calc(100% - 20px);
  box-sizing: border-box;
}

.sidebar-action-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.3);
}

.sidebar-action-btn.active {
  background: rgba(99, 102, 241, 0.14);
  color: var(--accent-color);
  border-color: rgba(99, 102, 241, 0.4);
  font-weight: 600;
}

.composer-tool-btn.active {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-color);
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 600;
}

.sidebar-user-card {
  margin: 6px 10px 10px 10px;
  width: calc(100% - 20px);
  box-sizing: border-box;
  position: relative;
}

.sidebar-user-badge {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.sidebar-user-badge:hover {
  background: var(--bg-hover);
  border-color: rgba(99, 102, 241, 0.3);
}

.user-avatar-mini {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info-text {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.user-name-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-mode-pill {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  font-weight: 600;
}

.user-chevron {
  opacity: 0.6;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.user-dropdown.sidebar-user-dropdown {
  position: absolute;
  bottom: calc(100% + 8px) !important;
  top: auto !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
  z-index: 100;
}

/* Floating Sidebar Toggle Button */
.floating-sidebar-toggle-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 40;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(8px);
}

.floating-sidebar-toggle-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: rgba(99, 102, 241, 0.4);
  transform: scale(1.05);
}

.floating-sidebar-toggle-btn:active {
  transform: scale(0.95);
}

@keyframes toggleBtnFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateX(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

.sidebar-collapsed .floating-sidebar-toggle-btn {
  display: flex !important;
  animation: toggleBtnFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@media (max-width: 768px) {
  .floating-sidebar-toggle-btn {
    display: flex !important;
  }
}

/* Floating Canvas Toggle Button (Top-Right) */
.floating-canvas-toggle-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.floating-canvas-toggle-btn:hover {
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.16);
  transform: translateY(-1px);
}

.floating-canvas-toggle-btn.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.12) 100%);
  color: var(--accent-color);
  border-color: rgba(99, 102, 241, 0.35);
  font-weight: 600;
}

/* ==========================================================================
   System Version Time Machine in Settings Modal
   ========================================================================== */
.timemachine-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 20px;
}

.timemachine-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.08) 50%, rgba(236, 72, 153, 0.05) 100%);
  border: 1px solid rgba(99, 102, 241, 0.22);
}

.timemachine-banner-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.timemachine-banner-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.timemachine-banner-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.timemachine-banner-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.timemachine-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.active-version-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 9999px;
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.timemachine-version-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timemachine-version-card {
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.6);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .timemachine-version-card {
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(255, 255, 255, 0.1);
}

.timemachine-version-card.is-active {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.05);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.12);
}

[data-theme="dark"] .timemachine-version-card.is-active {
  background: rgba(99, 102, 241, 0.12);
  border-color: #8b5cf6;
}

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

.version-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.version-tag {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.version-tag.baseline {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
}

.version-tag.custom {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

[data-theme="dark"] .version-tag.custom {
  color: #a5b4fc;
}

.version-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 8px;
}

.version-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-version-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s;
  border: 1px solid transparent;
}

.btn-version-toggle.active {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
  cursor: default;
}

.btn-version-toggle.action {
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  border-color: rgba(99, 102, 241, 0.25);
}

.btn-version-toggle.action:hover {
  background: #6366f1;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.version-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 6px 0 10px;
}

.version-features-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.version-feature-item {
  font-size: 0.76rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Creative Reply Format Switcher System (Global Styles & Settings)
   ========================================================================== */

/* 1. Article Mode (Magazine & Auto Illustrated Article) */
.format-mode-article .message-body {
  font-family: -apple-system, BlinkMacSystemFont, "Charter", "Bitstream Charter", "Georgia", serif, var(--font-sans);
  line-height: 1.9;
  letter-spacing: 0.005em;
  max-width: 100%;
}
.format-mode-article .message-body h1,
.format-mode-article .message-body h2,
.format-mode-article .message-body h3 {
  font-family: var(--font-sans);
  letter-spacing: -0.015em;
  color: var(--text-primary);
  margin-top: 1.8em;
  margin-bottom: 0.6em;
}
.format-mode-article .message-body h2 {
  position: relative;
  padding-left: 14px;
  border-left: 4px solid var(--accent-color);
  border-bottom: none;
}
.format-mode-article .article-lead {
  font-size: 1.12rem;
  font-weight: 500;
  line-height: 1.85;
  color: var(--text-primary);
  margin-bottom: 1.5em;
  padding-bottom: 1.2em;
  border-bottom: 1px dashed var(--border-color);
}
.format-mode-article .article-pullquote {
  margin: 22px 0;
  padding: 18px 24px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
  border-left: 4px solid #8b5cf6;
  border-radius: 0 12px 12px 0;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-primary);
}
.format-mode-article .article-illustration-card {
  margin: 22px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.format-mode-article .article-illustration-card .card-visual {
  height: 140px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #c7d2fe;
  position: relative;
}
.format-mode-article .article-illustration-card .card-caption {
  padding: 10px 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border-color);
}

/* 2. Xiaohongshu Card Mode (3:4 Visual Cards) */
.format-mode-xhs .message-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.format-mode-xhs .xhs-card-deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 14px 0;
}
.format-mode-xhs .xhs-card {
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  background: linear-gradient(160deg, #1f1b2e 0%, #161520 100%);
  border: 1px solid rgba(236, 72, 153, 0.25);
  box-shadow: 0 10px 30px rgba(236, 72, 153, 0.12);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
[data-theme="light"] .format-mode-xhs .xhs-card {
  background: linear-gradient(160deg, #fff5f8 0%, #ffffff 100%);
  border-color: rgba(244, 63, 94, 0.2);
  box-shadow: 0 8px 24px rgba(244, 63, 94, 0.08);
}
.format-mode-xhs .xhs-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(236, 72, 153, 0.2);
}
.format-mode-xhs .xhs-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%);
  color: #ffffff;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.3);
}
.format-mode-xhs .xhs-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--text-primary);
  margin: 12px 0 10px 0;
  letter-spacing: -0.02em;
}
.format-mode-xhs .xhs-card-content {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-secondary);
  flex: 1;
  overflow-y: auto;
}
.format-mode-xhs .xhs-tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(236, 72, 153, 0.2);
}
.format-mode-xhs .xhs-tag {
  font-size: 0.72rem;
  color: #f43f5e;
  font-weight: 600;
  background: rgba(244, 63, 94, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
}

/* 3. Knowledge Comic Mode */
.format-mode-comic .message-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.format-mode-comic .comic-strip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 14px 0;
}
.format-mode-comic .comic-panel {
  border: 2.5px solid var(--text-primary);
  border-radius: 10px;
  background: var(--bg-secondary);
  padding: 16px;
  position: relative;
  box-shadow: 4px 4px 0px var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.format-mode-comic .comic-narrator-box {
  background: #fef08a;
  border: 1.5px solid #000;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #171717;
  border-radius: 4px;
  align-self: flex-start;
  box-shadow: 2px 2px 0px #000;
  letter-spacing: 0.02em;
}
.format-mode-comic .comic-speech-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 2px solid #0f172a;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.6;
  position: relative;
  margin-top: 6px;
  box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.15);
}
.format-mode-comic .comic-speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 20px;
  border-width: 9px 8px 0;
  border-style: solid;
  border-color: #ffffff transparent;
  display: block;
  width: 0;
}
.format-mode-comic .comic-speech-bubble::before {
  content: "";
  position: absolute;
  bottom: -12px;
  left: 19px;
  border-width: 11px 9px 0;
  border-style: solid;
  border-color: #0f172a transparent;
  display: block;
  width: 0;
}

/* 4. Infographic Bento Mode */
.format-mode-infographic .message-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.format-mode-infographic .bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin: 12px 0;
}
.format-mode-infographic .bento-col-12 { grid-column: span 12; }
.format-mode-infographic .bento-col-8 { grid-column: span 8; }
.format-mode-infographic .bento-col-6 { grid-column: span 6; }
.format-mode-infographic .bento-col-4 { grid-column: span 4; }

@media (max-width: 768px) {
  .format-mode-infographic .bento-col-8,
  .format-mode-infographic .bento-col-6,
  .format-mode-infographic .bento-col-4 {
    grid-column: span 12;
  }
}

.format-mode-infographic .bento-card {
  border-radius: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.format-mode-infographic .bento-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}
.format-mode-infographic .bento-stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, #6366f1, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  margin-bottom: 6px;
}
.format-mode-infographic .bento-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 5. WeChat Article Mode */
.format-mode-wechat .message-body {
  font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", sans-serif;
  letter-spacing: 0.05em;
  line-height: 1.82;
  color: var(--text-primary);
  padding: 4px 2px;
}
.format-mode-wechat .wechat-section-header {
  text-align: center;
  margin: 30px 0 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.format-mode-wechat .wechat-header-line {
  height: 1px;
  width: 32px;
  background: #10b981;
}
.format-mode-wechat .wechat-header-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #10b981;
  letter-spacing: 0.08em;
}
.format-mode-wechat .wechat-callout {
  margin: 20px 0;
  padding: 16px 20px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.06);
  border-left: 3.5px solid #10b981;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

/* 6. Settings Panel: Creative Formats Grid & Live Preview */
.format-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.format-card-option {
  border-radius: 12px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  position: relative;
}
.format-card-option:hover {
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.12);
}
.format-card-option.is-active {
  border-color: var(--accent-color);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.18);
}
.format-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.format-card-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}
.format-card-icon {
  font-size: 1.4rem;
  line-height: 1;
}
.format-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}
.format-card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.format-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}
.format-card-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.format-card-option.is-active .format-card-badge {
  color: #10b981;
  font-weight: 600;
}
.format-preview-pane {
  margin-top: 18px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 18px 22px;
}
.format-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}
.format-preview-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Pagination: Load Earlier Messages Bar */
.load-earlier-messages-bar {
  display: flex;
  justify-content: center;
  padding: 12px 0 6px 0;
  width: 100%;
}
.load-earlier-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.load-earlier-btn:hover {
  background: var(--bg-hover);
  color: var(--brand-indigo);
  border-color: var(--brand-indigo);
}

/* ========================================================
   Pixel-Perfect Conversation Screenshot Export Root
   ======================================================== */
.chat-export-screenshot-root {
  width: 840px;
  background: #0c0e14;
  color: #f4f4f5;
  padding: 36px 32px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.chat-export-screenshot-root .export-screenshot-header {
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-export-screenshot-root .export-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.chat-export-screenshot-root .export-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #818cf8;
}

.chat-export-screenshot-root .export-header-logo {
  font-size: 1.2rem;
}

.chat-export-screenshot-root .export-header-tag {
  font-size: 0.72rem;
  padding: 3px 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  color: #a5b4fc;
  font-weight: 600;
}

.chat-export-screenshot-root .export-screenshot-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 10px 0;
  line-height: 1.4;
}

.chat-export-screenshot-root .export-screenshot-meta {
  font-size: 0.82rem;
  color: #9ca3af;
  display: flex;
  gap: 12px;
  align-items: center;
}

.chat-export-screenshot-root .export-screenshot-messages {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.chat-export-screenshot-root .export-shot-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 0;
}

.chat-export-screenshot-root .export-shot-row.user {
  flex-direction: row-reverse;
}

.chat-export-screenshot-root .export-shot-row.user .user-bubble {
  background: #1e1b4b;
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 14px 14px 4px 14px;
  padding: 14px 18px;
  max-width: 82%;
  color: #ffffff;
  font-size: 0.95rem;
  line-height: 1.6;
}

.chat-export-screenshot-root .export-shot-row.assistant .assistant-bubble {
  background: #13151f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px 14px 14px 4px;
  padding: 18px 22px;
  max-width: 90%;
  flex: 1;
  color: #e4e4e7;
  font-size: 0.95rem;
  line-height: 1.7;
}

.chat-export-screenshot-root .export-shot-row .message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.chat-export-screenshot-root .export-shot-row.user .user-avatar {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.chat-export-screenshot-root .export-shot-row.assistant .assistant-avatar {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.chat-export-screenshot-root .export-screenshot-thinking {
  margin-bottom: 14px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 10px;
  padding: 12px;
}

.chat-export-screenshot-root .export-attachments-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.chat-export-screenshot-root .export-att-img {
  max-width: 320px;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  object-fit: cover;
}

.chat-export-screenshot-root .export-att-file {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-size: 0.82rem;
  color: #a1a1aa;
}

.chat-export-screenshot-root .export-shot-footer {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.75rem;
  color: #71717a;
}

.chat-export-screenshot-root .footer-model-badge {
  font-family: var(--font-mono, monospace);
  padding: 2px 6px;
  background: rgba(99, 102, 241, 0.12);
  border-radius: 4px;
  color: #818cf8;
}

.chat-export-screenshot-root .export-screenshot-footer {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  font-size: 0.78rem;
  color: #6b7280;
}






/* ==============================================================================
 * Open WebUI Style Signature Navbar, Model Selector & RAG Knowledge Base
 * ============================================================================== */

/* Main Chat Top Navbar */
.openwebui-navbar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  transition: all 0.25s ease;
}

[data-theme="light"] .openwebui-navbar {
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

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

/* Nav Icon Buttons */
.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-secondary, #cbd5e1);
  cursor: pointer;
  transition: all 0.18s ease;
}

.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary, #f8fafc);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* Open WebUI Style Model Selector Pill */
.nav-model-dropdown-wrap {
  position: relative;
}

.nav-model-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary, #f8fafc);
  font-size: 0.86rem;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.nav-model-selector-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.nav-model-sparkle {
  font-size: 0.95rem;
}

.nav-model-title {
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-model-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
}

.nav-model-chevron {
  color: var(--text-muted, #94a3b8);
  transition: transform 0.2s ease;
}

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

/* Model Dropdown Menu */
.nav-model-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 330px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  z-index: 1000;
  animation: navMenuFadeIn 0.18s ease-out;
}

@keyframes navMenuFadeIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.nav-model-menu-header {
  padding: 10px 14px;
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #94a3b8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
}

.nav-model-options {
  max-height: 290px;
  overflow-y: auto;
  padding: 6px;
}

.nav-model-opt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-model-opt:hover {
  background: rgba(255, 255, 255, 0.07);
}

.nav-model-opt.active {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-model-opt .opt-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-model-opt .opt-icon {
  font-size: 1.1rem;
}

.nav-model-opt .opt-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-model-opt .badge-recommended {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.66rem;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.nav-model-opt .badge-tag {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.66rem;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.nav-model-opt .opt-desc {
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
}

.nav-model-opt .opt-check {
  font-size: 0.85rem;
  color: #38bdf8;
  font-weight: bold;
}

.nav-model-menu-footer {
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-model-menu-footer .effort-label {
  font-size: 0.74rem;
  color: var(--text-muted, #94a3b8);
}

.effort-pills {
  display: flex;
  gap: 4px;
}

.effort-pill {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary, #cbd5e1);
  cursor: pointer;
  transition: all 0.15s ease;
}

.effort-pill:hover {
  background: rgba(255, 255, 255, 0.1);
}

.effort-pill.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #ffffff;
  font-weight: 600;
}

/* Open WebUI Live Quota Pill */
.nav-quota-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 18px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: #34d399;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-quota-pill:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.nav-quota-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: quotaPulse 2s infinite;
}

@keyframes quotaPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.nav-quota-text {
  color: var(--text-secondary, #cbd5e1);
}

.nav-quota-val {
  color: #34d399;
  font-family: var(--font-mono, monospace);
  font-weight: 700;
}

/* Detailed Quota Popover */
.nav-quota-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.65);
  padding: 14px;
  z-index: 1000;
  animation: navMenuFadeIn 0.18s ease-out;
  color: var(--text-primary, #f8fafc);
}

.popover-quota-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.popover-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

.btn-popover-refresh {
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.btn-popover-refresh:hover {
  color: var(--text-primary, #ffffff);
  background: rgba(255, 255, 255, 0.1);
}

.popover-quota-main-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

.main-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.main-card-val {
  color: #34d399;
  font-family: var(--font-mono, monospace);
  font-size: 0.95rem;
}

.popover-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.popover-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #38bdf8 100%);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.main-card-sub {
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
}

.popover-quota-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.pq-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.74rem;
}

.pq-row-name {
  color: var(--text-secondary, #cbd5e1);
}

.pq-row-val {
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  color: #38bdf8;
}

.popover-quota-footer {
  font-size: 0.68rem;
  color: var(--text-muted, #64748b);
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 8px;
}

/* Nav Action Pills */
.nav-action-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-secondary, #cbd5e1);
  font-size: 0.78rem;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.18s ease;
}

.nav-action-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary, #ffffff);
}

.nav-action-pill.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
}

.nav-pill-counter {
  padding: 0 5px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.66rem;
  font-weight: 700;
}

/* Active Context Pill in Composer */
.composer-active-context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 6px;
}

.active-context-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 14px;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
  font-size: 0.74rem;
  font-weight: 550;
}

.context-pill-remove {
  background: none;
  border: none;
  color: #93c5fd;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 2px;
}

.context-pill-remove:hover {
  color: #ffffff;
}

/* Knowledge Base Quick Picker Dropdown */
.kb-quick-picker-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 12px;
  width: 290px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
  padding: 8px;
  z-index: 1000;
  animation: navMenuFadeIn 0.16s ease-out;
}

.kb-quick-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 6px;
}

.kb-quick-manage-btn {
  background: none;
  border: none;
  color: #38bdf8;
  font-size: 0.72rem;
  cursor: pointer;
}

.kb-quick-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kb-quick-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.kb-quick-opt:hover {
  background: rgba(255, 255, 255, 0.08);
}

.opt-kb-text {
  display: flex;
  flex-direction: column;
}

.opt-kb-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
}

.opt-kb-meta {
  font-size: 0.68rem;
  color: var(--text-muted, #94a3b8);
}

/* Knowledge Base Modal */
.modal-knowledge-card {
  width: 900px;
  max-width: 94vw;
  height: 600px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.knowledge-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.kb-sidebar {
  width: 280px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}

.kb-sidebar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.kb-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  text-transform: uppercase;
}

.btn-create-kb {
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-create-kb:hover {
  background: rgba(99, 102, 241, 0.35);
  color: #ffffff;
}

.kb-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-item-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all 0.15s ease;
}

.kb-item-card:hover {
  background: rgba(255, 255, 255, 0.06);
}

.kb-item-card.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.45);
}

.kb-item-icon {
  font-size: 1.2rem;
}

.kb-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
}

.kb-item-meta {
  font-size: 0.68rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
}

.kb-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 20px;
}

.kb-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.kb-title {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text-primary, #f8fafc);
}

.kb-desc {
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 3px;
}

.btn-delete-kb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  font-size: 0.74rem;
  cursor: pointer;
}

.btn-delete-kb:hover {
  background: rgba(239, 68, 68, 0.28);
}

.kb-upload-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
  margin-bottom: 16px;
}

.kb-upload-dropzone:hover,
.kb-upload-dropzone.dragover {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.08);
}

.dropzone-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.dropzone-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
}

.dropzone-hint {
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 4px;
}

.kb-documents-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kb-docs-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 8px;
}

.kb-docs-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-doc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.doc-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.doc-file-icon {
  font-size: 1.1rem;
}

.doc-row-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-row-name {
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--text-primary, #f8fafc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.doc-row-sub {
  font-size: 0.68rem;
  color: var(--text-muted, #94a3b8);
}

.doc-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-attach-to-chat {
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  font-size: 0.7rem;
  cursor: pointer;
}

.btn-attach-to-chat:hover {
  background: rgba(59, 130, 246, 0.35);
}

.btn-del-doc {
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
}

.btn-del-doc:hover {
  color: #ef4444;
}

/* ==========================================================================
   Gemini 4 Argon · Codex UI Skin (Deep Space Cosmic Violet)
   ========================================================================== */
[data-theme="argon"] {
  --bg-primary: #0a0814;
  --bg-secondary: #0c0a18;
  --bg-tertiary: #131024;
  --bg-hover: #1c1736;
  --border-color: rgba(139, 92, 246, 0.18);
  --border-color-focus: rgba(168, 85, 247, 0.5);
  --border: rgba(139, 92, 246, 0.18);
  --text-primary: #f3f0fa;
  --text-secondary: #c4b5fd;
  --text-muted: #8b80b6;
  --accent-color: #8b5cf6;
  --accent-hover: #a855f7;
  --accent-light: rgba(139, 92, 246, 0.15);
  --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #a855f7 50%, #c084fc 100%);
  --shimmer-gradient: linear-gradient(135deg, #8b5cf6 0%, #a855f7 50%, #d8b4fe 100%);
  --primary-accent: #a855f7;
  --brand-indigo: #8b5cf6;
  --brand-violet: #a855f7;
  --brand-pink: #d946ef;
  --card-glass-bg: rgba(18, 15, 33, 0.85);
  --card-glass-border: rgba(139, 92, 246, 0.22);
  --card-hover-border: rgba(168, 85, 247, 0.45);
  --user-msg-bg: #1c1734;
  --user-msg-border: rgba(168, 85, 247, 0.28);
  --user-msg-text: #ffffff;
  --assistant-msg-bg: #120f23;
  --code-bg: #07060e;
  --shadow-glow: 0 0 30px rgba(168, 85, 247, 0.3);
}

[data-theme="argon"] body {
  background-color: #0a0814;
  background-image: radial-gradient(ellipse at 50% 12%, rgba(139, 92, 246, 0.09), transparent 70%);
}

[data-theme="argon"] .sidebar {
  background: #0c0a18;
  border-right-color: rgba(139, 92, 246, 0.15);
}

[data-theme="argon"] .openwebui-navbar {
  background: rgba(10, 8, 20, 0.75);
  backdrop-filter: blur(16px);
  border-bottom-color: rgba(139, 92, 246, 0.15);
}

[data-theme="argon"] .chat-input-wrapper,
[data-theme="argon"] .input-box-container {
  background: rgba(22, 18, 41, 0.85) !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
  box-shadow: 0 8px 32px rgba(5, 3, 15, 0.7) !important;
}

[data-theme="argon"] .chat-input-wrapper:focus-within,
[data-theme="argon"] .input-box-container:focus-within {
  border-color: rgba(168, 85, 247, 0.6) !important;
  box-shadow: 0 0 35px rgba(168, 85, 247, 0.28) !important;
}

[data-theme="argon"] .conversation-item.active {
  background: #201b3a !important;
  border: 1px solid rgba(168, 85, 247, 0.3) !important;
  color: #f3f0fa !important;
}

[data-theme="argon"] .conversation-item:hover {
  background: #17132c;
}

[data-theme="argon"] .message-row.user .message-bubble {
  background: #1c1734 !important;
  border: 1px solid rgba(168, 85, 247, 0.28) !important;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.15) !important;
}

[data-theme="argon"] .message-row.assistant .message-bubble {
  background: #120f23 !important;
  border: 1px solid rgba(139, 92, 246, 0.15) !important;
}

[data-theme="argon"] .btn-primary,
[data-theme="argon"] #btnSend {
  background: linear-gradient(135deg, #7c3aed, #a855f7) !important;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.5) !important;
}

[data-theme="argon"] .sidebar-argon-card {
  display: block !important;
}

/* ==========================================================================
   Sidebar Argon Orbit Card Styles (Compact, zero overflow)
   ========================================================================== */
.sidebar-argon-card {
  margin: 4px 10px 6px 10px;
  background: rgba(18, 15, 33, 0.88);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 12px;
  padding: 8px 10px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(5, 3, 15, 0.4);
  color: #f1f0f7;
  width: calc(100% - 20px);
  box-sizing: border-box;
}

.sidebar-argon-card .argon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono, monospace);
  font-size: 9.5px;
  margin-bottom: 2px;
}

.sidebar-argon-card .argon-title {
  color: #c4b5fd;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.sidebar-argon-card .argon-live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #c084fc;
  box-shadow: 0 0 6px #c084fc;
}

.sidebar-argon-card .argon-badge {
  color: #a855f7;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.25);
  font-size: 9px;
}

.sidebar-argon-card .argon-canvas-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}

.sidebar-argon-card .argon-canvas-container canvas {
  width: 105px !important;
  height: 105px !important;
}

.sidebar-argon-card .argon-spectrum-header {
  margin-top: 2px;
  font-family: var(--font-mono, monospace);
  font-size: 8.5px;
  color: rgba(196, 181, 253, 0.65);
  letter-spacing: 0.05em;
}

.sidebar-argon-card .argon-spectrum-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 18px;
  margin-top: 4px;
  gap: 2px;
  padding: 0 1px;
}

.sidebar-argon-card .spectrum-bar {
  flex: 1;
  border-radius: 1.5px;
  background: linear-gradient(to top, #7c3aed, #c084fc);
  box-shadow: 0 0 4px rgba(168, 85, 247, 0.5);
  transition: height 0.12s ease-out;
  min-height: 3px;
}

.sidebar-argon-card .argon-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(168, 85, 247, 0.12);
  font-family: var(--font-mono, monospace);
  font-size: 8.5px;
  color: #c4b5fd;
  letter-spacing: 0.06em;
}

.sidebar-argon-card .argon-active-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #c084fc;
  font-weight: 600;
}

.sidebar-argon-card .argon-ping-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a855f7;
  position: relative;
  box-shadow: 0 0 6px #a855f7;
}

/* Navbar Quick Skin Button */
.nav-skin-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
  transition: all 0.2s ease;
}

.nav-skin-btn:hover {
  background: rgba(139, 92, 246, 0.22);
  border-color: #a855f7;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
  transform: translateY(-1px);
}

[data-theme="argon"] .nav-skin-btn {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(168, 85, 247, 0.4));
  border-color: #c084fc;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
}

/* ==========================================================================
   Full Width / Immersive Wide Chat Mode & Relaxed Canvas Constraints
   ========================================================================== */
.chat-panes-wrapper.full-width-chat .chat-messages,
.chat-panes-wrapper.canvas-collapsed.full-width-chat .chat-messages {
  max-width: 100% !important;
  width: 100% !important;
  padding-left: clamp(20px, 3.5vw, 64px) !important;
  padding-right: clamp(20px, 3.5vw, 64px) !important;
  margin: 0 !important;
}

.chat-panes-wrapper.full-width-chat .input-section,
.chat-panes-wrapper.canvas-collapsed.full-width-chat .input-section {
  max-width: 100% !important;
  width: 100% !important;
  padding-left: clamp(20px, 3.5vw, 64px) !important;
  padding-right: clamp(20px, 3.5vw, 64px) !important;
}

.chat-panes-wrapper.full-width-chat .floating-composer-card,
.chat-panes-wrapper.canvas-collapsed.full-width-chat .floating-composer-card {
  max-width: 100% !important;
}

.chat-panes-wrapper.full-width-chat .welcome-screen {
  max-width: 100% !important;
  padding-left: clamp(20px, 3.5vw, 64px) !important;
  padding-right: clamp(20px, 3.5vw, 64px) !important;
}

.chat-panes-wrapper.full-width-chat .suggestions-chips-wrap {
  max-width: 1400px !important;
}

.chat-panes-wrapper.full-width-chat .message-row.user {
  max-width: 100% !important;
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  justify-content: flex-end !important;
  margin-left: auto !important;
  margin-right: 0 !important;
}

.chat-panes-wrapper.full-width-chat .message-row.user .message-bubble {
  align-self: flex-end !important;
  margin-left: auto !important;
  margin-right: 0 !important;
}

.chat-panes-wrapper.full-width-chat .message-row.assistant {
  max-width: 100% !important;
  width: 100% !important;
}

.chat-panes-wrapper.full-width-chat .message-row.assistant .message-bubble {
  max-width: 100% !important;
  width: 100% !important;
}

/* Relax canvas-collapsed default width to prevent cramped 900px */
.chat-panes-wrapper.canvas-collapsed .chat-messages {
  max-width: 100% !important;
  margin: 0 !important;
  width: 100% !important;
}

.chat-panes-wrapper.canvas-collapsed .input-section {
  max-width: min(1500px, 95%) !important;
}

.chat-panes-wrapper.canvas-collapsed .floating-composer-card {
  max-width: 100% !important;
}

.nav-wide-btn.active {
  background: rgba(99, 102, 241, 0.22);
  border-color: #818cf8;
  color: #ffffff;
}
