/* ========================================================
   Antigravity Web Console - Modern Aesthetic Stylesheet
   Mobile-Optimized & In-Chat Model Picker & System Windows Inspector
   ======================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1f293d;
  --bg-hover: #26334d;
  --bg-active: #2d3d5c;
  --bg-card: #141c2e;
  --bg-card-subtle: #192338;
  
  --border-subtle: #202b40;
  --border-medium: #2d3b55;
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0a0e17;

  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.15);

  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  
  --status-running: #10b981;
  --status-running-bg: rgba(16, 185, 129, 0.15);
  --status-idle: #64748b;
  --status-idle-bg: rgba(100, 116, 139, 0.2);
  --status-error: #ef4444;
  --status-error-bg: rgba(239, 68, 68, 0.15);
  --status-warning: #f59e0b;
  --status-warning-bg: rgba(245, 158, 11, 0.15);

  --thinking-accent: #a855f7;
  --thinking-bg: rgba(168, 85, 247, 0.08);
  --thinking-border: rgba(168, 85, 247, 0.25);

  --tool-bg: #0d131f;
  --tool-border: #23314a;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;

  --header-height: 60px;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: fixed;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ================= Sidebar Backdrop (Mobile) ================= */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 140;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

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

/* ================= Sidebar ================= */
.sidebar {
  width: 320px;
  min-width: 320px;
  height: 100%;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 150;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.logo-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  flex-shrink: 0;
}

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

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

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mobile-sidebar-close {
  display: none;
}

.new-task-btn {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Search Box */
.search-box {
  margin: 10px 14px 6px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  padding: 8px 32px 8px 34px;
  font-size: 0.85rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-light);
}

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

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

.clear-search-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  padding: 4px 14px;
  gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.filter-btn:hover {
  color: var(--text-secondary);
  background-color: var(--bg-hover);
}

.filter-btn.active {
  color: #fff;
  background-color: var(--bg-tertiary);
  font-weight: 600;
}

.tab-badge {
  background: var(--status-running);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: var(--radius-full);
}

/* Conversation List */
.conversation-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border: 1px solid transparent;
  transition: all 0.15s;
  background-color: transparent;
  text-align: left;
}

.conv-item:hover {
  background-color: var(--bg-hover);
}

.conv-item.active {
  background-color: var(--bg-card);
  border-color: var(--border-medium);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.conv-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.conv-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conv-item.active .conv-title {
  color: #fff;
  font-weight: 600;
}

.status-pill {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.status-pill.running {
  background-color: var(--status-running-bg);
  color: var(--status-running);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-pill.running::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--status-running);
  animation: pulse 1.5s infinite;
}

.status-pill.idle {
  background-color: var(--status-idle-bg);
  color: var(--text-secondary);
}

.status-pill.error {
  background-color: var(--status-error-bg);
  color: var(--status-error);
}

.conv-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.conv-model-pill {
  font-size: 0.68rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

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

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

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

.status-dot.online {
  background-color: var(--status-running);
  box-shadow: 0 0 6px var(--status-running);
}

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

/* ================= Main Chat Content ================= */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* Header */
.chat-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-secondary);
  flex-shrink: 0;
  z-index: 10;
  gap: 10px;
}

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

.header-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.chat-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-model-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  white-space: nowrap;
}

.chat-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
}

.clickable-id {
  font-family: var(--font-mono);
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 1px dashed var(--text-muted);
}

.clickable-id:hover {
  color: var(--accent-primary);
}

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

.btn-windows {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(59, 130, 246, 0.15));
  border: 1px solid rgba(6, 182, 212, 0.35);
  color: #38bdf8;
  padding: 6px 12px;
  font-size: 0.84rem;
}

.btn-windows:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(59, 130, 246, 0.25));
  border-color: #38bdf8;
  color: #fff;
}

.auto-refresh-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-secondary);
  user-select: none;
}

.auto-refresh-toggle input {
  display: none;
}

