/* BizSage v2 — style.css (new layout) */

:root {
  --bg: #181816;
  --bg-sidebar: #1f1e1b;
  --bg-input: #2b2a27;
  --bg-message: #242320;
  --bg-user: #2b2a27;
  --border: #383632;
  --border-subtle: #302e2a;
  --text: #ece8e0;
  --text-muted: #9a9488;
  --accent: #c49a6c;
  --accent-hover: #d4ad82;
  --success: #4caf50;
  --error: #ef5350;
  --warning: #ffa726;
  --error-hover: #ff6e6a;
  --accent-faint: rgba(196,154,108,0.15);
  --accent-subtle: rgba(196,154,108,0.05);
  --accent-shadow: rgba(196,154,108,0.25);
  --accent-tint: rgba(196,154,108,0.04);
  --error-faint: rgba(248,81,73,0.15);
  --error-hover-faint: rgba(248,81,73,0.3);
  --error-subtle: rgba(239,83,80,0.1);
  --error-shadow: rgba(248,81,73,0.25);
  --warning-faint: rgba(255,167,38,0.1);
  --code-bg: rgba(120,112,98,0.15);
  --shadow-color: rgba(0,0,0,0.3);
  --icon-green: #3fb950;
  --icon-red: #f85149;
  --icon-yellow: #d29922;
  --icon-gray: #8b949e;
  --font: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --topbar-h: 48px;
  --panel-w: 260px;
}

/* Light theme */
[data-theme="light"] {
  --bg: #f5f3ef;
  --bg-sidebar: #eae7e1;
  --bg-input: #ffffff;
  --bg-message: #ffffff;
  --bg-user: #f0ede7;
  --border: #d4d0c8;
  --border-subtle: #e0ddd6;
  --text: #1a1918;
  --text-muted: #6b6560;
  --accent: #a07040;
  --accent-hover: #8a5e30;
  --success: #2e7d32;
  --error: #c62828;
  --warning: #e65100;
  --error-hover: #d32f2f;
  --accent-faint: rgba(160,112,64,0.12);
  --accent-subtle: rgba(160,112,64,0.06);
  --accent-shadow: rgba(160,112,64,0.2);
  --accent-tint: rgba(160,112,64,0.04);
  --error-faint: rgba(198,40,40,0.1);
  --error-hover-faint: rgba(198,40,40,0.2);
  --error-subtle: rgba(198,40,40,0.08);
  --error-shadow: rgba(198,40,40,0.15);
  --warning-faint: rgba(230,81,0,0.08);
  --code-bg: rgba(100,92,80,0.08);
  --shadow-color: rgba(0,0,0,0.08);
  --icon-green: #2e7d32;
  --icon-red: #c62828;
  --icon-yellow: #b8860b;
  --icon-gray: #6b7280;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  transition: background-color 0.3s, color 0.3s;
}

/* ===================== */
/* App Layout (Grid)     */
/* ===================== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#content-area {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* ===================== */
/* Top Bar               */
/* ===================== */
#top-bar {
  height: var(--topbar-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 20;
}

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

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.brand-badge {
  background: var(--accent);
  color: var(--bg);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

/* Sidebar Selectors */
.sidebar-selects {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-select-row {
  margin-bottom: 8px;
}
.sidebar-select-row:last-child {
  margin-bottom: 0;
}

.sidebar-select-row > label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sidebar-select-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-picker-btn {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}
.sidebar-picker-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-btn-add {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.sidebar-btn-add:hover {
  background: var(--accent-hover);
}

.topbar-btn {
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.topbar-btn:hover {
  color: var(--text);
  background: var(--bg-input);
  border-color: var(--border);
}

/* Create project popover */
.create-project-popover {
  min-width: 260px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.create-project-popover input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  box-sizing: border-box;
}

.create-project-popover input:focus {
  border-color: var(--accent);
}

.create-project-popover-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.btn-sm {
  padding: 5px 14px;
  font-size: 12px;
}

/* Settings popover */
.settings-popover {
  position: fixed;
  width: 280px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px var(--shadow-color);
  z-index: 200;
  overflow: hidden;
}

.settings-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.settings-popover-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.settings-popover-close:hover { color: var(--text); }

.settings-popover-body {
  padding: 12px 16px 16px;
}

.settings-popover-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 10px;
  margin-bottom: 4px;
}

.settings-popover-body label:first-child { margin-top: 0; }

.settings-popover-body select,
.settings-popover-body input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.settings-popover-body select:focus,
.settings-popover-body input:focus {
  border-color: var(--accent);
}

/* Sidebar footer (settings) */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  padding: 8px 12px;
}

.sidebar-settings-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  transition: color 0.15s, background 0.15s;
}

.sidebar-settings-btn:hover {
  color: var(--text);
  background: var(--bg-input);
}

/* ===================== */
/* Sidebar Tabs          */
/* ===================== */
.sidebar-tabs {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.sidebar-tab:hover {
  color: var(--text);
  background: var(--bg-input);
}

.sidebar-tab.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-faint);
}

