/* ============================================================
   Native CSS — Visual design from target UI
   Organized by: Variables → Reset → Layout → Components → Responsive
   ============================================================ */

/* --- CSS Variables (Design Tokens) --- */
:root {
  --app-bg-start: #eff6ff;
  --app-bg-end: #fff6ee;
  --accent-surface: #dfe9f4;
  --accent-surface-hover: #cbe0f7;
  --accent-border: #b8d5f8;
  --accent-text: #312e81;
  --soft-border: #dedede;
  --soft-border-strong: #f5f4f4;
  --soft-panel: #f2f4fa;
  --soft-panel-strong: #f8f4f4;
  --user-shell-bg: #f7f2f1;
  --user-shell-border: #bababa;
  --user-badge-bg: #f7e2e2;
  --user-badge-border: #dddada;
  --user-badge-text: #000000;
  --assistant-badge-bg: #dfe9f4;
  --assistant-badge-strong: #c2d7f8;
  --ink-strong: #050505;
  --ink-default: #131212;
  --console-fg: #b8d5f8;
  --resend-hover-bg: rgba(234, 222, 156, 0.2);
  --fork-hover-text: #0e766e;

  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-150: #ececed;
  --zinc-200: #e4e4e7;
  --zinc-250: #dcdce0;
  --zinc-300: #d4d4d8;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-550: #5f5f68;
  --zinc-600: #52525b;
  --zinc-650: #494951;
  --zinc-700: #3f3f46;
  --zinc-750: #333338;
  --zinc-800: #27272a;
  --zinc-850: #1f1f22;
  --zinc-900: #18181b;
  --zinc-950: #09090b;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--zinc-900);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: linear-gradient(to bottom, var(--app-bg-start), var(--app-bg-end));
}

button { cursor: pointer; border: none; background: none; font: inherit; padding: 0; }
input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.font-mono { font-family: 'JetBrains Mono', 'SFMono-Regular', monospace; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e4e4e7; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #d4d4d8; }

/* --- App Shell --- */
.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* --- Header --- */
.app-header {
  background: #fff;
  border-bottom: 1px solid var(--zinc-200);
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
}

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

.brand-icon {
  padding: 5px;
  background: #000;
  border-radius: 7px;
  color: #fff;
  display: flex;
}

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

.brand-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--zinc-900);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.brand-version {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  padding: 2px 8px;
  background: var(--zinc-100);
  color: var(--zinc-650);
  border-radius: 9999px;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--zinc-500);
  margin: 0;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--zinc-500);
}

.header-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9abeed;
  display: inline-block;
}

/* --- Mobile Tab Switcher --- */
.mobile-tabs {
  display: flex;
  margin: 8px 16px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--zinc-200);
  padding: 4px;
  border-radius: 12px;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.mobile-tab-btn {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s;
  color: var(--zinc-650);
}

.mobile-tab-btn:hover { background: var(--zinc-50); }

.mobile-tab-btn.active {
  background: var(--zinc-900);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mobile-tab-btn i { width: 14px; height: 14px; }

/* --- Main Grid --- */
.main-grid {
  flex: 1;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 8px;
  min-height: 0;
}

/* --- Panel (shared card style) --- */
.panel {
  background: #fff;
  border: 1px solid var(--zinc-200);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

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

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--zinc-900);
}

.panel-title i { width: 16px; height: 16px; color: #000; }

/* --- Column: Left (Prompt + Sessions) --- */
.col-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
}

.col-left.hidden-mobile { display: none; }

/* Prompt Panel */
.prompt-panel { gap: 14px; }
.prompt-panel.panel { flex: 1; min-height: 0; }

.btn-small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 8px;
  color: var(--zinc-700);
  background: var(--zinc-50);
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
  transition: background 0.15s;
  font-weight: 500;
}

.btn-small:hover { background: var(--zinc-100); }
.btn-small i { width: 14px; height: 14px; }

/* Preset Settings Box */
.preset-box {
  background: var(--zinc-50);
  border-radius: 8px;
  padding: 10px;
  border: 1px solid var(--zinc-150);
}

.preset-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--zinc-500);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preset-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-select-row {
  display: flex;
  gap: 6px;
  width: 100%;
}

.preset-select {
  flex: 1;
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--zinc-700);
  min-width: 0;
}

.preset-select:focus {
  outline: none;
  box-shadow: 0 0 0 1px #6366f1;
}