.auto-refresh-toggle .slider {
  width: 28px;
  height: 16px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-full);
  position: relative;
  transition: 0.2s;
  border: 1px solid var(--border-medium);
}

.auto-refresh-toggle .slider::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--text-muted);
  top: 2px;
  left: 2px;
  transition: 0.2s;
}

.auto-refresh-toggle input:checked + .slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.auto-refresh-toggle input:checked + .slider::before {
  transform: translateX(12px);
  background-color: #fff;
}

/* Chat Messages Container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

.chat-messages {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Empty State */
.empty-placeholder {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 440px;
  color: var(--text-muted);
  padding: 24px 16px;
}

.empty-icon {
  margin-bottom: 14px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-placeholder h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-placeholder p {
  font-size: 0.88rem;
  line-height: 1.5;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
}

/* Message Styles */
.msg-step {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.user-msg-card {
  align-self: flex-end;
  max-width: 85%;
  background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 2px var(--radius-lg);
  padding: 12px 16px;
  box-shadow: 0 4px 14px rgba(30, 58, 138, 0.25);
}

.user-msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 4px;
}

.user-msg-body {
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.assistant-msg-card {
  align-self: flex-start;
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assistant-msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
}

.assistant-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-primary);
  font-weight: 600;
}

.thought-block {
  background-color: var(--thinking-bg);
  border: 1px solid var(--thinking-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.thought-header {
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--thinking-accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.thought-header:hover {
  background-color: rgba(168, 85, 247, 0.12);
}

.thought-content {
  padding: 8px 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #cbd5e1;
  border-top: 1px solid var(--thinking-border);
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

.tool-call-block {
  background-color: var(--tool-bg);
  border: 1px solid var(--tool-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.tool-call-header {
  padding: 7px 10px;
  background-color: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--tool-border);
}

.tool-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #38bdf8;
  font-weight: 600;
}

.tool-call-args {
  padding: 8px 12px;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  background-color: rgba(0, 0, 0, 0.2);
}

.tool-output-block {
  background-color: #0b101b;
  border-top: 1px dashed var(--tool-border);
  padding: 8px 12px;
  color: #a7f3d0;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.markdown-body {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #e2e8f0;
  word-break: break-word;
}

.markdown-body p {
  margin-bottom: 10px;
}

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

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin-top: 14px;
  margin-bottom: 6px;
  color: #fff;
  font-weight: 600;
}

.markdown-body code:not(pre code) {
  font-family: var(--font-mono);
  background-color: rgba(255, 255, 255, 0.08);
  color: #f472b6;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.86em;
}

.markdown-body pre {
  margin: 10px 0;
  background-color: #090d16 !important;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  overflow-x: auto;
}

.markdown-body pre code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.45;
  background: transparent !important;
  padding: 0 !important;
}

.markdown-body ul, .markdown-body ol {
  margin-left: 18px;
  margin-bottom: 10px;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent-primary);
  padding-left: 10px;
  margin: 10px 0;
  color: var(--text-secondary);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  display: block;
  overflow-x: auto;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  text-align: left;
  font-size: 0.85rem;
}

.markdown-body th {
  background-color: var(--bg-tertiary);
  font-weight: 600;
}

.system-event-badge {
  align-self: center;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin: 2px 0;
  text-align: center;
  max-width: 90%;
}

/* ================= Chat Input Area & Integrated Model Toolbar ================= */
.chat-input-area {
  padding: 8px 14px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-input-wrapper {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Model Selector Toolbar */
.chat-input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.model-picker-container {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.toolbar-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
}

.model-dropdown-wrapper {
  position: relative;
}

.btn-model-picker {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

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

.model-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  width: 290px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
  animation: modalScale 0.15s ease;
}

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

.model-menu-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.model-menu-item:hover {
  background-color: var(--bg-hover);
}

.model-menu-item.selected {
  background-color: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.m-item-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.m-rec-tag {
  font-size: 0.62rem;
  background: var(--accent-primary);
  color: #fff;
  padding: 1px 5px;
  border-radius: var(--radius-full);
}

.m-item-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

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

.btn-quick-new-task {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.btn-quick-new-task:hover {
  color: var(--accent-primary);
  background-color: var(--bg-tertiary);
}

.input-container {
  display: flex;
  gap: 8px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 6px 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  align-items: flex-end;
  transition: border-color 0.2s;
}

.input-container:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.input-container textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: var(--font-sans);
  line-height: 1.5;
  resize: none;
  min-height: 24px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 0;
}

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

.send-msg-btn {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  flex-shrink: 0;
  min-height: 36px;
}

/* ================= Buttons ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  outline: none;
  gap: 6px;
}

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

.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  font-size: 0.84rem;
}

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

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

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

/* ================= Modal ================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 12px;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: modalScale 0.2s ease;
}

.modal-dialog-lg {
  max-width: 820px;
}

@keyframes modalScale {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-icon.window-icon {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
}

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

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

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

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

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

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

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

.form-sublabel {
  font-weight: 400;
  color: var(--text-muted);
}

.required {
  color: var(--status-error);
}

.form-input, .form-textarea {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: #fff;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.model-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.model-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
}

.model-option:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-medium);
}

.model-option.selected {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: var(--accent-primary);
}

.model-option input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--accent-primary);
}

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

.model-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-recommended {
  font-size: 0.65rem;
  background: var(--accent-primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

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

.quick-templates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

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

.template-chip {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.76rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s;
}

.template-chip:hover {
  background-color: var(--bg-hover);
  color: #fff;
  border-color: var(--accent-primary);
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.modal-footer .btn {
  padding: 8px 16px;
  font-size: 0.88rem;
}

/* ================= Windows Modal Specifics ================= */
.windows-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  background-color: rgba(0, 0, 0, 0.15);
  flex-wrap: wrap;
}

.filter-tabs-pills {
  display: flex;
  gap: 6px;
}

.pill-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s;
}

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

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

.windows-search-box {
  flex: 1;
  min-width: 180px;
}

.windows-search-box input {
  width: 100%;
  padding: 6px 12px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.8rem;
  outline: none;
}

.windows-search-box input:focus {
  border-color: var(--accent-cyan);
}

.windows-modal-body {
  max-height: 520px;
  min-height: 280px;
  padding: 14px 18px;
}

.windows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

.window-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.15s;
}

.window-card:hover {
  border-color: var(--border-medium);
  background-color: var(--bg-card-subtle);
}

.window-card.active-win {
  border-left: 3px solid var(--status-running);
}

.window-card.minimized-win {
  border-left: 3px solid var(--status-warning);
}

.window-card.hidden-win {
  border-left: 3px solid var(--status-idle);
  opacity: 0.8;
}

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

.win-process-badge {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: #38bdf8;
  background-color: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.win-state-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.win-state-badge.active {
  background-color: var(--status-running-bg);
  color: var(--status-running);
}

.win-state-badge.minimized {
  background-color: var(--status-warning-bg);
  color: var(--status-warning);
}

.win-state-badge.hidden {
  background-color: var(--status-idle-bg);
  color: var(--text-muted);
}

.win-card-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-subtle);
  padding-top: 4px;
  margin-top: 2px;
}