.sidebar-tab svg { flex-shrink: 0; }

@media (min-width: 769px) {
  .panel-tab-title { display: none; }
}

/* ===================== */
/* Side Panel            */
/* ===================== */
#side-panel {
  width: var(--panel-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s ease, margin-left 0.2s ease;
}

#side-panel.collapsed {
  width: 0;
  border-right: none;
  overflow: hidden;
}

.panel-tab {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.panel-tab.active {
  display: flex;
}

.panel-tab-header {
  padding: 12px 14px 8px;
  flex-shrink: 0;
}

.panel-tab-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.panel-tab-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 14px 14px;
}

/* ===================== */
/* Drop zone             */
/* ===================== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 8px;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.drop-zone input[type="file"] { display: none; }

/* ===================== */
/* File list             */
/* ===================== */
.file-list {
  list-style: none;
  margin-top: 4px;
}

.file-list li {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 28px 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  border-radius: 6px;
  transition: background 0.15s;
}
.file-list li:hover {
  background: var(--bg-input);
}

.file-list li .file-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.file-list li .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list li .file-size {
  color: var(--text-muted);
  font-size: 11px;
}

/* Section label separator */
.file-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 10px 8px 4px;
  cursor: default;
  display: flex;
  align-items: center;
  gap: 6px;
}
.file-section-label::before {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.file-section-text {
  flex-shrink: 0;
}
.file-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.file-section-label:hover {
  background: transparent;
}

.file-menu-btn {
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.file-list li:hover .file-menu-btn { opacity: 1; }
.file-menu-btn:hover { background: var(--border); color: var(--text); }

/* Preview active state */
.file-list li.preview-active {
  background: var(--accent-faint);
  color: var(--accent);
}

/* ===================== */
/* Segmented Control     */
/* ===================== */
.segmented-control {
  display: flex;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 2px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.seg-btn {
  flex: 1;
  padding: 6px 8px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

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

.seg-btn.active {
  background: var(--accent-faint);
  color: var(--accent);
  font-weight: 600;
}

.segment-content {
  display: none;
}

.segment-content.active {
  display: block;
}

/* ===================== */
/* Connection list       */
/* ===================== */
.connection-list {
  list-style: none;
}

.connection-list li {
  padding: 8px 10px;
  margin-bottom: 4px;
  background: var(--bg-input);
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.connection-list li:hover {
  background: var(--border);
}

.connection-list .conn-info {
  flex: 1;
  min-width: 0;
}

.connection-list .conn-alias {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-list .conn-type {
  font-size: 11px;
  color: var(--text-muted);
}

/* Inline project checkbox */
.conn-project-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.conn-project-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.conn-project-toggle label {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 3px;
  cursor: pointer;
  white-space: nowrap;
}

/* DB type badges */
.db-type-badge {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
}

.db-type-badge.postgres { background: rgba(0,122,204,0.15); color: #4dabf5; }
.db-type-badge.mysql { background: rgba(255,148,38,0.15); color: #ffa726; }
.db-type-badge.mssql { background: rgba(204,30,30,0.15); color: #ef5350; }
.db-type-badge.api { background: rgba(76,175,80,0.15); color: #4caf50; }

.db-alias-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 13px;
}

.db-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.connection-list li:hover .db-menu-btn { opacity: 1; }
.db-menu-btn:hover { background: var(--border); color: var(--text); }

/* ===================== */
/* History               */
/* ===================== */
.history-search {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  margin-top: 6px;
  transition: border-color 0.15s;
}

.history-search:focus {
  border-color: var(--accent);
}

.history-list {
  list-style: none;
  margin-top: 8px;
}

.history-list li {
  padding: 8px 8px 8px 12px;
  margin-bottom: 4px;
  background: var(--bg-input);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
  position: relative;
}

.history-list li:hover {
  background: var(--border);
}

.history-list li.active {
  background: var(--border);
  border-left: 2px solid var(--accent);
}

.history-list li .hist-question {
  color: var(--text);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-list li .hist-meta {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}

/* Menu "..." button */
.hist-menu-btn {
  position: absolute;
  top: 6px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.history-list li:hover .hist-menu-btn { opacity: 1; }
.hist-menu-btn:hover { background: var(--border); color: var(--text); }

/* Context menu popover */
.ctx-menu {
  position: absolute;
  top: 100%;
  right: 4px;
  z-index: 50;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  min-width: 140px;
  box-shadow: 0 4px 16px var(--shadow-color);
}

.ctx-menu-up {
  top: auto;
  bottom: 100%;
}

.ctx-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.ctx-option:hover { background: var(--bg-input); }
.ctx-option.ctx-danger { color: var(--error); }
.ctx-option.ctx-danger:hover { background: var(--error-subtle); }

/* Inline rename input */
.ctx-rename-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 4px 8px;
  outline: none;
}

/* ===================== */
/* Buttons               */
/* ===================== */
.btn-primary {
  padding: 8px 20px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-shadow);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  width: 100%;
  padding: 6px 12px;
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

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

.btn-danger {
  width: 100%;
  padding: 6px 12px;
  margin-top: 6px;
  background: var(--error-faint);
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

.btn-danger:hover {
  background: var(--error-hover-faint);
}

/* ===================== */
/* Main content          */
/* ===================== */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

#messages {
  max-width: 800px;
  margin: 0 auto;
}

/* ===================== */
/* Welcome Screen        */
/* ===================== */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 40px 20px;
  animation: fadeIn 0.5s ease-out;
}

.welcome-logo {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.welcome-logo .welcome-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--bg);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  vertical-align: super;
  margin-left: 4px;
}

.welcome-description {
  color: var(--text-muted);
  font-size: 16px;
  margin: 12px 0 28px;
  max-width: 480px;
  line-height: 1.6;
}

.welcome-tips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 32px;
  font-size: 14px;
  color: var(--text-muted);
}

.welcome-tips span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.welcome-tips .tip-icon {
  color: var(--accent);
  font-size: 16px;
  flex-shrink: 0;
}

/* ===================== */
/* Messages              */
/* ===================== */
.message {
  margin-bottom: 20px;
  padding: 24px;
  border-radius: var(--radius-lg);
  line-height: 1.6;
  font-size: 16px;
  transition: box-shadow 0.2s;
}

.message.user {
  background: var(--bg-user);
}

.message.assistant {
  background: var(--bg-message);
}

.message.assistant:hover {
  box-shadow: 0 2px 12px var(--shadow-color);
}

.message.system-msg {
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 16px;
}

.message.error-msg {
  background: var(--error-subtle);
  color: var(--error);
}

.message-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Markdown rendering in messages */
.message h1, .message h2, .message h3, .message h4 {
  margin: 16px 0 8px;
  font-weight: 600;
}

.message h1 { font-size: 22px; }
.message h2 { font-size: 19px; }
.message h3 { font-size: 16px; }

.message p { margin: 8px 0; }

.message ul, .message ol {
  padding-left: 24px;
  margin: 8px 0;
}

.message li { margin: 4px 0; }

/* Tables */
.message table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0;
  width: 100%;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.message th, .message td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
}

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

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

.message th {
  background: var(--bg-sidebar);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.message tbody tr:hover {
  background: var(--accent-tint);
}

/* Code */
.message code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.message pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
  margin: 12px 0;
  position: relative;
}

.message pre code {
  background: none;
  padding: 0;
}

/* Plotly interactive charts */
.plotly-chart {
  width: 100%;
  margin: 1rem 0;
  min-height: 300px;
  border-radius: var(--radius);
}

/* Language label on code blocks */
.code-lang-label {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--border);
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font);
  padding: 2px 8px;
  border-radius: var(--radius) 0 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* Copy button per code block */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 8px;
  font-size: 11px;
  font-family: var(--font);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: var(--border); color: var(--text); }
.code-copy-btn.copied { color: var(--success); border-color: var(--success); }

/* Override highlight.js background */
.message pre code.hljs { background: transparent !important; padding: 0 !important; }
.preview-markdown pre code.hljs { background: transparent !important; padding: 0 !important; }

/* KaTeX */
.message .katex { color: var(--text); }
.message .katex-display { margin: 12px 0; overflow-x: auto; }
.preview-markdown .katex { color: var(--text); }
.preview-markdown .katex-display { margin: 12px 0; overflow-x: auto; }

/* Nested lists */
.message ul ul, .message ol ol, .message ul ol, .message ol ul { margin: 4px 0; }
.preview-markdown ul ul, .preview-markdown ol ol, .preview-markdown ul ol, .preview-markdown ol ul { margin: 4px 0; }

.message blockquote {
  border-left: 3px solid var(--border);
  padding-left: 12px;
  color: var(--text-muted);
  margin: 8px 0;
}

.message strong { font-weight: 600; }

.message hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Streaming cursor */
.streaming-cursor::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent);
  animation: blink 1s step-end infinite;
  margin-left: 2px;
  vertical-align: text-bottom;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ===================== */
/* Input area            */
/* ===================== */
#input-area {
  padding: 16px 24px 12px;
  background: var(--bg);
  border-top: none;
}

.input-container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

#question-input {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--radius-xl);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  padding: 16px 20px;
  resize: none;
  outline: none;
  min-height: 56px;
  line-height: 1.5;
  overflow-y: hidden;
  max-height: 240px;
}

/* ---- Bottom action row ---- */
.input-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 8px;
  gap: 6px;
  min-height: 44px;
}
.input-actions-left,
.input-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Shared pill button */
.input-action-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.input-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-faint);
}
.input-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.input-action-btn svg { flex-shrink: 0; }