.btn-delete-preset {
  padding: 6px;
  background: #fff;
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
  color: var(--zinc-400);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-delete-preset:hover { background: #fef2f2; color: #ef4444; }
.btn-delete-preset i { width: 16px; height: 16px; }

.btn-accent {
  background: var(--accent-surface);
  color: #000;
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  padding: 8px;
  transition: background 0.15s;
}

.btn-accent:hover { background: var(--accent-surface-hover); }
.btn-accent i { width: 14px; height: 14px; }

.preset-server-status {
  font-size: 10px;
  color: var(--zinc-400);
  min-height: 14px;
  padding-top: 4px;
}

/* Slot List */
.slot-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 4px;
}

.slot-item {
  border: 1px solid var(--soft-border);
  border-radius: 8px;
  transition: all 0.15s;
}

.slot-item.active {
  
  border-color: var(--accent-border);
  background: color-mix(in srgb, var(--accent-surface) 15%, transparent);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.slot-item.inactive {
  background: var(--zinc-50);
  opacity: 0.4;
  border: 1px dashed var(--soft-border);;
}

.slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 12px;
  cursor: pointer;
  user-select: none;
}

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

.slot-collapse-btn {
  padding: 2px;
  border-radius: 4px;
  color: var(--zinc-400);
  flex-shrink: 0;
}

.slot-collapse-btn:hover { background: var(--zinc-100); }
.slot-collapse-btn i { width: 14px; height: 14px; }

.slot-toggle-btn {
  padding: 4px;
  border-radius: 4px;
  color: var(--zinc-500);
  flex-shrink: 0;
}

.slot-toggle-btn:hover { background: var(--zinc-100); }
.slot-toggle-btn i { width: 16px; height: 16px; }
.slot-toggle-btn.active i { color: #000; }

.slot-name-input {
  font-size: 12px;
  font-weight: 600;
  color: var(--zinc-800);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 2px 4px;
  border-radius: 4px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-name-input:hover { border-bottom-color: var(--zinc-300); }
.slot-name-input:focus {
  border-bottom-color: var(--zinc-500);
  background: #fff;
  outline: none;
}

.slot-delete-btn {
  padding: 4px;
  color: var(--zinc-400);
  border-radius: 4px;
  transition: all 0.15s;
}

.slot-delete-btn:hover { background: #fef2f2; color: #ef4444; }
.slot-delete-btn i { width: 14px; height: 14px; }

.slot-editor {
  padding: 2px 12px 12px;
  border-top: 1px solid var(--zinc-100);
}

.slot-textarea {
  width: 100%;
  font-size: 12px;
  font-family: inherit;
  padding: 8px;
  background: var(--zinc-50);
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
  color: var(--zinc-700);
  resize: vertical;
}

.slot-textarea:focus {
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 1px var(--zinc-400);
}

.slot-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--zinc-400);
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
}

/* Token Stats Bar */
.token-stats {
  margin-top: 0px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0px;
  border-radius: 8px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  border: none;
}

.token-stats-label { color: var(--zinc-500); }
.token-stats-value { font-weight: 600; color: var(--zinc-800); }

/* Session Panel */
.session-panel.panel {
  gap: 12px;
  flex: 1;
  min-height: 220px;
}

.btn-new-session {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 10px;
  font-weight: 600;
  border-radius: 6px;
  background: var(--accent-surface);
  color: #000;
  transition: background 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-new-session:hover { background: var(--accent-surface-hover); }
.btn-new-session i { width: 14px; height: 14px; }

.session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.session-item {
  position: relative;
  padding: 4px 10px 3px 10px;
  border-radius: 8px;
  border: 1px dashed var(--soft-border);;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  background: #fff;
  color: var(--zinc-700);
}

.session-item:hover { background: var(--zinc-50); }

.session-item.active {
  border: 1px solid var(--soft-border);
  background: var(--accent-surface);
  border-color: var(--accent-border);
  color: var(--zinc-900);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.session-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 32px;
}

.session-title-display {
  display: flex;
  align-items: left;
  gap: 6px;

  min-width: 0;
}

.session-title-display i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--zinc-400);
  
}
.session-title-display i[data-lucide] {
  width: 24px !important;
  height: 24px;
}

.session-item.active .session-title-display i { color: #000; }

.session-title-text {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
  left: 0px;

  max-width: 110px;
}


  
}

.session-title-input {
  font-size: 12px;
  font-weight: 600;
  color: var(--zinc-800);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 1px 4px;
  width: 100%;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-title-input:hover { border-color: var(--zinc-300); }
.session-title-input:focus {
  border-color: var(--accent-border);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.session-hover-actions {
  position: absolute;
  right: 8px;
  top: 10px;
  display: none;
  align-items: center;
  gap: 4px;
  background: #ffffff00;
  padding-left: 8px;
}

.session-item:hover .session-hover-actions { display: flex; }
.session-item.active .session-hover-actions { background: var(--accent-surface); }

.session-action-btn {
  padding: 4px;
  border-radius: 4px;
  color: var(--zinc-500);
  transition: all 0.15s;
}

.session-action-btn:hover { background: var(--zinc-100); color: var(--zinc-800); }
.session-action-btn.delete:hover { color: #ef4444; }
.session-action-btn i { width: 12px; height: 12px; }

.session-meta {
  font-size: 10px;
  color: var(--zinc-400);
  margin: 4px;
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-family: 'JetBrains Mono', monospace;
  position: relative;
  right: -19px;
  min-width: 25px;
}

.session-item:hover .session-meta {
  opacity: 0;
  pointer-events: none;
}

.session-item:hover .session-hover-actions {
  opacity: 1;
  pointer-events: auto;
}

/* --- Column: Center (Chat) --- */
.col-center {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.col-center.hidden-mobile { display: none; }

/* API Error Alert */
.api-error {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  padding: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
  border-radius: 0 8px 8px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #78350f;
}

.api-error i { width: 16px; height: 16px; color: #d97706; flex-shrink: 0; margin-top: 2px; }
.api-error b { font-weight: 700; }

/* Chat Panel */
.chat-panel {
  flex: 1;
  background: #fff;
  border: 1px solid var(--zinc-200);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  min-height: 0;
}

/* Chat Toolbar */
.chat-toolbar {
  padding: 8px 16px;
  background: rgba(250,250,250,0.5);
  border-bottom: 1px solid var(--zinc-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 8px;
}

.chat-toolbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-title-inline {
  font-size: 14px;
  font-weight: 600;
  color: var(--zinc-900);
  white-space: nowrap;
}

.chat-phase-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--zinc-500);
  white-space: nowrap;
}

.chat-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--zinc-700);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.status-dot.generating {
  background: #4f46e5;
  animation: pulse 1.5s infinite;
}

.session-phase-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--zinc-400);
  margin-left: 4px;
}

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

.chat-options {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-option-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--zinc-550);
  user-select: none;
  cursor: pointer;
}

.chat-option-label input[type="checkbox"] {
  border-radius: 4px;
  border: 1px solid var(--zinc-300);
  accent-color: #4f46e5;
}

.btn-sql-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-sql-toggle.active {
  background: var(--accent-surface);
  color: #000;
  font-weight: 700;
}

.btn-sql-toggle.idle {
  background: var(--zinc-100);
  color: var(--zinc-500);
  border-color: transparent;
}

.btn-sql-toggle.idle:hover { background: var(--zinc-200); }

/* 每条 assistant 气泡右上角的 COT 开关，仅控制本条思维链 */
.btn-cot-msg {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
  padding: 1px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cot-msg.active {
  background: var(--accent-surface);
  color: #000;
  font-weight: 700;
}

.btn-cot-msg.idle {
  background: var(--zinc-100);
  color: var(--zinc-500);
}

.btn-cot-msg.idle:hover { background: var(--zinc-200); }

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Empty State */
.chat-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--zinc-400);
  padding: 24px;
}