.windows-footer-note {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-right: auto;
}

/* ================= Toast Notification ================= */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: #fff;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastIn 0.25s ease;
}

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

.toast.success { border-left: 4px solid var(--status-running); }
.toast.error { border-left: 4px solid var(--status-error); }
.toast.info { border-left: 4px solid var(--accent-primary); }

/* ================= Loading Spinner ================= */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: 0.84rem;
  width: 100%;
  grid-column: 1 / -1;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.4); opacity: 0.3; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* ================= MOBILE ADAPTATION (< 768px) ================= */
@media (max-width: 768px) {
  :root {
    --header-height: 54px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 82vw;
    max-width: 320px;
    height: 100%;
    transform: translateX(-100%);
    box-shadow: none;
  }

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

  .sidebar-backdrop {
    display: block;
  }

  .mobile-sidebar-close {
    display: flex;
  }

  .mobile-menu-btn {
    display: flex;
    padding: 6px;
  }

  .chat-header {
    padding: 0 10px;
  }

  .chat-title {
    font-size: 0.94rem;
  }

  .chat-model-pill {
    display: none !important;
  }

  .chat-meta {
    font-size: 0.68rem;
  }

  .header-right {
    gap: 6px;
  }

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

  .btn-windows, .chat-header .btn-secondary {
    padding: 6px 8px;
  }

  .auto-refresh-toggle .label-text {
    display: none;
  }

  .chat-container {
    padding: 10px 8px;
  }

  .chat-messages {
    gap: 12px;
  }

  .user-msg-card {
    max-width: 92%;
    padding: 10px 12px;
  }

  .assistant-msg-card {
    padding: 12px 12px;
  }

  .chat-input-area {
    padding: 6px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .input-container textarea {
    font-size: 16px;
  }

  .form-input, .form-textarea {
    font-size: 16px;
  }

  .modal-dialog {
    max-height: 94vh;
    border-radius: var(--radius-md);
  }

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

  .windows-filter-bar {
    padding: 8px 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .windows-search-box {
    width: 100%;
  }

  .windows-modal-body {
    padding: 10px 12px;
  }
}


/* ================= Real-time Pending Indicator Styles ================= */
.pending-card {
  border: 1px dashed var(--accent-primary) !important;
  background: rgba(59, 130, 246, 0.05) !important;
}

.pulse-text {
  font-size: 0.7rem;
  color: #10b981;
  font-weight: 600;
  animation: pulse 1.5s infinite;
}

.pending-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0;
}

.skeleton-line {
  height: 12px;
  background-color: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  width: 90%;
  position: relative;
  overflow: hidden;
}

.skeleton-line.short {
  width: 60%;
}

.shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateX(-100%);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0,
    rgba(255, 255, 255, 0.08) 20%,
    rgba(255, 255, 255, 0.15) 60%,
    rgba(255, 255, 255, 0)
  );
  animation: shimmer 1.8s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}