/* Accent variant (Preparar/Análise) */
.btn-extract-accent {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-faint);
}
.btn-extract-accent:hover { background: var(--accent); color: #fff; }
.btn-extract-accent:hover svg { stroke: #fff; }
.btn-extract-accent.has-new::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-left: 2px;
}

/* Muted variant (model picker) */
.input-action-btn-muted {
  color: var(--text-muted);
  border-color: transparent;
  background: transparent;
}
.input-action-btn-muted:hover {
  background: var(--accent-faint);
  border-color: transparent;
  color: var(--accent);
}

/* Send button (circular) */
.btn-send-icon {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s; flex-shrink: 0;
}
.btn-send-icon:hover { background: var(--accent-hover); transform: scale(1.05); }
.btn-send-icon:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-send-icon.btn-stop { background: var(--error); }
.btn-send-icon.btn-stop:hover { background: var(--error-hover); }

/* ---- Dropdown / Popover ---- */
.input-dropdown { position: relative; }
.input-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 200px; max-width: 320px; max-height: 280px;
  overflow-y: auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px var(--shadow-color);
  z-index: 100;
  padding: 4px;
}
.input-popover-right { left: auto; right: 0; }
.input-popover-down {
  bottom: auto;
  top: calc(100% + 6px);
}
#side-panel .input-popover {
  position: fixed;
  z-index: 110;
}
#suggestions-popover { min-width: 260px; max-width: 400px; }
#model-popover { max-height: 480px; }