.chat-empty-icon {
  padding: 12px;
  background: #ede9fe;
  border-radius: 12px;
  margin-bottom: 12px;
  color: #6366f1;
}

.chat-empty-icon i { width: 32px; height: 32px; }

.chat-empty h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--zinc-700);
  margin: 0;
}

.chat-empty p {
  font-size: 11px;
  color: var(--zinc-500);
  max-width: 280px;
  margin-top: 4px;
}

/* Message Bubble */
.msg-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 85%;
}

.msg-wrap.user {
  align-self: flex-end;
  margin-left: 48px;
}

.msg-wrap.assistant {
  align-self: flex-start;
  margin-right: 48px;
}

.msg-wrap.error {
  align-self: flex-start;
  margin-right: 48px;
}

.msg-wrap.msg-hidden {
  opacity: 0.35;
}

.msg-wrap.msg-hidden .msg-bubble {
  border-style: dashed;
}

.btn-eye-toggle {
  opacity: 0.4;
  transition: opacity 0.15s;
}

.btn-eye-toggle:hover {
  opacity: 1;
}

.msg-hidden .btn-eye-toggle {
  opacity: 0.8;
  color: #ef4444;
}

.msg-bubble {
  display: flex;
  flex-direction: column;
  border: 1px solid;
  overflow: hidden;
  width: 100%;
  transition: all 0.2s;
}

.msg-bubble.user {
  background: var(--user-shell-bg);
  border-color: #ece7e7;
  border-radius: 20px 20px 0px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.msg-bubble.assistant {
  background: #fff;
  border-color: #ece7e7;
  border-radius: 20px 20px 16px 0px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.msg-bubble.error {
  background: #fff4f2;
  border-color: #f3b4ae;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.msg-bubble.system-note {
  background: #fefce8;
  border-color: #fde68a;
  border-radius: 12px;
}

/* Message Header */
.msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--zinc-100);
  font-size: 12px;
}

.msg-header.assistant-header {
  background: var(--soft-panel);
}

.msg-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-role-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.msg-role-badge.user { color: var(--user-badge-text); }
.msg-role-badge.assistant { color: #000; }
.msg-role-badge.error { color: #991b1b; }
.msg-role-badge.system-note { color: #92400e; }

.msg-time {
  font-size: 10px;
  color: var(--zinc-400);
  font-family: 'JetBrains Mono', monospace;
}

.msg-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--zinc-400);
}

.msg-latency {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--zinc-500);
}

.msg-latency i { width: 10px; height: 10px; color: var(--zinc-300); }

.msg-duration {
  font-size: 10px;
  color: #0f766e;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.msg-token-badge {
  background: var(--zinc-100);
  color: var(--zinc-650);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
}

/* Message Content */
.msg-content {
  padding: 16px 25px 0px 25px !important;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 14px;
  line-height: 1.7;
  color: #1c1c1e;
}

.msg-content.user-content { background: #fff; }

/* Markdown Body Styles */
.msg-content h1,
.msg-content h2,
.msg-content h3 {
  line-height: 1.25;
  margin: 4px 0 2px;
}

.msg-content h1 { font-size: 18px; }
.msg-content h2 { font-size: 16px; }
.msg-content h3 { font-size: 15px; }

.msg-content p {
  margin: 0;
  white-space: normal;
}

.msg-content ul,
.msg-content ol {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 3px;
}

.msg-content pre {
  overflow: auto;
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 10px;
  white-space: pre-wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.msg-content code {
  border: 1px solid var(--zinc-200);
  border-radius: 4px;
  background: var(--zinc-50);
  padding: 1px 4px;
  font-size: 0.92em;
  font-family: 'JetBrains Mono', monospace;
}

.msg-content pre code {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
}

.msg-content blockquote {
  margin: 0;
  padding-left: 10px;
  border-left: 3px solid var(--accent-border);
  color: var(--zinc-600);
}

/* Think Chain Block */
.think-block {
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  padding: 12px;
  color: #1c1c1e;
  background: var(--soft-panel);
}

.think-block.strong {
  background: var(--soft-panel-strong);
  border-color: #f4f4f5;
}

.think-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 10px;
  color: #000;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.think-label i { width: 12px; height: 12px; color: #000; }

.think-body {
  white-space: pre-wrap;
  font-size: 11px;
  line-height: 1.625;
  font-family: 'JetBrains Mono', monospace;
  color: var(--zinc-700);
  user-select: text;
}

/* Text Reply */
.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  color: var(--zinc-900);
  font-size: 14px;
}

/* SQL Block */
.sql-block {
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--accent-border);
  background: color-mix(in srgb, var(--accent-surface) 10%, transparent);
}

.sql-block.strong { border-color: #f4f4f5; }

.sql-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  font-size: 12px;
  color: #1e293b;
  border-bottom: 1px solid var(--accent-border);
  background: var(--soft-panel);
}

.sql-toolbar-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

.sql-toolbar-title i { width: 14px; height: 14px; color: var(--ink-strong); }

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

.btn-copy-sql {
  padding: 4px;
  border-radius: 4px;
  color: #64748b;
}