/* ================= Load More History Banner ================= */
.load-more-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--bg-tertiary);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.btn-load-more {
  background: none;
  border: none;
  color: #38bdf8;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.btn-load-more:hover {
  background-color: rgba(56, 189, 248, 0.1);
  color: #fff;
}

.btn-load-all {
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.74rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-load-all:hover {
  background-color: var(--bg-hover);
  color: #fff;
}

/* ================= Active Window Snapshot Styles ================= */
.btn-snapshot {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(236, 72, 153, 0.35);
  color: #f472b6;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-snapshot:hover {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.28), rgba(168, 85, 247, 0.28));
  border-color: #ec4899;
  color: #fff;
  transform: translateY(-1px);
}

.btn-snapshot svg {
  stroke: #f472b6;
  transition: stroke 0.2s;
}

.btn-snapshot:hover svg {
  stroke: #fff;
}

.snapshot-dialog {
  max-width: 960px;
  width: 95vw;
}

.snapshot-icon {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(168, 85, 247, 0.2));
  color: #f472b6;
}

.btn-snapshot-refresh {
  background: rgba(236, 72, 153, 0.12);
  border: 1px solid rgba(236, 72, 153, 0.3);
  color: #f472b6;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-snapshot-refresh:hover {
  background: rgba(236, 72, 153, 0.25);
  color: #fff;
}

.snapshot-toolbar {
  padding: 10px 16px;
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.snapshot-selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 260px;
}