/* Popover items */
.popover-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: none; border: none; border-radius: 8px;
  color: var(--text); font-size: 13px; cursor: pointer;
  transition: background 0.15s; text-align: left;
}
.popover-item:hover { background: var(--accent-faint); }
.popover-item.active { background: var(--accent-faint); color: var(--accent); font-weight: 600; }
.popover-item-icon { flex-shrink: 0; font-size: 15px; }
.popover-item-check { margin-left: auto; color: var(--accent); font-size: 14px; }

.input-footer {
  max-width: 800px;
  margin: 6px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 8px;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status.idle { color: var(--text-muted); }
.status.idle::before { background: var(--text-muted); }
.status.running { color: var(--accent); }
.status.running::before { background: var(--accent); animation: blink 1s step-end infinite; }
.status.done { color: var(--success); }
.status.done::before { background: var(--success); }
.status.error { color: var(--error); }
.status.error::before { background: var(--error); }

/* ===================== */
/* Copy / Save buttons   */
/* ===================== */
.btn-copy {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.message:hover .btn-copy { opacity: 1; }
.btn-copy:hover { background: var(--border); color: var(--text); }
.btn-copy.copied { color: var(--success); border-color: var(--success); }

.btn-save {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  margin-top: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font);
  transition: all 0.15s;
}
.btn-save:hover { border-color: var(--accent); color: var(--accent); }
.btn-save.saved { border-color: var(--success); color: var(--success); cursor: default; }
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

.message-meta {
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 0 0;
  margin-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

/* ===================== */
/* Preview Panel (Drawer)*/
/* ===================== */
.preview-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 40;
}

.preview-backdrop.open {
  display: block;
}

.preview-panel {
  width: 0;
  max-width: 75vw;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease;
  box-shadow: -4px 0 24px var(--shadow-color);
  flex-shrink: 0;
}

.preview-panel.open {
  width: min(var(--preview-width, 40vw), 75vw);
}

/* Resize handle */
.preview-resize-handle {
  position: absolute;
  top: 0;
  left: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}

.preview-resize-handle:hover,
.preview-resize-handle.active {
  background: var(--accent);
  opacity: 0.4;
}

.preview-panel.resizing {
  transition: none;
}

body.col-resizing {
  cursor: col-resize !important;
  user-select: none;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.preview-file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

#preview-filename {
  font-weight: 500;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#preview-file-size {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.btn-pdf-download {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-pdf-download:hover {
  background: var(--accent);
  color: #fff;
}

.btn-pdf-download:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#btn-close-preview {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
  transition: all 0.15s;
}