.btn-copy-sql:hover { background: var(--accent-border); }
.btn-copy-sql i { width: 12px; height: 12px; }

.sql-code {
  padding: 12px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--zinc-800);
  background: rgba(250,250,250,0.3);
  white-space: pre-wrap;
  margin: 0;
}

/* Message Footer Bars */
.msg-footer-user {
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 11px;
}

.btn-resend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--zinc-750);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-resend:hover {
  color: #000;
  background: var(--resend-hover-bg);
}

.btn-resend i { width: 12px; height: 12px; color: var(--zinc-600); }

.msg-footer-user .user-btns {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.msg-edit-area {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 4px 0 0 0;
  padding: 12px 25px;
  border: none;
  border-top: 1px solid var(--zinc-100);
  background: #fffef7;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: #1c1c1e;
  resize: vertical;
  min-height: 56px;
  min-width: 800px;
  outline: none;
}

.msg-edit-area:focus { background: #fff; }

.msg-footer-assistant {
  padding: 3px 18px;
  background: rgba(250, 250, 250, 0.5);
  border-radius: 0 0 12px 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 11px;
}

.btn-fork {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--zinc-650);
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-fork:hover {
  background: var(--zinc-100);
  color: var(--fork-hover-text);
}

.btn-fork i { width: 12px; height: 12px; color: var(--ink-default); }

/* Typing Indicator */
.typing-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  margin-right: auto;
  max-width: 90%;
}

.typing-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--zinc-400);
  font-family: 'JetBrains Mono', monospace;
}