.snapshot-selector-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.snapshot-select {
  flex: 1;
  max-width: 480px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: #fff;
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.snapshot-select:focus {
  border-color: #ec4899;
}

.snapshot-info-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.info-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.snapshot-modal-body {
  padding: 16px;
  background-color: #080c14;
  min-height: 280px;
  max-height: 72vh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.snapshot-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.snapshot-img {
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-medium);
  transition: opacity 0.2s ease;
  cursor: zoom-in;
}

.snapshot-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #ef4444;
  font-size: 0.88rem;
  padding: 30px 16px;
  text-align: center;
}

.snapshot-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

/* 快照按钮在窗口列表卡片上的样式 */
.btn-win-snap {
  background-color: rgba(236, 72, 153, 0.12);
  border: 1px solid rgba(236, 72, 153, 0.3);
  color: #f472b6;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s;
}

.btn-win-snap:hover {
  background-color: rgba(236, 72, 153, 0.25);
  color: #fff;
  border-color: #ec4899;
}

/* Markdown Images */
.markdown-body img {
  max-width: 100%;
  max-height: 480px;
  border-radius: var(--radius-md);
  margin: 10px 0;
  cursor: zoom-in;
  border: 1px solid var(--border-medium);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  display: block;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.markdown-body img:hover {
  opacity: 0.95;
  transform: scale(1.01);
}

/* Step Media Gallery */
.step-media-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-light);
}

.media-preview-card {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  max-width: 220px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.media-preview-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.25);
}

.media-thumb-wrapper {
  width: 220px;
  height: 140px;
  background-color: #0b0f17;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.media-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.media-preview-card:hover .media-thumb {
  transform: scale(1.05);
}

.media-card-info {
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background-color: var(--bg-card);
}

.media-card-title {
  font-size: 0.76rem;
  font-weight: 500;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.media-card-type {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: #94a3b8;
  background-color: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Image Lightbox Modal */
.lightbox-modal {
  z-index: 1000;
  background-color: rgba(10, 15, 26, 0.88);
  backdrop-filter: blur(8px);
}

.lightbox-dialog {
  width: 92vw;
  max-width: 1200px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.lightbox-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-primary);
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
}

.lightbox-title {
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.lightbox-body {
  flex: 1;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #06090e;
  overflow: auto;
  min-height: 300px;
}

.lightbox-img-wrapper {
  max-width: 100%;
  max-height: calc(92vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img-wrapper img {
  max-width: 100%;
  max-height: calc(92vh - 90px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  user-select: none;
}

/* Audio Player Card */
.media-audio-card {
  width: 100%;
  max-width: 600px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin: 6px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
}

.media-audio-card:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.2);
}

.audio-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.audio-icon-title {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex: 1;
}

.audio-wave-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.audio-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.audio-filename {
  font-size: 0.84rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #93c5fd;
  background-color: rgba(59, 130, 246, 0.18);
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

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

.btn-audio-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 0.72rem;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-audio-action:hover {
  background: rgba(59, 130, 246, 0.2);
  color: #fff;
  border-color: #3b82f6;
}

.audio-player-wrapper {
  width: 100%;
}

.audio-element {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-md);
  outline: none;
  filter: invert(0.9) hue-rotate(180deg);
}

/* Audio Link in Markdown */
.markdown-body a.audio-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.85em;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
}

.markdown-body a.audio-link::before {
  content: "🎵";
  font-size: 0.9em;
}

.markdown-body a.audio-link:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
  color: #fff;
}

/* Agent Embed Frame */
.agent-embed-wrapper {
  margin: 14px 0;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--bg-card);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.agent-embed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.78rem;
}

.agent-embed-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #e2e8f0;
}

.btn-embed-open {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-embed-open:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #fff;
}

.agent-embed-iframe {
  width: 100%;
  height: 380px;
  border: none;
  display: block;
  background-color: #0b0f17;
}

/* Document & File Card */
.media-doc-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  min-width: 240px;
}

.doc-icon {
  color: var(--accent-primary);
}

.doc-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.doc-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-mime {
  font-size: 0.68rem;
  color: #94a3b8;
}