#btn-close-preview:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

#preview-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

/* Preview sub-types */
.preview-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: var(--text-muted);
  font-size: 14px;
}

.preview-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  color: var(--error);
  text-align: center;
}

.preview-error-icon {
  font-size: 28px;
}

.preview-truncated {
  background: var(--warning-faint);
  color: var(--warning);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.preview-sheet-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.preview-sheet-tab {
  padding: 4px 12px;
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.preview-sheet-tab.active {
  background: var(--accent-faint);
  border-color: var(--accent);
  color: var(--accent);
}

.preview-table-wrapper {
  overflow-x: auto;
}

.preview-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.preview-table th,
.preview-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-table th:last-child,
.preview-table td:last-child {
  border-right: none;
}

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

.preview-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 11px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.preview-table tbody tr:hover {
  background: var(--accent-tint);
}

.preview-json {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}

.preview-markdown {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.preview-markdown h1, .preview-markdown h2, .preview-markdown h3 {
  margin: 16px 0 8px;
  font-weight: 600;
}
.preview-markdown h1 { font-size: 20px; }
.preview-markdown h2 { font-size: 17px; }
.preview-markdown h3 { font-size: 15px; }
.preview-markdown p { margin: 8px 0; }
.preview-markdown ul, .preview-markdown ol { padding-left: 24px; margin: 8px 0; }
.preview-markdown li { margin: 4px 0; }
.preview-markdown pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
  margin: 12px 0;
  position: relative;
}
.preview-markdown pre code { background: none; padding: 0; }
.preview-markdown code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.preview-markdown table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0;
  width: 100%;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.preview-markdown th, .preview-markdown td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
}
.preview-markdown th:last-child, .preview-markdown td:last-child { border-right: none; }
.preview-markdown tbody tr:last-child td { border-bottom: none; }
.preview-markdown th {
  background: var(--bg-sidebar);
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
}
.preview-markdown blockquote {
  border-left: 3px solid var(--border);
  padding-left: 12px;
  color: var(--text-muted);
  margin: 8px 0;
}
.preview-markdown img { max-width: 100%; border-radius: var(--radius); }

.preview-text {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}

.preview-pdf {
  width: 100%;
  height: 100%;
  border: none;
}

.preview-html-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* Schema browser */
.schema-table-list {
  list-style: none;
}

.schema-table-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  transition: background 0.15s;
}

.schema-table-list li:hover {
  background: var(--bg-input);
}

.schema-table-icon {
  color: var(--text-muted);
  display: flex;
}

.schema-columns {
  padding: 0 12px;
}

.schema-columns table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.schema-columns th,
.schema-columns td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
}