.typing-bubble {
  padding: 16px;
  border-radius: 16px 16px 16px 4px;
  font-size: 12px;
  background: var(--zinc-50);
  border: 1px solid var(--zinc-200);
  color: var(--zinc-500);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-dots {
  display: flex;
  gap: 6px;
  padding: 4px 0;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4f46e5;
  animation: bounce 1s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 150ms; }
.typing-dot:nth-child(3) { animation-delay: 300ms; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Chat Input Area */
.chat-input-area {
  border-top: 1px solid var(--zinc-200);
  background: #fff;
  flex-shrink: 0;
  padding: 12px;
}

.chat-input-wrap { position: relative; }

.slash-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 30;
  background: #fff;
  border: 1px solid var(--zinc-250);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden;
  padding: 4px;
}
.slash-hint.hidden { display: none; }

.slash-hint-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.slash-hint-item.active { background: var(--accent-surface); }
.slash-hint-item:hover { background: var(--accent-surface-hover); }

.slash-hint-usage {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--zinc-800);
  white-space: nowrap;
}
.slash-hint-desc {
  font-size: 11px;
  color: var(--zinc-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-textarea {
  width: 100%;
  font-size: 12px;
  padding: 12px;
  padding-right: 56px;
  background: rgba(250,250,250,0.4);
  border: 1px solid var(--zinc-250);
  border-radius: 8px;
  color: var(--zinc-800);
  resize: none;
  min-height: 80px;
  max-height: 280px;
  line-height: 1.625;
  display: block;
}

.chat-textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
  border-color: #3b82f6;
  background: #fff;
}

.textarea-resize-handle {
  height: 0px;
  cursor: ns-resize;
  background: var(--zinc-200);
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.textarea-resize-handle:hover { opacity: 1; }

.textarea-resize-handle::after {
  content: "";
  width: 30px;
  height: 4px;
  background: var(--zinc-500);
  border-radius: 1px;
}

.btn-send {
  position: absolute;
  right: 14px;
  bottom: 14px;
  height: 32px;
  width: 32px;
  padding: 8px;
  border-radius: 8px;
  background: var(--zinc-950);
  color: #fff;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  z-index: 10;
}

.btn-send:hover {
  background: var(--zinc-850);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-send:disabled {
  background: var(--zinc-100);
  color: var(--zinc-400);
  box-shadow: none;
}

.btn-send i { width: 16px; height: 16px; }

/* Token Budget Bar */
.token-budget-bar {
  margin-top: 0px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 8px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--zinc-500);
  background: rgba(250,250,250,0.6);
  padding: 4px 6px;
  border-radius: 4px;
  border: none;
}

.token-budget-labels {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.token-budget-labels span { color: var(--zinc-650); }
.token-budget-labels b { color: var(--zinc-800); }
.token-budget-sep { color: var(--zinc-300); }

.token-budget-total { color: var(--zinc-550); font-weight: 500; }
.token-budget-total b { color: var(--zinc-800); font-weight: 600; }
.token-budget-total b.over-budget { color: #ef4444; font-weight: 700; }

.budget-progress-track {
  width: 100%;
  height: 1.5px;
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 4px;
  background: var(--zinc-100);
}

.budget-progress-fill {
  height: 100%;
  transition: width 0.3s;
  background: #9abeed;
}

.budget-progress-fill.warn { background: #f59e0b; }
.budget-progress-fill.danger { background: #ef4444; }

/* --- Column: Right (Output + Debug + Config) --- */
.col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
}

.col-right.hidden-mobile { display: none; }

/* Sync Panel */
.sync-panel.panel {
  flex: 0 0 auto;
  overflow: hidden;
}

.sync-header {
  cursor: pointer;
  user-select: none;
}

.sync-summary {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--zinc-500);
  margin-left: auto;
}

.sync-chevron {
  color: var(--zinc-400);
  transition: color 0.15s;
  padding: 0;
}

.sync-chevron:hover { color: var(--zinc-600); }

.sync-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.sync-targets {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sync-target-card {
  padding: 6px 8px;
  border: 1px solid var(--zinc-150, #e8e8ec);
  border-radius: 6px;
  background: var(--zinc-50);
  font-size: 11px;
}

.sync-target-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-target-icon {
  font-size: 12px;
  font-weight: 700;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.sync-target-label {
  flex: 1;
  font-weight: 500;
  color: var(--zinc-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-target-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--zinc-400);
  flex-shrink: 0;
}

.sync-progress-bar {
  height: 3px;
  background: var(--zinc-200);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.sync-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.sync-target-pages {
  font-size: 10px;
  color: var(--zinc-400);
  margin-top: 2px;
  text-align: right;
}

.btn-sync-all {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 10px;
  font-weight: 600;
  border-radius: 6px;
  background: var(--accent-surface);
  color: #000;
  transition: background 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-sync-all:hover { background: var(--accent-surface-hover); }

.btn-sync-all:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sync-all i { width: 14px; height: 14px; }

.sync-target-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 4px;
  color: var(--zinc-400);
  transition: all 0.15s;
  flex-shrink: 0;
}
.sync-target-btn:hover { background: var(--zinc-200); color: var(--zinc-700); }
.sync-target-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.sync-target-btn i { width: 11px; height: 11px; }
.sync-target-btn.hidden { display: none; }
.sync-target-stop:hover { color: #ef4444; }

.sync-target-error {
  font-size: 10px;
  color: #ef4444;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-empty {
  text-align: center;
  color: var(--zinc-400);
  font-size: 11px;
  padding: 12px 0;
}

/* Sync command receipts (sync_command_result.v1) */
.sync-cmd-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sync-cmd-results:not(:empty) { margin-bottom: 8px; }
.sync-cmd-result {
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  border: 1px solid transparent;
}
.sync-cmd-ok {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}
.sync-cmd-error {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
}
.sync-cmd-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sync-cmd-icon { flex-shrink: 0; font-weight: 700; }
.sync-cmd-ok .sync-cmd-icon { color: #10b981; }
.sync-cmd-error .sync-cmd-icon { color: #ef4444; }
.sync-cmd-slug {
  font-weight: 600;
  color: var(--zinc-700);
  flex: 1;
}
.sync-cmd-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--zinc-400);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.sync-cmd-dismiss:hover { color: var(--zinc-700); }
.sync-cmd-msg { color: var(--zinc-700); margin-top: 3px; }
.sync-cmd-remedy { color: var(--zinc-500); margin-top: 3px; }
.sync-cmd-debug {
  margin-top: 4px;
  color: var(--zinc-500);
  font-size: 10px;
}
.sync-cmd-debug summary { cursor: pointer; color: var(--zinc-400); }
.sync-cmd-debug > div { margin-top: 2px; word-break: break-word; }
.sync-cmd-debug b { color: var(--zinc-600); }

/* Output/Artifact Panel */
.artifact-panel.panel {
  gap: 12px;
  flex: 1;
  min-height: 120px;
  overflow: hidden;
}

#output-panel {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.btn-clear-artifacts {
  font-size: 10px;
  color: var(--zinc-400);
  transition: color 0.15s;
}

.btn-clear-artifacts:hover { color: #ef4444; }

.artifact-empty {
  background: var(--zinc-50);
  border: 1px dashed var(--zinc-200);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  color: var(--zinc-400);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.artifact-empty i { width: 32px; height: 32px; color: var(--zinc-300); margin-bottom: 6px; }

.artifact-empty h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--zinc-700);
  margin: 0;
}

.artifact-empty p {
  font-size: 10px;
  color: var(--zinc-500);
  max-width: 200px;
  margin-top: 4px;
}

/* Execute Task Cards (Output) */
.output-card {
  border: 1px solid var(--zinc-200);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.output-card .output-title {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  background: var(--zinc-50);
  border-bottom: 1px solid var(--zinc-200);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--zinc-800);
}

.output-card .output-body {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--zinc-600);
  line-height: 1.5;
}

.output-card .output-body ul {
  margin: 4px 0 0;
  padding-left: 16px;
  display: grid;
  gap: 2px;
  color: var(--zinc-700);
  font-size: 11px;
}

.output-card .output-body code {
  font-size: 10px;
  background: var(--zinc-50);
  border: 1px solid var(--zinc-200);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'JetBrains Mono', monospace;
}

.output-actions {
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--zinc-100);
}

.output-actions button {
  font-size: 11px;
  padding: 5px 12px;
  font-weight: 600;
  background: var(--accent-surface);
  color: #000;
  border-radius: 6px;
  transition: all 0.15s;
}

.output-actions button:hover {
  background: var(--accent-surface-hover);
}

.output-actions button.btn-reexecute {
  background: #fff;
  color: var(--zinc-750);
  border: 1px solid var(--zinc-200);
}

.output-actions button.btn-reexecute:hover {
  background: var(--zinc-100);
  color: #000;
}

.output-actions button.btn-reexecute-dated {
  color: var(--accent-700, #1d4ed8);
  border-color: var(--accent-200, #bfdbfe);
}
.output-actions button.btn-reexecute-dated:hover {
  background: var(--accent-50, #eff6ff);
}

.output-actions button:disabled {
  opacity: 0.6;
  cursor: default;
}

.output-daterange {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--zinc-800, #27272a);
  font-family: 'JetBrains Mono', monospace;
}

.output-daterange svg {
  width: 15px;
  height: 15px;
  color: var(--accent-700, #1d4ed8);
  flex-shrink: 0;
}

.output-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--zinc-400, #a1a1aa);
}

.output-error {
  margin-top: 4px;
  font-size: 11px;
  color: #ef4444;
}

.output-error > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  user-select: none;
  padding: 3px 0;
}

.output-error > summary::-webkit-details-marker {
  display: none;
}

.output-error > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 4px;
  transition: transform 0.15s;
}

.output-error[open] > summary::before {
  transform: rotate(90deg);
}

.output-error-body {
  margin-top: 4px;
  padding: 6px 8px;
  background: rgba(239, 68, 68, 0.06);
  border-radius: 6px;
  word-break: break-all;
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.output-actions button.icon-btn {
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  background: #fff;
  color: var(--zinc-750);
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
}

.output-actions button.icon-btn:hover {
  background: var(--zinc-100);
  color: #000;
}

.output-actions button.icon-btn svg {
  width: 14px;
  height: 14px;
}

.output-actions button.icon-btn.icon-btn-accent {
  color: var(--accent-700, #1d4ed8);
  border-color: var(--accent-200, #bfdbfe);
}

.output-actions button.icon-btn.icon-btn-accent:hover {
  background: var(--accent-50, #eff6ff);
}

.output-actions button.icon-btn.icon-btn-danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.output-actions button.icon-btn.icon-btn-danger:hover {
  background: #fef2f2;
  color: #991b1b;
}

.output-actions .spin {
  animation: icon-btn-spin 0.9s linear infinite;
}

@keyframes icon-btn-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.output-actions .tn-group {
  display: inline-flex;
  align-items: stretch;
}

.output-actions .tn-select {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-700, #1d4ed8);
  background: #fff;
  border: 1px solid var(--accent-200, #bfdbfe);
  border-right: none;
  border-radius: 6px 0 0 6px;
  padding: 0 4px;
  cursor: pointer;
}

.output-actions .tn-group button.icon-btn {
  border-radius: 0 6px 6px 0;
}

.task-status {
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--zinc-200);
  background: var(--zinc-50);
  border-radius: 9999px;
  padding: 1px 7px;
  white-space: nowrap;
  color: var(--zinc-600);
}

.task-status.done { color: #065f46; border-color: #86efac; background: #ecfdf5; }
.task-status.failed { color: #991b1b; border-color: #fecaca; background: #fef2f2; }
.task-status.running { color: #7c2d12; border-color: #fdba74; background: #fff7ed; }

.output-status {
  text-align: center;
  padding: 20px 10px;
  color: var(--zinc-400);
  font-size: 12px;
  border: 1px dashed var(--zinc-200);
  border-radius: 8px;
  background: #fff;
}

.output-status .spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--zinc-200);
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}

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

/* Debug Payload Panel */
.debug-panel.panel {
  gap: 10px;
}

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

.btn-debug-action {
  padding: 4px;
  border-radius: 4px;
  color: var(--zinc-400);
  transition: all 0.15s;
}

.btn-debug-action:hover {
  background: var(--zinc-100);
  color: var(--zinc-750);
}

.btn-debug-action i { width: 12px; height: 12px; }

.btn-debug-toggle {
  padding: 4px;
  border-radius: 4px;
  color: var(--zinc-500);
  transition: all 0.15s;
}

.btn-debug-toggle:hover {
  color: var(--zinc-900);
  background: var(--accent-surface);
}

.btn-debug-toggle i { width: 14px; height: 14px; }

.debug-description {
  font-size: 11.5px;
  color: var(--zinc-500);
  margin: 0;
}

.debug-prompt-box {
  background: var(--zinc-50);
  border: 1px solid var(--zinc-200);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.debug-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--zinc-150);
  padding: 6px 12px;
  font-size: 10.5px;
  color: var(--zinc-700);
  font-family: 'JetBrains Mono', monospace;
  border-bottom: 1px solid var(--zinc-200);
}

.debug-prompt-header span { font-weight: 600; }

.btn-copy-prompt {
  font-size: 10px;
  color: #4338ca;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 2px;
}

.btn-copy-prompt:hover { color: #312e81; }

.debug-prompt-body {
  padding: 10px;
  max-height: 220px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--zinc-700);
  background: rgba(250,250,250,0.5);
  white-space: pre-wrap;
  line-height: 1.625;
  user-select: text;
  margin: 0;
}

.debug-collapsed-msg {
  font-size: 11px;
  color: var(--zinc-400);
  background: var(--zinc-50);
  border: 1px solid var(--zinc-150);
  padding: 10px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
}

.draft-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--amber-600, #d97706);
  background: var(--amber-50, #fffbeb);
  border: 1px solid var(--amber-200, #fde68a);
  border-radius: 3px;
  padding: 1px 5px;
}

.btn-accent.has-draft {
  background: var(--amber-500, #f59e0b);
  animation: pulse-save 1.5s ease-in-out infinite;
}
@keyframes pulse-save {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.debug-history-section {
  margin-top: 8px;
}
.debug-history-section summary {
  font-size: 11px;
  color: var(--zinc-400);
  cursor: pointer;
  padding: 4px 0;
  font-family: 'JetBrains Mono', monospace;
}
.debug-history-item {
  margin-top: 6px;
  opacity: 0.7;
}

/* Dev Mode Panel (left column, collapsible) */
.devmode-panel.panel {
  gap: 0;
  flex: 0 0 auto;
}

.devmode-header {
  cursor: pointer;
}

.devmode-header:hover {
  background: var(--zinc-50);
  border-radius: 8px;
}

.devmode-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 12px;
  max-height: 50vh;
  overflow-y: auto;
}

.devmode-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.devmode-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--zinc-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--zinc-100);
}

/* API Config Panel */
.config-panel.panel {
  gap: 14px;
}

.config-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--zinc-100);
  padding: 4px;
  border-radius: 8px;
}

.config-mode-btn {
  padding: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  transition: all 0.15s;
  color: var(--zinc-500);
  border: 1px solid transparent;
}

.config-mode-btn:hover { color: var(--zinc-800); }

.config-mode-btn.active {

  background: #fff;
  color: var(--zinc-900);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.config-mode-btn.active.api-mode {
  color: var(--accent-text);

}

.config-section { display: flex; flex-direction: column; gap: 12px; }

.config-info-box {
  background: var(--zinc-50);
  border: 1px solid var(--zinc-200);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  color: var(--zinc-600);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-info-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--zinc-800);
}

.config-info-title i { width: 14px; height: 14px; color: var(--zinc-600); }

.config-info-text {
  font-size: 11px;
  color: var(--zinc-500);
  line-height: 1.5;
  margin: 0;
}

.config-field { display: flex; flex-direction: column; gap: 2px; }

.config-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--zinc-500);
}

.config-input {
  width: 100%;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
  padding: 8px;
  background: var(--zinc-50);
  color: var(--zinc-850);
}

.config-input:focus {
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 1px #818cf8;
}

.config-select {
  width: 100%;
  font-size: 12px;
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  color: var(--zinc-800);
}

.config-select:focus {
  outline: none;
  box-shadow: 0 0 0 1px #818cf8;
}

.config-select:disabled {
  background: var(--zinc-50);
  color: var(--zinc-400);
  cursor: not-allowed;
}

.config-model-filter {
  width: 100%;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
  padding: 6px 8px;
  background: var(--zinc-50);
  color: var(--zinc-800);
  margin-top: 4px;
}

.config-model-filter:focus {
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 1px #818cf8;
}

.config-model-count {
  font-size: 10px;
  color: var(--zinc-400);
  font-weight: 400;
}

.btn-test-connection {
  width: 100%;
  font-size: 11px;
  padding: 6px;
  background: #000000 !important;
  color: #fff;
  border-radius: 4px;
  font-weight: 500;
  transition: background 0.15s;
  margin-top: 6px;
}

.btn-test-connection:hover { background: var(--zinc-800); }
.btn-test-connection:disabled { opacity: 0.5; }

.api-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
  display: inline-block;
  transition: background 0.3s;
  flex-shrink: 0;
}

.api-status-dot.ok { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2); }
.api-status-dot.fail { background: #ef4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2); }
.api-status-dot.testing { background: #f59e0b; animation: pulse-dot 1s infinite; }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

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

.config-hint {
  font-size: 10px;
  color: var(--zinc-400);
  line-height: 1.5;
  margin: 0;
  padding-top: 4px;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--zinc-200);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  max-width: 384px;
  width: 100%;
  padding: 20px;
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--zinc-900);
  margin: 0 0 8px;
}

.modal-desc {
  font-size: 12px;
  color: var(--zinc-500);
  margin: 0 0 16px;
}

.modal-input {
  width: 100%;
  font-size: 12px;
  border: 1px solid var(--zinc-200);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 16px;
  color: var(--zinc-800);
}

.modal-input:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--zinc-400);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  font-size: 12px;
}

.btn-modal-cancel {
  padding: 6px 12px;
  color: var(--zinc-500);
  background: var(--zinc-100);
  border-radius: 4px;
}

.btn-modal-cancel:hover { background: var(--zinc-150); }

.btn-modal-confirm {
  padding: 6px 12px;
  color: #fff;
  background: var(--zinc-900);
  border-radius: 4px;
  font-weight: 500;
}

.btn-modal-confirm:hover { background: var(--zinc-850); }

/* --- Responsive --- */
@media (min-width: 640px) {
  .token-budget-bar { font-size: 11px; }
}

@media (min-width: 1280px) {
  body { height: 100dvh; overflow: hidden; }

  .app-shell { height: 100dvh; overflow: hidden; }

  .mobile-tabs { display: none; }

  .main-grid {
    grid-template-columns: 2fr 7fr 3fr;
    gap: 16px;
    padding: 16px;
    overflow: hidden;
  }

  .col-left, .col-center {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .col-left {
    overflow-y: auto;
  }

  .col-right {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .col-left.hidden-mobile,
  .col-center.hidden-mobile,
  .col-right.hidden-mobile {
    display: flex;
  }

  .config-panel.panel {
    flex: 0 0 auto;
    min-height: 0;
  }

  .session-panel.panel {
    flex: 0 0 auto;
    min-height: 80px;
    max-height: 32%;
    overflow-y: auto;
  }

  .devmode-panel.panel {
    flex: 0 0 auto;
    min-height: 0;
  }

  .artifact-panel.panel { flex: 1 1 0; min-height: 0; }

  h2 {
    display: block;
    font-size: 15px;
    margin-block-start: 0.83em;
    margin-block-end: 0.83em;
    margin-inline-start: 0;
    margin-inline-end: 0;
    font-weight: bold;
    unicode-bidi: isolate;
  }

  svg {
    width: 12px !important;
    height: 12px!important;
    background: #ffffff00
    fill: none;
    stroke: currentcolor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}


/* ===== Generic utility ===== */
.hidden { display: none !important; }

/* ===== Main-column bookmark tabs (对话 | routine) — 浏览器书签样式 ===== */
/* 标签像浏览器 tab：只有上方圆角，激活页与下方内容面板连成一体。 */
.main-tabs {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
  padding-left: 6px;
  margin-bottom: -1px;          /* 盖住下方面板的顶边，形成连体 */
  position: relative;
  z-index: 2;
}

/* 印度时间时钟：T-n 与同步口径的锚点，常驻标签行右侧 */
.ist-clock {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  margin-right: 6px;
  padding-bottom: 8px;          /* 与 tab 文字基线对齐 */
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--zinc-500);
  cursor: default;
  white-space: nowrap;
}
.ist-clock i, .ist-clock svg { width: 13px; height: 13px; }
.main-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--zinc-500);
  background: var(--zinc-100);
  border: 1px solid var(--zinc-200);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  position: relative;
  top: 2px;                     /* 未激活的页略微下沉 */
  transition: background 0.15s, color 0.15s, top 0.15s;
}
.main-tab-btn:hover { color: var(--zinc-700); background: var(--zinc-150); }
.main-tab-btn.active {
  color: var(--zinc-900);
  background: #fff;             /* 与内容面板同色 */
  border-color: var(--zinc-200);
  top: 0;
  z-index: 3;
}
/* 激活页底边盖掉面板顶边的那一段，接缝消失 */
.main-tab-btn.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: #fff;
}
.main-tab-btn i { width: 15px; height: 15px; }

/* tab 下的内容面板顶部改为平角，与书签衔接 */
.chat-panel,
.routine-panel {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* ===== Routine panel ===== */
.routine-panel {
  flex: 1;
  background: #fff;
  border: 1px solid var(--zinc-200);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  min-height: 0;
}

.routine-empty-hint {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--zinc-400);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}
.routine-empty-hint i { width: 32px; height: 32px; opacity: 0.5; }
.routine-empty-hint .routine-empty-sub { font-size: 12px; color: var(--zinc-400); }

.routine-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.routine-def {
  padding: 14px 16px;
  border-bottom: 1px solid var(--zinc-200);
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 60%;
}

.routine-name-input {
  width: 100%;
  font-size: 15px;
  font-weight: 700;
  color: var(--zinc-900);
  border: none;
  border-bottom: 1px solid transparent;
  padding: 4px 0;
  outline: none;
}
.routine-name-input:focus { border-bottom-color: var(--zinc-300); }

.routine-field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--zinc-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 12px 0 5px;
}
.routine-inline-label { margin: 0; }

.routine-sql-input {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--zinc-800);
  background: var(--zinc-50);
  border: 1px solid var(--zinc-200);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  resize: vertical;
  min-height: 90px;
}
.routine-sql-input:focus { border-color: var(--zinc-400); }

.routine-depends {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.depend-chip {
  font-size: 12px;
  font-weight: 500;
  color: var(--zinc-600);
  background: var(--zinc-100);
  border: 1px solid var(--zinc-200);
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
  transition: all 0.12s;
}
.depend-chip:hover { border-color: var(--zinc-400); }
.depend-chip.on {
  color: var(--accent-text);
  background: var(--accent-surface);
  border-color: var(--accent-border);
}
.routine-hint { font-size: 12px; color: var(--zinc-400); }

.routine-def-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.routine-freq-select {
  font-size: 12px;
  color: var(--zinc-700);
  background: #fff;
  border: 1px solid var(--zinc-300);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}
.routine-freq-hint { font-size: 11px; color: var(--zinc-400); }

/* 执行时间（IST）：与频率并排 */
.routine-time-label { margin-left: 4px; }
.routine-time-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.routine-time-group.disabled { opacity: 0.4; }
.routine-time-input {
  font-size: 12px;
  color: var(--zinc-700);
  background: #fff;
  border: 1px solid var(--zinc-300);
  border-radius: 6px;
  padding: 3px 6px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.routine-time-input:disabled { cursor: not-allowed; background: var(--zinc-100); }
.routine-time-tz {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-700, #1d4ed8);
  white-space: nowrap;
}

.routine-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.routine-run-group { display: inline-flex; align-items: stretch; }
.routine-run-group .tn-select {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  background: #fff;
  border: 1px solid var(--accent-border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  padding: 0 6px;
  cursor: pointer;
}
.btn-run-routine {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--zinc-950);
  border: 1px solid var(--zinc-950);
  border-radius: 0 8px 8px 0;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-run-routine:hover { background: var(--zinc-800); }
.btn-run-routine:disabled { background: var(--zinc-300); border-color: var(--zinc-300); cursor: default; }
.btn-run-routine i { width: 14px; height: 14px; }

.routine-runs-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--zinc-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 16px 6px;
  flex-shrink: 0;
}
.routine-runs-header i { width: 13px; height: 13px; }

.routine-runs {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
  min-height: 0;
}
.routine-run-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s;
}
.routine-run-item:hover { background: var(--zinc-50); }
.routine-run-item.active {
  background: var(--accent-surface);
  border-color: var(--accent-border);
}
.routine-run-item .run-status { font-size: 13px; flex-shrink: 0; }
.routine-run-item .run-time { font-size: 12px; color: var(--zinc-700); font-weight: 500; }
.routine-run-item .run-meta { font-size: 11px; color: var(--zinc-400); margin-left: auto; }

.list-empty {
  font-size: 12px;
  color: var(--zinc-400);
  padding: 12px 4px;
  text-align: center;
}

/* ===== 默认『数据同步』routine 视图 ===== */
.routine-sync-item .session-title-display i { color: var(--zinc-500); }
.routine-sync-item.active .session-title-display i { color: #000; }

.routine-sync-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--zinc-900);
  padding: 4px 0 2px;
}
.routine-sync-title i { width: 17px; height: 17px; }
.routine-sync-pin {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-surface);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  padding: 1px 9px;
}
.routine-sync-goal {
  font-size: 12px;
  color: var(--zinc-500);
  margin: 8px 0 12px;
}
.routine-sync-coverage {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sync-cov-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 7px;
  background: var(--zinc-50);
  border: 1px solid var(--zinc-150);
  font-size: 12px;
}
.sync-cov-row.ok { border-color: #bbf7d0; background: #f0fdf4; }
.sync-cov-row.behind { border-color: #fde68a; background: #fffbeb; }
.sync-cov-row .cov-mark { font-size: 12px; }
.sync-cov-row .cov-name { font-weight: 600; color: var(--zinc-800); }
.sync-cov-row .cov-date { margin-left: auto; color: var(--zinc-500); }

.routine-sync-guard-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--zinc-500);
}
.guard-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.18);
  animation: guard-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes guard-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.btn-run-routine.guard-on { background: #b91c1c; border-color: #b91c1c; }
.btn-run-routine.guard-on:hover { background: #991b1b; }
#btn-run-sync { border-radius: 8px; }