.doc-actions {
  display: flex;
  gap: 6px;
}

.btn-doc-action {
  font-size: 0.72rem;
  color: #60a5fa;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.1);
  text-decoration: none;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.btn-doc-action:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #fff;
}

/* ================= Live Token Speed & Agent Speed Widget ================= */
.speed-meter-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 20px;
  padding: 4px 10px;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  font-size: 0.8rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  user-select: none;
}

.speed-meter-pill:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.2);
  transform: translateY(-1px);
}

.speed-meter-pill:active {
  transform: translateY(0);
}

.speed-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.speed-pulse-dot.generating {
  background-color: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: speedPulse 1.2s infinite ease-in-out;
}

.speed-pulse-dot.tools {
  background-color: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  animation: speedPulse 1.8s infinite ease-in-out;
}

.speed-pulse-dot.idle {
  background-color: #64748b;
  box-shadow: none;
}

.speed-pulse-dot.disconnected {
  background-color: #ef4444;
}

@keyframes speedPulse {
  0% { transform: scale(0.9); opacity: 0.75; }
  50% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.75; }
}

.speed-info-block {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.speed-val {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-weight: 700;
  font-size: 0.84rem;
  color: #38bdf8;
}

.speed-meter-pill.generating .speed-val {
  color: #34d399;
}

.speed-unit {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 500;
}

.speed-divider {
  width: 1px;
  height: 12px;
  background: rgba(255, 255, 255, 0.15);
}

.tokens-info-block {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.tokens-label {
  font-size: 0.7rem;
  color: #94a3b8;
}

.tokens-val {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-weight: 600;
  font-size: 0.8rem;
  color: #f1f5f9;
}

/* Modal Dialog */
.token-speed-dialog {
  max-width: 640px;
  width: 92vw;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
}

.speed-icon-bg {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(16, 185, 129, 0.2));
  color: #38bdf8;
}

.token-speed-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

.speed-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.speed-metric-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.speed-metric-card.primary {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.1), rgba(15, 23, 42, 0.7));
  border-color: rgba(16, 185, 129, 0.3);
}

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

.metric-label {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
}

.metric-status-tag {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
}

.metric-status-tag.generating {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.metric-status-tag.tools {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

.metric-icon-tag {
  font-size: 0.68rem;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 8px;
}

.metric-card-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.large-speed-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: #34d399;
}

.large-speed-unit {
  font-size: 0.8rem;
  color: #94a3b8;
}

.large-tokens-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: #f8fafc;
}

.large-agent-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: #38bdf8;
}

.large-agent-unit {
  font-size: 0.75rem;
  color: #94a3b8;
}

.metric-card-footer {
  font-size: 0.72rem;
  color: #64748b;
}

/* Token Breakdown Bars */
.token-breakdown-section {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 12px;
}

.token-bars-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.token-bar-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.token-bar-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
}

.token-kind-name {
  color: #94a3b8;
}

.token-kind-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: #e2e8f0;
  font-weight: 600;
}

.token-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.token-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.token-progress-fill.input-fill {
  background: #38bdf8;
}

.token-progress-fill.cache-fill {
  background: #a855f7;
}

.token-progress-fill.output-fill {
  background: #10b981;
}

/* Speed Chart Section */
.speed-chart-section {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

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

.chart-legend {
  font-size: 0.72rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 5px;
}

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

.chart-container {
  width: 100%;
  height: 90px;
  position: relative;
  overflow: hidden;
}

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

.sparkline-area {
  fill: rgba(16, 185, 129, 0.15);
}

.sparkline-line {
  fill: none;
  stroke: #10b981;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.speed-modal-footer-tip {
  font-size: 0.72rem;
  color: #64748b;
  flex: 1;
}

@media (max-width: 768px) {
  .speed-summary-grid {
    grid-template-columns: 1fr;
  }
  .speed-meter-pill .tokens-info-block {
    display: none;
  }
  .speed-divider {
    display: none;
  }
}