.schema-columns th:last-child,
.schema-columns td:last-child { border-right: none; }
.schema-columns tbody tr:last-child td { border-bottom: none; }
.schema-columns th {
  background: var(--bg);
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ===================== */
/* Modal                 */
/* ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 64px var(--shadow-color);
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

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

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

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 10px;
  margin-bottom: 4px;
}

.modal-body label:first-child { margin-top: 0; }

.modal-body input,
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  border-color: var(--accent);
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.db-test-result {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.db-test-result.testing {
  background: var(--accent-faint);
  color: var(--accent);
}

.db-test-result.success {
  background: rgba(76,175,80,0.1);
  color: var(--success);
}

.db-test-result.error {
  background: var(--error-faint);
  color: var(--error);
}

/* DB checkboxes (legacy compat) */
.db-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.db-checkboxes label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 0;
}

/* ===================== */
/* Mobile Bottom Tab Bar */
/* ===================== */
#mobile-tab-bar {
  height: 56px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-subtle);
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
  z-index: 35;
  position: relative;
}

.mobile-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 8px;
  transition: color 0.15s;
  font-size: 10px;
}

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

.mobile-tab.active {
  color: var(--accent);
}

.mobile-tab span {
  font-size: 10px;
}

/* ===================== */
/* Desktop / Mobile      */
/* ===================== */
.desktop-only { display: flex; }
.mobile-only { display: none; }

/* Sidebar backdrop for mobile */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 25;
}

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

/* Fade-in animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* ===================== */
/* Responsive (Mobile)   */
/* ===================== */
@media (max-width: 768px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }

  #top-bar {
    padding: 0 8px;
    gap: 8px;
  }

  #top-bar .topbar-left {
    flex: 1;
  }

  #side-panel {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 56px; /* above mobile tab bar */
    width: 100% !important;
    z-index: 30;
    display: none;
    border-right: none;
    border-top: 1px solid var(--border);
  }

  #side-panel.mobile-open {
    display: flex;
  }

  .panel-tab-body {
    padding: 0 16px 16px;
  }

  #side-panel .input-popover {
    left: 16px; right: 16px;
    max-width: calc(100vw - 32px); min-width: auto;
  }

  /* Preview fullscreen on mobile */
  .preview-resize-handle {
    display: none;
  }

  .preview-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    max-width: 100vw;
  }

  .preview-panel.open {
    width: 100vw;
  }

  #input-area {
    padding: 8px 12px;
  }

  #chat-container {
    padding: 16px 12px;
  }

  .message {
    padding: 16px;
  }

  #messages {
    max-width: 100%;
  }

  .input-actions-row { flex-wrap: wrap; gap: 4px; }
  .input-actions-left { flex-wrap: wrap; order: 2; width: 100%; }
  .input-actions-right { order: 1; width: 100%; justify-content: flex-end; }

  .input-container { border-radius: var(--radius-lg); }
  #question-input { padding: 12px 14px; font-size: 15px; min-height: 48px; max-height: 180px; }
  .btn-send-icon { width: 32px; height: 32px; }

  .input-popover {
    position: fixed; bottom: auto;
    left: 16px; right: 16px;
    max-width: calc(100vw - 32px); min-width: auto;
  }

  .welcome-screen {
    min-height: 40vh;
    padding: 20px;
  }

  .welcome-logo {
    font-size: 24px;
  }

  .welcome-description {
    font-size: 14px;
  }
}

/* Desktop: no backdrop when preview is side-by-side */
@media (min-width: 769px) {
  .preview-backdrop.open { display: none; }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --panel-w: 220px;
  }
}

/* ===================== */
/* Scrollbar styling     */
/* ===================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Run view wrapper (history viewing) */
.run-view {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.run-view .message {
  margin-bottom: 0;
  border-radius: 0;
}

.run-view .message:first-child {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.run-view .message:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Tool activity indicator */
.tool-indicator {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--accent-tint);
  border-left: 2px solid var(--accent);
  padding: 4px 10px;
  margin: 4px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  animation: toolFadeIn 0.2s ease;
}

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

/* Thinking block (collapsed details) */
.thinking-block {
  margin: 6px 0 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--accent-tint);
  overflow: hidden;
}

.thinking-block summary {
  cursor: pointer;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  user-select: none;
}

.thinking-block summary:hover {
  color: var(--accent);
}

.thinking-content {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 8px 12px;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid var(--border-subtle);
}
